mirror of
https://github.com/opnsense/src.git
synced 2026-05-28 04:12:45 -04:00
EDOOFUS
Prevent one thread from messing up another thread's saved signal mask by saving it in struct pthread instead of leaving it as a global variable. D'oh! Approved by: re/blanket libthr
This commit is contained in:
parent
7d9d7ca2ed
commit
b32a99e5f4
2 changed files with 3 additions and 10 deletions
|
|
@ -73,8 +73,7 @@ _thread_critical_enter(pthread_t pthread)
|
|||
errno);
|
||||
abort();
|
||||
}
|
||||
|
||||
restore = sav;
|
||||
curthread->savedsig = sav;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -82,17 +81,10 @@ _thread_critical_exit(pthread_t pthread)
|
|||
{
|
||||
sigset_t set;
|
||||
|
||||
/*
|
||||
* restore is protected by giant. We could restore our signal state
|
||||
* incorrectly if someone else set restore between unlocking giant
|
||||
* and restoring the signal mask. To avoid this we cache a copy prior
|
||||
* to the unlock.
|
||||
*/
|
||||
set = restore;
|
||||
|
||||
/*
|
||||
* Restore signals.
|
||||
*/
|
||||
set = curthread->savedsig;
|
||||
if (__sys_sigprocmask(SIG_SETMASK, &set, NULL)) {
|
||||
_thread_printf(STDERR_FILENO, "Critical Exit: sig err %d\n",
|
||||
errno);
|
||||
|
|
|
|||
|
|
@ -425,6 +425,7 @@ struct pthread {
|
|||
char *name;
|
||||
u_int64_t uniqueid; /* for gdb */
|
||||
thr_id_t thr_id;
|
||||
sigset_t savedsig;
|
||||
|
||||
/*
|
||||
* Lock for accesses to this thread structure.
|
||||
|
|
|
|||
Loading…
Reference in a new issue