aboutsummaryrefslogtreecommitdiff
path: root/libfuzzer/FuzzerUtilPosix.cpp
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2022-03-25 12:32:02 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2022-03-25 12:32:02 +0000
commit9c2b23171805126e9464a32d20faafe9a9f61098 (patch)
treeb1b15d9075830bd60f4e5587c8d9f27f4bcba29f /libfuzzer/FuzzerUtilPosix.cpp
parent6ef352c644106bdf993c1a4fcc0a253716b92780 (diff)
parent4e031b3a08a06e36fa74d66192dac5250ad69131 (diff)
downloadlibfuzzer-sys-9c2b23171805126e9464a32d20faafe9a9f61098.tar.gz
Snap for 8358640 from 4e031b3a08a06e36fa74d66192dac5250ad69131 to mainline-go-cellbroadcast-releaseaml_go_cbr_330912000android13-mainline-go-cellbroadcast-release
Change-Id: Ic3682978db6b184b0b28c622a3bc71522bace2bb
Diffstat (limited to 'libfuzzer/FuzzerUtilPosix.cpp')
-rw-r--r--libfuzzer/FuzzerUtilPosix.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/libfuzzer/FuzzerUtilPosix.cpp b/libfuzzer/FuzzerUtilPosix.cpp
index afb7334..0446d73 100644
--- a/libfuzzer/FuzzerUtilPosix.cpp
+++ b/libfuzzer/FuzzerUtilPosix.cpp
@@ -77,10 +77,13 @@ static void SetSigaction(int signum,
return;
}
- sigact = {};
- sigact.sa_flags = SA_SIGINFO;
- sigact.sa_sigaction = callback;
- if (sigaction(signum, &sigact, 0)) {
+ 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);
+ new_sigact.sa_sigaction = callback;
+ if (sigaction(signum, &new_sigact, nullptr)) {
Printf("libFuzzer: sigaction failed with %d\n", errno);
exit(1);
}