fuzz: Enable additional hardening checks#10830
Open
tmleman wants to merge 2 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Enables extra runtime hardening checks in the Zephyr native POSIX libFuzzer build configuration to improve detection of memory corruption issues during fuzzing.
Changes:
- Enable
CONFIG_SYS_HEAP_HARDENING_EXTREMEfor stronger heap corruption detection. - Enable
CONFIG_STACK_SENTINELto detect stack overflows in fuzzing builds.
IPC fuzzer is built with Zephyr sys_heap. Because we have a custom allocator, the compiler sanitizers alone are not able to detect all errors related to memory allocation. Enabling heap hardening aims to increase the number of potentially detectable errors in fuzz builds. CONFIG_SYS_HEAP_HARDENING_EXTREME: adds per-chunk canary trailers (catching buffer overflows that spill even a single byte into the next chunk), double-free detection, free-list pointer validation, and a full heap structure walk after every alloc/free operation. This last check catches external corruption (e.g. a wild write from an unrelated component damaging heap metadata) before the allocator acts on it, rather than letting the damage propagate silently to the next allocation that happens to touch the corrupted region. The measured cost is ~7% throughput (288k -> 280k execs/30s), negligible given the class of bugs it surfaces. Signed-off-by: Tomasz Leman <tomasz.m.leman@intel.com>
Enable Zephyr stack sentinel checks for the native libFuzzer build. This complements the heap hardening option by catching Zephyr thread stack overflows closer to the corrupting input. CONFIG_STACK_SENTINEL: stores a magic value at the lowest addresses of each thread stack and checks it on context switch, interrupt return, k_yield(), and thread exit. When the sentinel is corrupted the system traps immediately, giving the fuzzer a clear crash signal instead of allowing silent corruption that manifests later in an unrelated path. This is particularly useful in UBSan-only fuzz runs where ASan stack redzones are not available. Signed-off-by: Tomasz Leman <tomasz.m.leman@intel.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Since performance is not so important in fuzzing builds I decided to enable additional debug utilities that allow detecting more issues related to memory corruption issues.