Thread View: muc.lists.freebsd.bugs
6 messages
6 total messages
Started by bugzilla-noreply
Mon, 23 Nov 2026 21:59
[Bug 301060] jaildesc: jail_get(2) with JAIL_DYING never reports jail removal on the returned descriptor
Author: 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
[Bug 301060] jaildesc: jail_get(2) with JAIL_DYING never reports jail removal on the returned descriptor
Author: bugzilla-noreply
Date: Mon, 23 Nov 2026 21:59
Date: Mon, 23 Nov 2026 21:59
18 lines
2548 bytes
2548 bytes
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=301060 --- Comment #1 from laamalif@proton.me --- Created attachment 277618 --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=277618&action=edit Fix: set JDF_REMOVED on JAIL_DYING descriptors in jaildesc_set_prison() + ATF test get_desc_dying -- 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
[Bug 301060] jaildesc: jail_get(2) with JAIL_DYING never reports jail removal on the returned descriptor
Author: bugzilla-noreply
Date: Mon, 23 Nov 2026 21:59
Date: Mon, 23 Nov 2026 21:59
18 lines
2542 bytes
2542 bytes
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=301060 --- Comment #2 from laamalif@proton.me --- Created attachment 277619 --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=277619&action=edit Reproducer (raw syscalls): prints PASS/FAIL per check, exit 0 only on all-pass; run as root -- 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
[Bug 301060] jaildesc: jail_get(2) with JAIL_DYING never reports jail removal on the returned descriptor
Author: bugzilla-noreply
Date: Mon, 23 Nov 2026 21:59
Date: Mon, 23 Nov 2026 21:59
16 lines
2521 bytes
2521 bytes
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=301060 --- Comment #3 from laamalif@proton.me --- Created attachment 277620 --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=277620&action=edit Reproducer (libjail path): same PASS/FAIL discipline; build with -ljail -- 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
[Bug 301060] jaildesc: jail_get(2) with JAIL_DYING never reports jail removal on the returned descriptor
Author: bugzilla-noreply
Date: Mon, 23 Nov 2026 21:59
Date: Mon, 23 Nov 2026 21:59
17 lines
2468 bytes
2468 bytes
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=301060 --- Comment #4 from laamalif@proton.me --- Please use: Author: Laam Alif <laamalif@proton.me> Reported by: Laam Alif at Ibteda Digital Library PR: 301060 -- 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
[Bug 301060] jaildesc: jail_get(2) with JAIL_DYING never reports jail removal on the returned descriptor
Author: bugzilla-noreply
Date: Mon, 23 Nov 2026 23:40
Date: Mon, 23 Nov 2026 23:40
16 lines
2539 bytes
2539 bytes
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=301060
Mark Linimon <linimon@FreeBSD.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|bugs@FreeBSD.org |jail@FreeBSD.org
--
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
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads