When queuing ignored signal, only abort target thread' sleep if it is inside sigwait()

Reported and tested by:	trasz
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D32252
This commit is contained in:
Konstantin Belousov 2021-10-03 05:03:59 +03:00
parent f17eb93d55
commit 9b86d3e5de
2 changed files with 16 additions and 3 deletions

View File

@ -2156,6 +2156,18 @@ tdksignal(struct thread *td, int sig, ksiginfo_t *ksi)
(void) tdsendsignal(td->td_proc, td, sig, ksi);
}
static int
sig_sleepq_abort(struct thread *td, int intrval)
{
THREAD_LOCK_ASSERT(td, MA_OWNED);
if (intrval == 0 && (td->td_flags & TDF_SIGWAIT) == 0) {
thread_unlock(td);
return (0);
}
return (sleepq_abort(td, intrval));
}
int
tdsendsignal(struct proc *p, struct thread *td, int sig, ksiginfo_t *ksi)
{
@ -2374,7 +2386,7 @@ tdsendsignal(struct proc *p, struct thread *td, int sig, ksiginfo_t *ksi)
PROC_SLOCK(p);
thread_lock(td);
if (TD_CAN_ABORT(td))
wakeup_swapper = sleepq_abort(td, intrval);
wakeup_swapper = sig_sleepq_abort(td, intrval);
else
thread_unlock(td);
PROC_SUNLOCK(p);
@ -2505,7 +2517,7 @@ tdsigwakeup(struct thread *td, int sig, sig_t action, int intrval)
if (td->td_priority > PUSER && !TD_IS_IDLETHREAD(td))
sched_prio(td, PUSER);
wakeup_swapper = sleepq_abort(td, intrval);
wakeup_swapper = sig_sleepq_abort(td, intrval);
PROC_SUNLOCK(p);
if (wakeup_swapper)
kick_proc0();

View File

@ -1126,7 +1126,8 @@ sleepq_abort(struct thread *td, int intrval)
THREAD_LOCK_ASSERT(td, MA_OWNED);
MPASS(TD_ON_SLEEPQ(td));
MPASS(td->td_flags & TDF_SINTR);
MPASS(intrval == 0 || intrval == EINTR || intrval == ERESTART);
MPASS((intrval == 0 && (td->td_flags & TDF_SIGWAIT) != 0) ||
intrval == EINTR || intrval == ERESTART);
/*
* If the TDF_TIMEOUT flag is set, just leave. A