Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 5 Jul 2025 17:07:24 GMT
From:      Kyle Evans <kevans@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 7134ad650bc4 - main - kern: add some extra metadata to the coredump devctl notification
Message-ID:  <202507051707.565H7O6d029002@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by kevans:

URL: https://cgit.FreeBSD.org/src/commit/?id=7134ad650bc47d8f7719c059e2f14f647af803d7

commit 7134ad650bc47d8f7719c059e2f14f647af803d7
Author:     Kyle Evans <kevans@FreeBSD.org>
AuthorDate: 2025-07-05 03:25:14 +0000
Commit:     Kyle Evans <kevans@FreeBSD.org>
CommitDate: 2025-07-05 17:07:17 +0000

    kern: add some extra metadata to the coredump devctl notification
    
    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
---
 sys/kern/kern_sig.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

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:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202507051707.565H7O6d029002>