From nobody@FreeBSD.org  Tue Apr  6 14:47:27 2010
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 0980E1065672
	for <freebsd-gnats-submit@FreeBSD.org>; Tue,  6 Apr 2010 14:47:27 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id EBE8E8FC26
	for <freebsd-gnats-submit@FreeBSD.org>; Tue,  6 Apr 2010 14:47:26 +0000 (UTC)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.3/8.14.3) with ESMTP id o36ElQ3B030695
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 6 Apr 2010 14:47:26 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id o36ElQSG030692;
	Tue, 6 Apr 2010 14:47:26 GMT
	(envelope-from nobody)
Message-Id: <201004061447.o36ElQSG030692@www.freebsd.org>
Date: Tue, 6 Apr 2010 14:47:26 GMT
From: "David E. Cross" <dcross@okcupid.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: Kernel messages about processes don't include Jail Identifier
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         145434
>Category:       kern
>Synopsis:       [kernel] [patch] Kernel messages about processes don't include Jail Identifier
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Tue Apr 06 14:50:04 UTC 2010
>Closed-Date:    
>Last-Modified:  Tue Apr  6 20:00:11 UTC 2010
>Originator:     David E. Cross
>Release:        8.0-RELEASE-amd64
>Organization:
Humor Rainbow Inc.
>Environment:
FreeBSD foo.bar.baz 8.0-RELEASE-p2 FreeBSD 8.0-RELEASE-p2 #0: Mon Apr  5 14:42:00 EDT 2010     root@foo.bar.baz:/usr/obj/usr/src/sys/GENERIC  amd64
>Description:
Processes which exit abnormally display a kernel message to this effect that includes some basic information about the process.  Its PID, its UID, its name.

On a machine with a lot of jails, this information can be essentially useless.

Consider a webhost with 50 jails serving PHP via fastcgi and one is crashing, its near impossible to track it down with just the information as currently provided.

>How-To-Repeat:
Try to trace down a coredump on a machine with lots of jails
>Fix:
Apply the included patch.

Patch attached with submission follows:

--- sys/kern/kern_sig.c.orig	2009-10-24 21:10:29.000000000 -0400
+++ sys/kern/kern_sig.c	2010-04-06 10:44:42.000000000 -0400
@@ -57,6 +57,8 @@
 #include <sys/mutex.h>
 #include <sys/namei.h>
 #include <sys/proc.h>
+#include <sys/ucred.h>
+#include <sys/jail.h>
 #include <sys/posix4.h>
 #include <sys/pioctl.h>
 #include <sys/resourcevar.h>
@@ -2733,8 +2735,9 @@
 			sig |= WCOREFLAG;
 		if (kern_logsigexit)
 			log(LOG_INFO,
-			    "pid %d (%s), uid %d: exited on signal %d%s\n",
+			    "pid %d (%s), jid %d, uid %d: exited on signal %d%s\n",
 			    p->p_pid, p->p_comm,
+			    (td->td_ucred && td->td_ucred->cr_prison) ? td->td_ucred->cr_prison->pr_id : 0, 
 			    td->td_ucred ? td->td_ucred->cr_uid : -1,
 			    sig &~ WCOREFLAG,
 			    sig & WCOREFLAG ? " (core dumped)" : "");


>Release-Note:
>Audit-Trail:

From: "Bjoern A. Zeeb" <bz@FreeBSD.org>
To: bug-followup@FreeBSD.org, dcross@okcupid.com
Cc:  
Subject: Re: kern/145434: [kernel] [patch] Kernel messages about processes
 don't include Jail Identifier
Date: Tue, 6 Apr 2010 19:48:08 +0000 (UTC)

 On FreeBSD 8./9.x it might actually be more usefull to print the jail
 name as it's always there (and would be the jid by default if not set).
 
 For FreeBSD 7.x the jail_name is optional so the jid might be the
 better info.
 
 -- 
 Bjoern A. Zeeb         It will not break if you know what you are doing.
>Unformatted:
