Page MenuHomeFreeBSD

kern_kthread: fork1() does not handle locked Giant
ClosedPublic

Authored by kib on Sep 2 2023, 7:35 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Mar 28, 9:33 AM
Unknown Object (File)
Tue, Mar 17, 10:37 PM
Unknown Object (File)
Tue, Mar 17, 10:30 PM
Unknown Object (File)
Sun, Mar 15, 8:18 AM
Unknown Object (File)
Sat, Mar 14, 6:22 PM
Unknown Object (File)
Sat, Mar 7, 7:59 PM
Unknown Object (File)
Fri, Mar 6, 7:12 AM
Unknown Object (File)
Feb 24 2026, 12:28 AM
Subscribers

Details

Summary
fork1() does not behave if called under Giant.  For instance, it might
need to call thread_suspend_check() which explicitly verifies that Giant
is not locked.  On the other hand, the kthread KPI is often called from
SYSINIT() which is still Giant-locked.

Handle this by dropping Giant in kthread_add() and kproc_create().

See for instance https://people.freebsd.org/~pho/stress/log/log0485.txt

Style changes will be a separate commit.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable