diff options
author | Max Krummenacher <max.krummenacher@toradex.com> | 2024-02-22 14:52:17 +0100 |
---|---|---|
committer | Max Krummenacher <max.krummenacher@toradex.com> | 2024-02-22 14:52:28 +0100 |
commit | 2c6a140e97ce3bb3cc5c5d637bf1e7dba95b0936 (patch) | |
tree | 50c8f3b36f6aa35e0383df45c2edea477a3f375e /drivers/tty | |
parent | 618b00d8d20a4793984f802454c74af8593e898a (diff) | |
parent | 2a910f4af54d11deaefdc445f895724371645a97 (diff) |
Merge tag 'v5.15.139' into fslc-5.15-2.2.x-imx
This is the 5.15.139 stable release
Signed-off-by: Max Krummenacher <max.krummenacher@toradex.com>
Conflicts:
drivers/clk/imx/clk-imx8mq.c
Diffstat (limited to 'drivers/tty')
-rw-r--r-- | drivers/tty/tty_jobctrl.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/drivers/tty/tty_jobctrl.c b/drivers/tty/tty_jobctrl.c index 80b86a7992b5..8ede78488c5b 100644 --- a/drivers/tty/tty_jobctrl.c +++ b/drivers/tty/tty_jobctrl.c @@ -300,12 +300,7 @@ void disassociate_ctty(int on_exit) return; } - spin_lock_irq(¤t->sighand->siglock); - put_pid(current->signal->tty_old_pgrp); - current->signal->tty_old_pgrp = NULL; - tty = tty_kref_get(current->signal->tty); - spin_unlock_irq(¤t->sighand->siglock); - + tty = get_current_tty(); if (tty) { unsigned long flags; @@ -320,6 +315,16 @@ void disassociate_ctty(int on_exit) tty_kref_put(tty); } + /* If tty->ctrl.pgrp is not NULL, it may be assigned to + * current->signal->tty_old_pgrp in a race condition, and + * cause pid memleak. Release current->signal->tty_old_pgrp + * after tty->ctrl.pgrp set to NULL. + */ + spin_lock_irq(¤t->sighand->siglock); + put_pid(current->signal->tty_old_pgrp); + current->signal->tty_old_pgrp = NULL; + spin_unlock_irq(¤t->sighand->siglock); + /* Now clear signal->tty under the lock */ read_lock(&tasklist_lock); session_clear_tty(task_session(current)); |