diff options
author | Kyle Evans <kevans@FreeBSD.org> | 2025-07-05 03:25:14 +0000 |
---|---|---|
committer | Kyle Evans <kevans@FreeBSD.org> | 2025-07-05 17:07:17 +0000 |
commit | 7134ad650bc47d8f7719c059e2f14f647af803d7 (patch) | |
tree | cff094f82a707db0715a8f60070077edcac34eb7 /sys | |
parent | 667ef8875bad115d334a85c1023db0cf4d8379ba (diff) |
We already have a chance of cutting it close to the devctl limit
depending on the path, but this should be less than 50 bytes extra on
average. The jid gives us enough for userland to be able to actually
locate the corefile on disk in case it was produced in a jailed process,
the rest is just icing on the cake. We could extract pid/signo from the
core itself, but it's nice to be able to do some pre-filtering before
we even touch the core.
I'd like to use this in a (near-future) ucored port that will hoover up
corefiles from all over the system depending on some criteria.
Reviewed by: imp (earlier version), kib
Differential Revision: https://reviews.freebsd.org/D51164
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/kern_sig.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c index 4565abc4b540..a61ebfc5c7c8 100644 --- a/sys/kern/kern_sig.c +++ b/sys/kern/kern_sig.c @@ -4139,7 +4139,7 @@ coredump(struct thread *td) struct flock lf; struct vattr vattr; size_t fullpathsize; - int error, error1, locked; + int error, error1, jid, locked, ppid, sig; char *name; /* name of corefile */ void *rl_cookie; off_t limit; @@ -4168,6 +4168,10 @@ coredump(struct thread *td) PROC_UNLOCK(p); return (EFBIG); } + + ppid = p->p_oppid; + sig = p->p_sig; + jid = p->p_ucred->cr_prison->pr_id; PROC_UNLOCK(p); error = corefile_open(p->p_comm, cred->cr_uid, p->p_pid, td, @@ -4253,6 +4257,9 @@ coredump(struct thread *td) } devctl_safe_quote_sb(sb, name); sbuf_putc(sb, '"'); + + sbuf_printf(sb, " jid=%d pid=%d ppid=%d signo=%d", + jid, p->p_pid, ppid, sig); if (sbuf_finish(sb) == 0) devctl_notify("kernel", "signal", "coredump", sbuf_data(sb)); out2: |