Author: Matt Morehouse Date: 2020-12-10T10:16:36-08:00 New Revision: bdaeb82a5f84b813f5eb7e63e6e111c4566c61ab
URL: https://github.com/llvm/llvm-project/commit/bdaeb82a5f84b813f5eb7e63e6e111c4566c61ab DIFF: https://github.com/llvm/llvm-project/commit/bdaeb82a5f84b813f5eb7e63e6e111c4566c61ab.diff LOG: [DFSan] Add custom wrapper for sigaltstack. The wrapper clears shadow for old_ss. Reviewed By: stephan.yichao.zhao Differential Revision: https://reviews.llvm.org/D93041 Added: Modified: compiler-rt/lib/dfsan/dfsan_custom.cpp compiler-rt/lib/dfsan/done_abilist.txt compiler-rt/test/dfsan/custom.cpp Removed: ################################################################################ diff --git a/compiler-rt/lib/dfsan/dfsan_custom.cpp b/compiler-rt/lib/dfsan/dfsan_custom.cpp index 576f7f64e301..b43f978d8a2c 100644 --- a/compiler-rt/lib/dfsan/dfsan_custom.cpp +++ b/compiler-rt/lib/dfsan/dfsan_custom.cpp @@ -799,6 +799,16 @@ int __dfsw_sigaction(int signum, const struct sigaction *act, return ret; } +SANITIZER_INTERFACE_ATTRIBUTE +int __dfsw_sigaltstack(const stack_t *ss, stack_t *old_ss, dfsan_label ss_label, + dfsan_label old_ss_label, dfsan_label *ret_label) { + int ret = sigaltstack(ss, old_ss); + if (ret != -1 && old_ss) + dfsan_set_label(0, old_ss, sizeof(*old_ss)); + *ret_label = 0; + return ret; +} + SANITIZER_INTERFACE_ATTRIBUTE int __dfsw_gettimeofday(struct timeval *tv, struct timezone *tz, dfsan_label tv_label, dfsan_label tz_label, diff --git a/compiler-rt/lib/dfsan/done_abilist.txt b/compiler-rt/lib/dfsan/done_abilist.txt index 9a92098f22eb..b8cfa3b9941b 100644 --- a/compiler-rt/lib/dfsan/done_abilist.txt +++ b/compiler-rt/lib/dfsan/done_abilist.txt @@ -200,6 +200,7 @@ fun:nanosleep=custom fun:pread=custom fun:read=custom fun:recvmsg=custom +fun:sigaltstack=custom fun:socketpair=custom fun:stat=custom fun:time=custom diff --git a/compiler-rt/test/dfsan/custom.cpp b/compiler-rt/test/dfsan/custom.cpp index 8305941d0054..a03f33f769af 100644 --- a/compiler-rt/test/dfsan/custom.cpp +++ b/compiler-rt/test/dfsan/custom.cpp @@ -762,6 +762,15 @@ void test_sigaction() { ASSERT_READ_ZERO_LABEL(&oldact, sizeof(oldact)); } +void test_sigaltstack() { + stack_t old_altstack = {}; + dfsan_set_label(j_label, &old_altstack, sizeof(old_altstack)); + int ret = sigaltstack(NULL, &old_altstack); + assert(ret == 0); + ASSERT_ZERO_LABEL(ret); + ASSERT_READ_ZERO_LABEL(&old_altstack, sizeof(old_altstack)); +} + void test_gettimeofday() { struct timeval tv; struct timezone tz; @@ -1172,6 +1181,7 @@ int main(void) { test_sched_getaffinity(); test_select(); test_sigaction(); + test_sigaltstack(); test_sigemptyset(); test_snprintf(); test_socketpair(); _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits