DynamoRIO / DynamoRIO/dynamorio

Mac does not allow clearing sigaltstack after abnormal signal exit

Open
#1,814 0 comments 0 reactions 0 assignees View on GitHub
Bug-Assert OpSys-OSX
Dominant language
C
Stars
3.2k
Forks
629
Avg merge
2d 15h
Merged PRs (30d)
31

Description

If we have a crash in a signal handler and we then exit DR we get this on Mac:

```
-22 for 0x4f069000 0xe000 0x4 cur=0x4f04eb80
```

The app crash is inside the handler: does the kernel really track whether
we called sigreturn? It looks like it does:

```
/extsw/mac/xnu-2422.1.72/bsd/kern/kern_sig.c
if (ss.ss_flags & SA_DISABLE) {
/* if we are here we are not in the signal handler ;so no need to check */
if (uth->uu_sigstk.ss_flags & SA_ONSTACK)
return (EINVAL);

/extsw/mac/xnu-2422.1.72/bsd/dev/i386/unix_signal.c
sendsig()
ut->uu_sigstk.ss_flags |= SA_ONSTACK;
sigreturn()
ut->uu_sigstk.ss_flags &= ~SA_ONSTACK;
```

This doesn't seem like the right thing for the kernel to do, but we'll have
to work around it by allowing the syscall to fail.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.