Author: kib Date: Wed Oct 28 22:12:47 2020 New Revision: 367120 URL: https://svnweb.freebsd.org/changeset/base/367120
Log: 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.piecuc...@gmail.com> MFC after: 2 weeks Modified: head/sys/kern/tty.c Modified: head/sys/kern/tty.c ============================================================================== --- head/sys/kern/tty.c Wed Oct 28 21:18:04 2020 (r367119) +++ head/sys/kern/tty.c Wed Oct 28 22:12:47 2020 (r367120) @@ -474,6 +474,19 @@ tty_wait_background(struct tty *tp, struct thread *td, 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); _______________________________________________ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"