From: Chris Wright Date: Sat, 25 Mar 2006 11:07:41 +0000 (-0800) Subject: [PATCH] make cap_ptrace enforce PTRACE_TRACME checks X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=d4eb82c783992551c574580eb55fddc8bb006ad0;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git [PATCH] make cap_ptrace enforce PTRACE_TRACME checks PTRACE_TRACEME doesn't have proper capabilities validation when parent is less privileged than child. Issue pointed out by Ram Gupta . Note: I haven't identified a strong security issue, and it's a small ABI change that could break apps that rely on existing behaviour (which allows parent that is less privileged than child to ptrace when child does PTRACE_TRACEME). Signed-off-by: Chris Wright Cc: Ram Gupta Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/security/commoncap.c b/security/commoncap.c index 8a6e097f99ea..841eb4e5c62b 100644 --- a/security/commoncap.c +++ b/security/commoncap.c @@ -60,8 +60,8 @@ int cap_settime(struct timespec *ts, struct timezone *tz) int cap_ptrace (struct task_struct *parent, struct task_struct *child) { /* Derived from arch/i386/kernel/ptrace.c:sys_ptrace. */ - if (!cap_issubset (child->cap_permitted, current->cap_permitted) && - !capable(CAP_SYS_PTRACE)) + if (!cap_issubset(child->cap_permitted, parent->cap_permitted) && + !__capable(parent, CAP_SYS_PTRACE)) return -EPERM; return 0; }