[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
This commit is contained in:
Matt Morehouse 2020-12-10 10:16:19 -08:00
parent 4f051fe374
commit bdaeb82a5f
3 changed files with 21 additions and 0 deletions

View File

@ -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,

View File

@ -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

View File

@ -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();