Page MenuHomeFreeBSD

thread: Simplify sanitizer integration with thread creation
ClosedPublic

Authored by markj on Apr 21 2024, 3:15 PM.
Tags
None
Referenced Files
F157614089: D44891.diff
Sat, May 23, 10:41 AM
Unknown Object (File)
Tue, May 19, 7:17 AM
Unknown Object (File)
Mon, May 18, 11:41 PM
Unknown Object (File)
Mon, May 18, 6:08 PM
Unknown Object (File)
Mon, May 18, 4:21 AM
Unknown Object (File)
Mon, May 18, 4:16 AM
Unknown Object (File)
Sun, May 17, 4:01 AM
Unknown Object (File)
Sun, May 17, 4:00 AM
Subscribers

Details

Summary

fork() may allocate a new thread in one of two ways: from UMA, or cached
in a freed proc that was just allocated from UMA. In either case, KASAN
and KMSAN need to initialize some state; in particular they need to
initialize the shadow mapping of the new thread's stack.

This is done differently between KASAN and KMSAN, which is confusing.
This patch improves things a bit:

  • Add a new thread_recycle() function, which moves all kernel stack handling out of kern_fork.c, since it doesn't really belong there.
  • Then, thread_alloc_stack() has only one local caller, so just inline it.
  • Avoid redundant shadow stack initialization: thread_alloc() initializes the KMSAN shadow stack (via kmsan_thread_alloc()) even through vm_thread_new() already did that.
  • Add kasan_thread_alloc(), for consistency with kmsan_thread_alloc().

No functional change intended.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 57256
Build 54144: arc lint + arc unit