]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.4.172/yama-check-for-pid-death-before-checking-ancestry.patch
4.14-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.4.172 / yama-check-for-pid-death-before-checking-ancestry.patch
CommitLineData
742fedfb
GKH
1From 9474f4e7cd71a633fa1ef93b7daefd44bbdfd482 Mon Sep 17 00:00:00 2001
2From: Kees Cook <keescook@chromium.org>
3Date: Wed, 16 Jan 2019 10:31:09 -0800
4Subject: Yama: Check for pid death before checking ancestry
5
6From: Kees Cook <keescook@chromium.org>
7
8commit 9474f4e7cd71a633fa1ef93b7daefd44bbdfd482 upstream.
9
10It's possible that a pid has died before we take the rcu lock, in which
11case we can't walk the ancestry list as it may be detached. Instead, check
12for death first before doing the walk.
13
14Reported-by: syzbot+a9ac39bf55329e206219@syzkaller.appspotmail.com
15Fixes: 2d514487faf1 ("security: Yama LSM")
16Cc: stable@vger.kernel.org
17Suggested-by: Oleg Nesterov <oleg@redhat.com>
18Signed-off-by: Kees Cook <keescook@chromium.org>
19Signed-off-by: James Morris <james.morris@microsoft.com>
20Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
21
22---
23 security/yama/yama_lsm.c | 4 +++-
24 1 file changed, 3 insertions(+), 1 deletion(-)
25
26--- a/security/yama/yama_lsm.c
27+++ b/security/yama/yama_lsm.c
28@@ -288,7 +288,9 @@ static int yama_ptrace_access_check(stru
29 break;
30 case YAMA_SCOPE_RELATIONAL:
31 rcu_read_lock();
32- if (!task_is_descendant(current, child) &&
33+ if (!pid_alive(child))
34+ rc = -EPERM;
35+ if (!rc && !task_is_descendant(current, child) &&
36 !ptracer_exception_found(current, child) &&
37 !ns_capable(__task_cred(child)->user_ns, CAP_SYS_PTRACE))
38 rc = -EPERM;