aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2016-11-14 19:48:07 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-01-06 04:40:13 -0500
commite747b4ae3b6bca205d82e86366e140cdcbfb7731 (patch)
treeeb37a1d3d431363778fde364f726e49571ba8ec6 /fs
parent48466c4772d2cfeb331395043f7edd8c5324ef1b (diff)
ptrace: Capture the ptracer's creds not PT_PTRACE_CAP
commit 64b875f7ac8a5d60a4e191479299e931ee949b67 upstream. When the flag PT_PTRACE_CAP was added the PTRACE_TRACEME path was overlooked. This can result in incorrect behavior when an application like strace traces an exec of a setuid executable. Further PT_PTRACE_CAP does not have enough information for making good security decisions as it does not report which user namespace the capability is in. This has already allowed one mistake through insufficient granulariy. I found this issue when I was testing another corner case of exec and discovered that I could not get strace to set PT_PTRACE_CAP even when running strace as root with a full set of caps. This change fixes the above issue with strace allowing stracing as root a setuid executable without disabling setuid. More fundamentaly this change allows what is allowable at all times, by using the correct information in it's decision. Fixes: 4214e42f96d4 ("v2.4.9.11 -> v2.4.9.12") Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/exec.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/fs/exec.c b/fs/exec.c
index a9dec2f540dc..67e86571685a 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -1425,7 +1425,7 @@ static void check_unsafe_exec(struct linux_binprm *bprm)
1425 unsigned n_fs; 1425 unsigned n_fs;
1426 1426
1427 if (p->ptrace) { 1427 if (p->ptrace) {
1428 if (p->ptrace & PT_PTRACE_CAP) 1428 if (ptracer_capable(p, current_user_ns()))
1429 bprm->unsafe |= LSM_UNSAFE_PTRACE_CAP; 1429 bprm->unsafe |= LSM_UNSAFE_PTRACE_CAP;
1430 else 1430 else
1431 bprm->unsafe |= LSM_UNSAFE_PTRACE; 1431 bprm->unsafe |= LSM_UNSAFE_PTRACE;