|
|
2460d0 |
From 8a9cce994f0c37c1b4dfc313a1b01fb009c55d01 Mon Sep 17 00:00:00 2001
|
|
|
2460d0 |
From: Julien Thierry <jthierry@redhat.com>
|
|
|
2460d0 |
Date: Thu, 21 Jan 2021 14:41:40 +0100
|
|
|
2460d0 |
Subject: [PATCH] [tty] Fix ->pgrp locking in tiocspgrp()
|
|
|
2460d0 |
|
|
|
2460d0 |
Kernels:
|
|
|
2460d0 |
3.10.0-1160.el7
|
|
|
2460d0 |
3.10.0-1160.2.1.el7
|
|
|
2460d0 |
3.10.0-1160.2.2.el7
|
|
|
2460d0 |
3.10.0-1160.6.1.el7
|
|
|
2460d0 |
3.10.0-1160.11.1.el7
|
|
|
2460d0 |
3.10.0-1160.15.1.el7
|
|
|
2460d0 |
|
|
|
2460d0 |
Changes since last build:
|
|
|
2460d0 |
arches: x86_64 ppc64le
|
|
|
2460d0 |
tty_io.o: changed function: tty_ioctl
|
|
|
2460d0 |
---------------------------
|
|
|
2460d0 |
|
|
|
2460d0 |
Modifications:
|
|
|
2460d0 |
None
|
|
|
2460d0 |
|
|
|
2460d0 |
commit ba0ec80fb32a3ca6e15d51ddcb54c1095f04cf2a
|
|
|
2460d0 |
Author: Chris von Recklinghausen <crecklin@redhat.com>
|
|
|
2460d0 |
Date: Wed Jan 6 19:26:01 2021 -0500
|
|
|
2460d0 |
|
|
|
2460d0 |
[tty] Fix ->pgrp locking in tiocspgrp()
|
|
|
2460d0 |
|
|
|
2460d0 |
Message-id: <20210106192601.11675-1-crecklin@redhat.com>
|
|
|
2460d0 |
Patchwork-id: 10200
|
|
|
2460d0 |
Patchwork-instance: patchwork-private
|
|
|
2460d0 |
O-Subject: [kernel team] [RHEL 7.9.Z bz1908193 CVE-2020-29661 PATCH] tty: Fix ->pgrp locking in tiocspgrp()
|
|
|
2460d0 |
Bugzilla: 1908193
|
|
|
2460d0 |
CVE: CVE-2020-29661
|
|
|
2460d0 |
RH-Acked-by: Oleg Nesterov <oleg@redhat.com>
|
|
|
2460d0 |
RH-Acked-by: Waiman Long <longman@redhat.com>
|
|
|
2460d0 |
|
|
|
2460d0 |
From: Jann Horn <jannh@google.com>
|
|
|
2460d0 |
|
|
|
2460d0 |
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1908193
|
|
|
2460d0 |
Brew: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=34103731
|
|
|
2460d0 |
CVE: CVE-2020-29661
|
|
|
2460d0 |
Upstream Status: linux
|
|
|
2460d0 |
Tested: CKI https://beaker.engineering.redhat.com/jobs/?jobsearch-0.table=Whiteboard&jobsearch-0.operation=contains&jobsearch-0.value=cki%40gitlab%3A620704
|
|
|
2460d0 |
bug has no reproducer
|
|
|
2460d0 |
|
|
|
2460d0 |
Conflicts: tiocspgrp is defined in drivers/tty/tty_io.c in rhel7 so make
|
|
|
2460d0 |
change there.
|
|
|
2460d0 |
drop changes to drivers/tty/tty_jobctrl.c
|
|
|
2460d0 |
|
|
|
2460d0 |
tiocspgrp() takes two tty_struct pointers: One to the tty that userspace
|
|
|
2460d0 |
passed to ioctl() (`tty`) and one to the TTY being changed (`real_tty`).
|
|
|
2460d0 |
These pointers are different when ioctl() is called with a master fd.
|
|
|
2460d0 |
|
|
|
2460d0 |
To properly lock real_tty->pgrp, we must take real_tty->ctrl_lock.
|
|
|
2460d0 |
|
|
|
2460d0 |
This bug makes it possible for racing ioctl(TIOCSPGRP, ...) calls on
|
|
|
2460d0 |
both sides of a PTY pair to corrupt the refcount of `struct pid`,
|
|
|
2460d0 |
leading to use-after-free errors.
|
|
|
2460d0 |
|
|
|
2460d0 |
Fixes: 47f86834bbd4 ("redo locking of tty->pgrp")
|
|
|
2460d0 |
CC: stable@kernel.org
|
|
|
2460d0 |
Signed-off-by: Jann Horn <jannh@google.com>
|
|
|
2460d0 |
Reviewed-by: Jiri Slaby <jirislaby@kernel.org>
|
|
|
2460d0 |
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
|
|
|
2460d0 |
(cherry picked from commit 54ffccbf053b5b6ca4f6e45094b942fab92a25fc)
|
|
|
2460d0 |
|
|
|
2460d0 |
Conflicts:
|
|
|
2460d0 |
drivers/tty/tty_jobctrl.c
|
|
|
2460d0 |
Signed-off-by: Chris von Recklinghausen <crecklin@redhat.com>
|
|
|
2460d0 |
Signed-off-by: Augusto Caringi <acaringi@redhat.com>
|
|
|
2460d0 |
|
|
|
2460d0 |
Signed-off-by: Julien Thierry <jthierry@redhat.com>
|
|
|
2460d0 |
---
|
|
|
2460d0 |
drivers/tty/tty_io.c | 4 ++--
|
|
|
2460d0 |
1 file changed, 2 insertions(+), 2 deletions(-)
|
|
|
2460d0 |
|
|
|
2460d0 |
diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
|
|
|
2460d0 |
index c6e277aae06..713e1ad5c09 100644
|
|
|
2460d0 |
--- a/drivers/tty/tty_io.c
|
|
|
2460d0 |
+++ b/drivers/tty/tty_io.c
|
|
|
2460d0 |
@@ -2542,10 +2542,10 @@ static int tiocspgrp(struct tty_struct *tty, struct tty_struct *real_tty, pid_t
|
|
|
2460d0 |
if (session_of_pgrp(pgrp) != task_session(current))
|
|
|
2460d0 |
goto out_unlock;
|
|
|
2460d0 |
retval = 0;
|
|
|
2460d0 |
- spin_lock_irqsave(&tty->ctrl_lock, flags);
|
|
|
2460d0 |
+ spin_lock_irqsave(&real_tty->ctrl_lock, flags);
|
|
|
2460d0 |
put_pid(real_tty->pgrp);
|
|
|
2460d0 |
real_tty->pgrp = get_pid(pgrp);
|
|
|
2460d0 |
- spin_unlock_irqrestore(&tty->ctrl_lock, flags);
|
|
|
2460d0 |
+ spin_unlock_irqrestore(&real_tty->ctrl_lock, flags);
|
|
|
2460d0 |
out_unlock:
|
|
|
2460d0 |
rcu_read_unlock();
|
|
|
2460d0 |
return retval;
|
|
|
2460d0 |
--
|
|
|
2460d0 |
2.25.4
|
|
|
2460d0 |
|