Check for process group change in tty_wait_background().
The calling process's process group can change between PROC_UNLOCK(p) and PGRP_LOCK(pg) in tty_wait_background(), e.g. by a setpgid() call from another process. If that happens, the signal is not sent to the calling process, even if the prior checks determine that one should be sent. Re-check that the process group hasn't changed after acquiring the pgrp lock, and if it has, redo the checks. PR: 250701 Submitted by: Jakub Piecuch <j.piecuch96@gmail.com> MFC after: 2 weeks
This commit is contained in:
parent
1ef64e3da5
commit
3cbf9dc81c
@ -474,6 +474,19 @@ tty_wait_background(struct tty *tp, struct thread *td, int sig)
|
||||
sig = 0;
|
||||
}
|
||||
PGRP_LOCK(pg);
|
||||
|
||||
/*
|
||||
* pg may no longer be our process group.
|
||||
* Re-check after locking process group.
|
||||
*/
|
||||
PROC_LOCK(p);
|
||||
if (p->p_pgrp != pg) {
|
||||
PROC_UNLOCK(p);
|
||||
PGRP_UNLOCK(pg);
|
||||
continue;
|
||||
}
|
||||
|
||||
PROC_UNLOCK(p);
|
||||
pgsignal(pg, ksi.ksi_signo, 1, &ksi);
|
||||
PGRP_UNLOCK(pg);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user