From owner-freebsd-bugs@freebsd.org Wed Jan 6 05:32:46 2016 Return-Path: Delivered-To: freebsd-bugs@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0E912A63B0F for ; Wed, 6 Jan 2016 05:32:46 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2001:1900:2254:206a::16:76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id F36071FCD for ; Wed, 6 Jan 2016 05:32:45 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from bugs.freebsd.org ([127.0.1.118]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id u065WiaO040047 for ; Wed, 6 Jan 2016 05:32:45 GMT (envelope-from bugzilla-noreply@freebsd.org) From: bugzilla-noreply@freebsd.org To: freebsd-bugs@FreeBSD.org Subject: [Bug 178396] [kernel] [patch] Add jid to kernel log when a process has been forced closed Date: Wed, 06 Jan 2016 05:32:44 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: kern X-Bugzilla-Version: unspecified X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Only Me X-Bugzilla-Who: mjg@FreeBSD.org X-Bugzilla-Status: In Progress X-Bugzilla-Resolution: X-Bugzilla-Priority: Normal X-Bugzilla-Assigned-To: freebsd-bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 06 Jan 2016 05:32:46 -0000 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D178396 Mateusz Guzik changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |mjg@FreeBSD.org --- Comment #4 from Mateusz Guzik --- The feature is definitely desirable. I would argue the complete solution would just support jail-aware dmesgs and print jail-specific stuff specific stuff with appropriate prefix to the 'ma= in' dmesg. This would require some effort and may be off the table for now. Regardless, it would be good if the new message here got the format one wou= ld expect to see in the more advanced case. There is further issue with increased infoleaks - now not only you learn wh= at segfaulting programs are being used by other jails, you get their (host)nam= es. Either way, the patch is wrong: + if (jailed(p->p_ucred)) { + char buf[MAXHOSTNAMELEN + 3]; + if (strcmp(p->p_ucred->cr_prison->pr_hostna= me, "") !=3D 0) { + sprintf(buf, " (%s)", p->p_ucred->cr_prison->pr_hostname); + } else { + *buf =3D '\0'; + } This should have used getcredhostname, assuming hostname is desirable. I wo= uld argue hostname is not the field you are interested in - after all, jail can change it. Instead, you should obtain jail name. Also, this patch does not handle hierarchical jails. + log(LOG_INFO, + "pid %d (%s), uid %d, jid %d%s: exited = on signal %d%s\n", + p->p_pid, p->p_comm, + td->td_ucred->cr_uid, + p->p_ucred->cr_prison->pr_id, + buf, + 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)" : ""= ); + } As a nit, just should have been handled with one log() call. Missing option= al jail bit could be provided with a pointer to "". That said, I would be in favor of messages like this one: [$jailname] $msg That is: pid 857 (perl), uid 1001: exited on signal 6 is turned into: [foo] pid 857 (perl), uid 1001: exited on signal 6 Assuming jail name is 'foo'. For hierarchical jails this would be [foo.bar]. --=20 You are receiving this mail because: You are the assignee for the bug.=