libthr: prevent setcontext() from masking SIGTHR

__thr_setcontext() mistakenly tested for the presence of SIGCANCEL
in its local ucontext_t instead of the parameter. Therefore,
if a thread calls setcontext() with a context whose signal mask
contains SIGTHR (a.k.a. SIGCANCEL), that signal will be blocked,
preventing the thread from being cancelled or suspended.

Reported by:	gcc 6.1 via RISC-V tinderbox
Reviewed by:	kib
MFC after:	3 days
Sponsored by:	Dell EMC
Differential Revision:	https://reviews.freebsd.org/D10933
This commit is contained in:
Eric van Gyzen 2017-05-26 15:51:51 +00:00
parent b79f050a88
commit d25183e0a7

View File

@ -736,7 +736,7 @@ __thr_setcontext(const ucontext_t *ucp)
errno = EINVAL;
return (-1);
}
if (!SIGISMEMBER(uc.uc_sigmask, SIGCANCEL))
if (!SIGISMEMBER(ucp->uc_sigmask, SIGCANCEL))
return __sys_setcontext(ucp);
(void) memcpy(&uc, ucp, sizeof(uc));
SIGDELSET(uc.uc_sigmask, SIGCANCEL);