[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20230901015030.2469062-2-earl.chew@yahoo.ca>
Date: Thu, 31 Aug 2023 18:50:29 -0700
From: Earl Chew <earl.chew@...oo.ca>
To: linux-kernel@...r.kernel.org, gregkh@...uxfoundation.org,
jirislaby@...nel.org
Cc: peter@...leysoftware.com, earl.chew@...oo.ca
Subject: [PATCH 1/3] tty: Fix __tty_check_change() and tiocspgrp() race
Restore the use of tty->ctrl.lock to cover both checking
current->task_pgrp() and sending kill_pgrp(). This coverage
was lost for SIGTTIN as part of commit 2812d9e9fd94
(tty: Combine SIGTTOU/SIGTTIN handling). In rare cases,
job control shells using tcsetpgrp() and SIGCONT to move
a background job to the foreground could find the new
foreground job stopping almost immediately due to SIGTTIN
or SIGTTOU.
Signed-off-by: Earl Chew <earl.chew@...oo.ca>
---
drivers/tty/tty_jobctrl.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/tty/tty_jobctrl.c b/drivers/tty/tty_jobctrl.c
index 0d04287da..aba721a3c 100644
--- a/drivers/tty/tty_jobctrl.c
+++ b/drivers/tty/tty_jobctrl.c
@@ -44,7 +44,6 @@ int __tty_check_change(struct tty_struct *tty, int sig)
spin_lock_irqsave(&tty->ctrl.lock, flags);
tty_pgrp = tty->ctrl.pgrp;
- spin_unlock_irqrestore(&tty->ctrl.lock, flags);
if (tty_pgrp && pgrp != tty_pgrp) {
if (is_ignored(sig)) {
@@ -58,6 +57,7 @@ int __tty_check_change(struct tty_struct *tty, int sig)
ret = -ERESTARTSYS;
}
}
+ spin_unlock_irqrestore(&tty->ctrl.lock, flags);
rcu_read_unlock();
if (!tty_pgrp)
--
2.39.1
Powered by blists - more mailing lists