Date: Wed, 28 Oct 2020 22:12:47 +0000 (UTC) From: Konstantin Belousov <kib@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367120 - head/sys/kern Message-ID: <202010282212.09SMClWb080204@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
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.piecuch96@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);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202010282212.09SMClWb080204>