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