apache / apache/nuttx

Sigprocmask handling errors in nxsig_deliver()

Open
#9,300 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
4k
Forks
1.7k
Avg merge
1d 17h
Merged PRs (30d)
237

Description

When delivering a signal, the signals specified in sa_mask are masked:

/* Save a copy of the old sigprocmask and install the new
* (temporary) sigprocmask. The new sigprocmask is the union
* of the current sigprocmask and the sa_mask for the signal being
* delivered plus the signal being delivered.
*/

savesigprocmask = stcb->sigprocmask;
sigorset(&newsigprocmask, &savesigprocmask, &sigq->mask);
stcb->sigprocmask = newsigprocmask;

[modified by #9299]

However there are two problems when when the signal handler returns and the sigprocmask is restored as mentioned in the comments:

/* Restore the original sigprocmask.
*
* What if the signal handler changed the sigprocmask? Try to retain
* any such changes here.
*
* REVISIT: This logic is imperfect. It will fail to detect bits set
* in the current sigprocmask that were already set by newsigprocmask.
*/

nxsig_xorset(&tmpset1, &stcb->sigprocmask, &newsigprocmask);
sigandset(&tmpset2, &stcb->sigprocmask, &tmpset1);
nxsig_nandset(&tmpset1, &savesigprocmask, &tmpset1);
sigorset(&stcb->sigprocmask, &tmpset1, &tmpset2);

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.