Skip to content

[libFuzzer] always install signal handler with SA_ONSTACK #147422

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions compiler-rt/lib/fuzzer/FuzzerUtilPosix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,14 @@ static void SetSigaction(int signum,
}

struct sigaction new_sigact = {};
// Address sanitizer needs SA_ONSTACK (causing the signal handler to run on a
// dedicated stack) in order to be able to detect stack overflows; keep the
// flag if it's set.
new_sigact.sa_flags = SA_SIGINFO | (sigact.sa_flags & SA_ONSTACK);
// SA_ONSTACK is required for certain runtimes that use small stacks, for
// instance the Go runtime.
// See https://github.com/golang/go/issues/49075
// Address sanitizer also wants SA_ONSTACK, and the fuzzer and sanitizer
// often run together.
// SA_ONSTACK is a no-op unless someone also calls sigaltstack. That is left
// up to code that needs it.
new_sigact.sa_flags = SA_SIGINFO | SA_ONSTACK;
new_sigact.sa_sigaction = callback;
if (sigaction(signum, &new_sigact, nullptr)) {
Printf("libFuzzer: sigaction failed with %d\n", errno);
Expand Down
Loading