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)
Thu, Dec 25, 9:40 PM
Unknown Object (File)
Dec 20 2025, 8:44 PM
Unknown Object (File)
Nov 24 2025, 8:16 PM
Unknown Object (File)
Nov 22 2025, 6:54 AM
Unknown Object (File)
Nov 19 2025, 12:05 AM
Unknown Object (File)
Nov 16 2025, 5:33 PM
Unknown Object (File)
Nov 14 2025, 9:30 AM
Unknown Object (File)
Nov 3 2025, 4:16 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