Page MenuHomeFreeBSD

KASAN: Disable the sanitizer in stack_capture()
ClosedPublic

Authored by markj on May 5 2021, 2:44 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Apr 20, 2:35 AM
Unknown Object (File)
Mar 26 2024, 1:17 AM
Unknown Object (File)
Jan 14 2024, 9:01 AM
Unknown Object (File)
Jan 14 2024, 4:59 AM
Unknown Object (File)
Jan 9 2024, 12:24 PM
Unknown Object (File)
Dec 20 2023, 4:54 AM
Unknown Object (File)
Nov 15 2023, 4:07 PM
Unknown Object (File)
Nov 9 2023, 2:52 PM
Subscribers

Details

Summary

When unwinding the stack we may descend into a poisoned region of the
kernel stack. I don't see a good way to handle this except to disable
the sanitizer entirely.

Define __nosanitizeaddress depending on whether we're in the kernel or
not, since KASAN and ASAN require different attributes. Add
__nosanitizememory while I'm here.

A further complication is that clang raises an error if
no_sanitize("kernel-address") is applied to a global variable rather
than a function:

error: 'no_sanitize' attribute only applies to functions and methods

So, modify linker_set.h to apply the attribute only if we're not in the
kernel.

Diff Detail

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

Event Timeline

markj requested review of this revision.May 5 2021, 2:44 PM
sys/x86/x86/stack_machdep.c
73 ↗(On Diff #88683)

I have no idea what is going on there, but don't all called functions require the same handling, e.g. stack_zero? Is it happen to work because struct stack itself is 'not poisoned'?

sys/x86/x86/stack_machdep.c
73 ↗(On Diff #88683)

stack_zero() is fine, it's the inline dereference of the frame pointer that potentially causes problems.

Mostly on principle "I do not see anything wrong"

This revision is now accepted and ready to land.May 5 2021, 8:02 PM