kern/178396: Add jid to kernel log when a process has been forced closed

Clement Moulin freebsd at simplerezo.com
Tue May 7 14:10:00 UTC 2013


>Number:         178396
>Category:       kern
>Synopsis:       Add jid to kernel log when a process has been forced closed
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          update
>Submitter-Id:   current-users
>Arrival-Date:   Tue May 07 14:10:00 UTC 2013
>Closed-Date:
>Last-Modified:
>Originator:     Clement Moulin
>Release:        9.0
>Organization:
SimpleRezo
>Environment:
FreeBSD XXX.simplerezo.com 9.0-RELEASE-p4 FreeBSD 9.0-RELEASE-p4 #0: Thu Aug 16 12:10:44 CEST 2012     root at XXX.simplerezo.com:/usr/obj/storage/freebsd/src/sys/KERNEL  amd64
>Description:
When process is forced killed, kernel log "process %pid (%processname), uid %uid: exited on signal %sid".

In a system hosting jails, this message, since it is produced by kernel, is logged on the host.

I'm suggesting to also log JID for "debugging" purpose: in my case, i have several jails, each with an apache process, and without JID information, i'm not able to find which one is causing "httpd: exiting on signal 10", without reading every apache error logs of each jail...

>How-To-Repeat:

>Fix:
See proposal patch in attachment.

Patch attached with submission follows:

--- kern_sig.c.orig	2013-05-07 11:11:44.000000000 +0200
+++ kern_sig.c	2013-05-07 11:33:52.000000000 +0200
@@ -2869,12 +2869,21 @@
 		if (coredump(td) == 0)
 			sig |= WCOREFLAG;
 		if (kern_logsigexit)
-			log(LOG_INFO,
-			    "pid %d (%s), uid %d: exited on signal %d%s\n",
-			    p->p_pid, p->p_comm,
-			    td->td_ucred ? td->td_ucred->cr_uid : -1,
-			    sig &~ WCOREFLAG,
-			    sig & WCOREFLAG ? " (core dumped)" : "");
+		  	if (p->p_flag & P_JAILED)
+				log(LOG_INFO,
+				    "pid %d (%s), uid %d, jid %d: exited on signal %d%s\n",
+				    p->p_pid, p->p_comm,
+				    td->td_ucred ? td->td_ucred->cr_uid : -1,
+				    p->p_ucred ? p->p_ucred->cr_prison->pr_id : -1,
+				    sig &~ WCOREFLAG,
+				    sig & WCOREFLAG ? " (core dumped)" : "");
+			else
+				log(LOG_INFO,
+				    "pid %d (%s), uid %d: exited on signal %d%s\n",
+				    p->p_pid, p->p_comm,
+				    td->td_ucred ? td->td_ucred->cr_uid : -1,
+				    sig &~ WCOREFLAG,
+				    sig & WCOREFLAG ? " (core dumped)" : "");
 	} else
 		PROC_UNLOCK(p);
 	exit1(td, W_EXITCODE(0, sig));


>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-bugs mailing list