Article View: muc.lists.freebsd.bugs
Article #679[Bug 301060] jaildesc: jail_get(2) with JAIL_DYING never reports jail removal on the returned descriptor
From: bugzilla-noreply
Date: Mon, 23 Nov 2026 21:59
Date: Mon, 23 Nov 2026 21:59
84 lines
5536 bytes
5536 bytes
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=301060
Bug ID: 301060
Summary: jaildesc: jail_get(2) with JAIL_DYING never reports
jail removal on the returned descriptor
Product: Base System
Version: CURRENT
Hardware: Any
OS: Any
Status: New
Severity: Affects Only Me
Priority: ---
Component: kern
Assignee: bugs@FreeBSD.org
Reporter: laamalif@proton.me
Jail descriptors returned by jail_get(2) with JAIL_DYING|JAIL_GET_DESC
(or JAIL_OWN_DESC) for an already-dying jail never report that the jail
was removed: poll(2) on the descriptor does not return POLLHUP, and
EVFILT_JAIL on it does not fire NOTE_JAIL_REMOVE. A descriptor obtained
while the jail was alive does report removal, so a caller waiting on the
dying-jail descriptor waits forever.
The one-shot removal broadcast in prison_cleanup_locked() ->
prison_knote(NOTE_JAIL_REMOVE) happens before kern_jail_get() can attach
the new descriptor, so jaildesc_set_prison() links the descriptor without
copying the prison's dying state. The descriptor reports nothing, and
the jail is released only when the caller closes it.
Reproduced on FreeBSD 15.1-RELEASE-p6 (arm64) with both the raw syscalls
and libjail, and on FreeBSD 16.0-CURRENT (amd64, main at the November
2026 tip, 6edecf52def6) before and after the attached patch. The
reproducers (attached, jd_dying_v2.c for the raw syscall path,
jd_dying_libjail.c for the libjail path) print per-check PASS/FAIL and
exit 0 only when everything passes. They must run as root; they pin the
dying jail with an alive reference so it cannot disappear before the
checks complete, and clean up after themselves.
Stock 16.0-CURRENT, jd_dying_v2 (raw syscalls):
jid 1 removed, dying, pinned
alive GET_DESC (control) poll POLLHUP PASS
alive GET_DESC (control) kevent NOTE_JAIL_REMOVE PASS
dying GET_DESC poll POLLHUP FAIL
dying GET_DESC kevent NOTE_JAIL_REMOVE FAIL
dying OWN_DESC poll POLLHUP FAIL
dying OWN_DESC kevent NOTE_JAIL_REMOVE FAIL
jail fully released after close PASS
RESULT: FAIL
exit=1
The control line (a descriptor taken while the jail was alive) passes on
the same kernel in the same run, so the failure is specific to the
JAIL_DYING lookup path. The libjail binary produces the same four
failures through jail_setv()/jail_getv().
The attached patch adds the missing state copy in
jaildesc_set_prison() (sys/kern/kern_jaildesc.c): if the prison is not
alive, the descriptor gets JDF_REMOVED at attach time, the same flag the
removal broadcast sets on pre-existing descriptors. It also adds an
ATF regression test (get_desc_dying in tests/sys/kern/jaildesc.c) that
creates a jail, removes it, obtains a descriptor with JAIL_DYING, and
requires poll() to return POLLHUP within a second.
I booted a kernel built from the current tip with the patch applied.
Both reproducers pass all cases, and the new test passes:
jaildesc_test get_desc_dying -> passed
against the same test failing on the stock kernel at the poll() timeout.
The seven pre-existing jaildesc test cases still pass; I ran each one
directly outside kyua because the installed Kyuafile on my test box
predates the test binary. The patch was applied and tested on 16.0-
CURRENT only; I have not built or booted a stable or release kernel
with it.
--
You are receiving this mail because:
You are the assignee for the bug.
--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-admin@muc.de
Technical Details
Message-ID:
<bug-301060-227@https.bugs.freebsd.org/bugzilla/>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!usenet.goja.nl.eu.org!2.eu.feeder.erje.net!feeder.erje.net!news2.arglkargh.de!news.karotte.org!news.muc.de!.POSTED.news.muc.de!not-for-mailShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!usenet.goja.nl.eu.org!2.eu.feeder.erje.net!feeder.erje.net!news2.arglkargh.de!news.karotte.org!news.muc.de!.POSTED.news.muc.de!not-for-mail From: bugzilla-noreply@freebsd.org Newsgroups: muc.lists.freebsd.bugs Subject: [Bug 301060] jaildesc: jail_get(2) with JAIL_DYING never reports jail removal on the returned descriptor Date: Mon, 23 Nov 2026 21:59:28 +0000 Organization: Newsgate at muc.de e.V. Approved: news-admin@muc.de Distribution: world Message-ID: <bug-301060-227@https.bugs.freebsd.org/bugzilla/> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: news.muc.de; posting-host="news.muc.de:193.149.48.2"; logging-data="29522"; mail-complaints-to="news-admin@muc.de" X-Original-To: bugs@mlmmj.nyi.freebsd.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1795471168; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=LEPihZV+NlL0RZPmHi+hKSjkXY6wUIPTqlQx51IkzRs=; b=deyhTmziKVHAy0+jwQ69EkQExfaGc/daJuMfJbUAP/usLrF8VMZ+bj/lulELTIi/Zi8/LW OSisA3XbIAr8l+Ef+s3XewFCMj4XDMedWtpxoB1nSMZObF47/feiMkIOTEgWnFuoQlpBiu 1+CQ4IqOZHMZ1mrKFLEBTmlITar35QxB4y+rFYwCaUaT2l+wAmJEHpAoVC7/HBxYSfckm+ RqK2s6gLE3rI9qziQVUhK1FQYLRAl2Rf9gT7efT+KYZv2BfjoxWY5pKK/AhRZwt20f5laY yhT9BN97vpqKTVxhyJ9zbWTBEkthvFDhr9lfu+EWxAsDUZi9cMSJQ8SH5tYueA== X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f Auto-Submitted: auto-generated Precedence: list X-Newsgate-Id: f02c70b8849f+ X-No-Archive: Yes