aboutsummaryrefslogtreecommitdiff
path: root/tests/sys/kqueue/kqueue_fork.c
Commit message (Collapse)AuthorAgeFilesLines
* kqueue: Avoid enqueuing an already-enqueued knoteMark Johnston2026-07-291-0/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | knotes with a non-trivial f_copy implementation may be activated before kqueue_fork_copy_knote() is finished. In particular, it may be enqueued at the time that kqueue_fork_copy_knote() calls knote_enqueue(). Guard against this. Add a test case which triggers the race. Fix several other problems with the replication of knote state: - Make sure only the KN_ACTIVE and KN_DISABLED status flags are inherited, the rest should not be copied. - Ignore marker knotes. - Ignore knotes for kqueues. They cannot be safely copied into the child without more work, as kqueues are inherently local to a process; on fork, we need to ensure that such knotes are patched to reference the new kqueue, not the original. - Try to keep knote state stable by holding the kqueue and knlist locks while copying. Approved by: so Security: FreeBSD-SA-26:50.kqueue Security: CVE-2026-58083 Reviewed by: kib Reported by: Hazley Samsudin of GovTech CSG Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D58223
* tests: kqueue: improve diagnostics for our CPONFORK testKyle Evans2026-04-171-11/+60
| | | | | | | | | | | | | | Notably, confirm in the child that our close-on-fork fd is actually closed, and break RECV_ALL out into a table and check each bit individually to provide a better message when the test fails. While we're here, just switch to waitid() rather than trying to identify the point where we have to make the switch. This reduces maintenance slightly, as keeping our assertion static would require still adding to a _RECV_ALL mask *just* for that purpose. Reviewed by: kib, markj (both slightly earlier version) Differential Revision: https://reviews.freebsd.org/D56372
* tests: kqueue: add a basic test for CPONFORKKyle Evans2026-04-091-0/+140
| | | | | | | | | | | | | | | | | Just copy over a timer and a write-filter, be sure that we can observe both in the child. Maybe the timer should check for a minimum time passed, but I don't know that we'd be likely to get that wrong. This also adds a negative test with a kqueue that is *not* set for CPONFORK being added to the first one, made readable, and confirming that we don't see a knote for it in the child. Some other improvements to the test noted in the review are planned in the short term, but they're not particularly worth blocking adding this as a basic sanity check. Reviewed by: kib, markj Differential Revision: https://reviews.freebsd.org/D56223
* kqueue tests: Add a regression testMark Johnston2024-01-271-0/+89
Based on the test case submitted by Andreas Bock for PR 275286. PR: 275286 MFC after: 2 weeks