diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2016-11-15 01:48:07 +0100 |
---|---|---|
committer | Eric W. Biederman <ebiederm@xmission.com> | 2016-11-22 18:49:49 +0100 |
commit | 64b875f7ac8a5d60a4e191479299e931ee949b67 (patch) | |
tree | 0c913f705ae947f5903ca0ff91ed633d1c2adc4a /fs/exec.c | |
parent | mm: Add a user_ns owner to mm_struct and fix ptrace permission checks (diff) | |
download | linux-64b875f7ac8a5d60a4e191479299e931ee949b67.tar.xz linux-64b875f7ac8a5d60a4e191479299e931ee949b67.zip |
ptrace: Capture the ptracer's creds not PT_PTRACE_CAP
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.
Cc: stable@vger.kernel.org
Fixes: 4214e42f96d4 ("v2.4.9.11 -> v2.4.9.12")
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Diffstat (limited to 'fs/exec.c')
-rw-r--r-- | fs/exec.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/fs/exec.c b/fs/exec.c index 4e497b9ee71e..3cf2cfced97a 100644 --- a/fs/exec.c +++ b/fs/exec.c @@ -1406,7 +1406,7 @@ static void check_unsafe_exec(struct linux_binprm *bprm) unsigned n_fs; if (p->ptrace) { - if (p->ptrace & PT_PTRACE_CAP) + if (ptracer_capable(p, current_user_ns())) bprm->unsafe |= LSM_UNSAFE_PTRACE_CAP; else bprm->unsafe |= LSM_UNSAFE_PTRACE; |