Skip to content

Commit

Permalink
exec: Remove LSM_UNSAFE_PTRACE_CAP
Browse files Browse the repository at this point in the history
With previous changes every location that tests for
LSM_UNSAFE_PTRACE_CAP also tests for LSM_UNSAFE_PTRACE making the
LSM_UNSAFE_PTRACE_CAP redundant, so remove it.

Signed-off-by: "Eric W. Biederman" <[email protected]>
  • Loading branch information
ebiederm committed Jan 23, 2017
1 parent 2052313 commit 9227dd2
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 13 deletions.
8 changes: 2 additions & 6 deletions fs/exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -1426,12 +1426,8 @@ static void check_unsafe_exec(struct linux_binprm *bprm)
struct task_struct *p = current, *t;
unsigned n_fs;

if (p->ptrace) {
if (ptracer_capable(p, current_user_ns()))
bprm->unsafe |= LSM_UNSAFE_PTRACE_CAP;
else
bprm->unsafe |= LSM_UNSAFE_PTRACE;
}
if (p->ptrace)
bprm->unsafe |= LSM_UNSAFE_PTRACE;

/*
* This isn't strictly necessary, but it makes it harder for LSMs to
Expand Down
3 changes: 1 addition & 2 deletions include/linux/security.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,7 @@ struct request_sock;
/* bprm->unsafe reasons */
#define LSM_UNSAFE_SHARE 1
#define LSM_UNSAFE_PTRACE 2
#define LSM_UNSAFE_PTRACE_CAP 4
#define LSM_UNSAFE_NO_NEW_PRIVS 8
#define LSM_UNSAFE_NO_NEW_PRIVS 4

#ifdef CONFIG_MMU
extern int mmap_min_addr_handler(struct ctl_table *table, int write,
Expand Down
2 changes: 1 addition & 1 deletion security/apparmor/domain.c
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ int apparmor_bprm_set_creds(struct linux_binprm *bprm)
;
}

if (bprm->unsafe & (LSM_UNSAFE_PTRACE | LSM_UNSAFE_PTRACE_CAP)) {
if (bprm->unsafe & LSM_UNSAFE_PTRACE) {
error = may_change_ptraced_domain(new_profile);
if (error)
goto audit;
Expand Down
2 changes: 1 addition & 1 deletion security/commoncap.c
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ int cap_bprm_set_creds(struct linux_binprm *bprm)

if ((is_setid ||
!cap_issubset(new->cap_permitted, old->cap_permitted)) &&
((bprm->unsafe & ~(LSM_UNSAFE_PTRACE | LSM_UNSAFE_PTRACE_CAP)) ||
((bprm->unsafe & ~LSM_UNSAFE_PTRACE) ||
!ptracer_capable(current, new->user_ns))) {
/* downgrade; they get no more than they had, and maybe less */
if (!ns_capable(new->user_ns, CAP_SETUID) ||
Expand Down
3 changes: 1 addition & 2 deletions security/selinux/hooks.c
Original file line number Diff line number Diff line change
Expand Up @@ -2404,8 +2404,7 @@ static int selinux_bprm_set_creds(struct linux_binprm *bprm)

/* Make sure that anyone attempting to ptrace over a task that
* changes its SID has the appropriate permit */
if (bprm->unsafe &
(LSM_UNSAFE_PTRACE | LSM_UNSAFE_PTRACE_CAP)) {
if (bprm->unsafe & LSM_UNSAFE_PTRACE) {
u32 ptsid = ptrace_parent_sid(current);
if (ptsid != 0) {
rc = avc_has_perm(ptsid, new_tsec->sid,
Expand Down
2 changes: 1 addition & 1 deletion security/smack/smack_lsm.c
Original file line number Diff line number Diff line change
Expand Up @@ -934,7 +934,7 @@ static int smack_bprm_set_creds(struct linux_binprm *bprm)
isp->smk_task != sbsp->smk_root)
return 0;

if (bprm->unsafe & (LSM_UNSAFE_PTRACE | LSM_UNSAFE_PTRACE_CAP)) {
if (bprm->unsafe & LSM_UNSAFE_PTRACE) {
struct task_struct *tracer;
rc = 0;

Expand Down

0 comments on commit 9227dd2

Please sign in to comment.