Commit d7c33cd7 authored by Kirill Smelkov's avatar Kirill Smelkov

bigfile/virtmem: When restoring SIGSEGV, don't change procmask for other signals

We factored out SIGSEGV block/restore from fileh_dirty_writeout() to all
functions in cb7a7055 (bigfile/virtmem: Block/restore SIGSEGV in
non-pagefault-handling function). The restoration however just sets
whole thread sigmask.

It could be possible that between block/restore calls procmask for other
signals could be changed, and this way - setting procmask directly - we
will overwrite them.

So be careful, and when restoring SIGSEGV mask, touch mask bit for only
that signal.

( we need xsigismember helper to get this done, which is also introduced
  in this patch )
parent 8fa9af7f
......@@ -64,7 +64,12 @@ static void sigsegv_block(sigset_t *save_sigset)
static void sigsegv_restore(const sigset_t *save_sigset)
{
xpthread_sigmask(SIG_SETMASK, save_sigset, NULL);
int how = xsigismember(save_sigset, SIGSEGV) ? SIG_BLOCK : SIG_UNBLOCK;
sigset_t mask_segv;
xsigemptyset(&mask_segv);
xsigaddset(&mask_segv, SIGSEGV);
xpthread_sigmask(how, &mask_segv, NULL);
}
......
......@@ -76,6 +76,7 @@ void xftruncate(int fd, off_t len);
void xsigemptyset(sigset_t *set);
void xsigaddset(sigset_t *set, int sig);
int xsigismember(const sigset_t *set, int sig);
void xpthread_sigmask(int how, const sigset_t *set, sigset_t *oldset);
#endif
......@@ -123,6 +123,16 @@ void xsigaddset(sigset_t *set, int sig)
BUGe();
}
int xsigismember(const sigset_t *set, int sig)
{
int ret;
ret = sigismember(set, sig);
if (ret == -1)
BUGe();
return ret;
}
/* pthread_sigmask() should not fail on any correct usage */
void xpthread_sigmask(int how, const sigset_t *set, sigset_t *oldset)
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment