Page MenuHomeFreeBSD

Make kernel print jail ID when logging a process exit.
ClosedPublic

Authored by marieheleneka_gmail.com on Dec 20 2018, 10:46 AM.

Details

Summary

Previously, when a process was killed (ex: core dumped), the kernel would log a message like this:
pid 74906 (top), uid 0: exited on signal 11 (core dumped)

The message now looks like this:
pid 66526 (top), jid: 1, uid 0: exited on signal 11 (core dumped)

"jid" will be 0 for processes not running in a jail, which is in line with other parts of the system. (ex: "ps -J 0" to show unjailed processes)
"jid" will be -1 if the jid information is unavailable for some reason. (this should ordinarily not happen, but I've not dug enough in the code to guarantee it won't ever happen.)

Suggested commit message:
Kernel now includes jail ID when logging a process exit. jid is 0 for unjailed processes.

Submitted by: Marie Helene Kvello-Aune <freebsd@mhka.no>
Sponsored by: Modirum MDPay
relnotes: yes

Test Plan

Apply patch, build & install kernel.
Spin up a few jails
Check dmesg output after running "kill -11" on a few jailed and unjailed processes.

Diff Detail

Repository
rS FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

Added jid to log message for sigexit as well.
Made formatting more consistent (removed a colon)

In D18618#397024, @mjg wrote:

That diff looks interesting, and it made me realize I had missed sigexit. That's fixed now.

I much prefer D27's way of formatting things, but it seems to me it's dead in the water.

Made code a bit more readable by storing jid as a variable, instead of double ?: syntax.
Fixed trailing whitespace.

This revision was not accepted when it landed; it landed in state Needs Review.Dec 29 2018, 2:49 PM
This revision was automatically updated to reflect the committed changes.