Skip to content

Commit 9227dd2

Browse files
committed
exec: Remove LSM_UNSAFE_PTRACE_CAP
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]>
1 parent 2052313 commit 9227dd2

File tree

6 files changed

+7
-13
lines changed

6 files changed

+7
-13
lines changed

fs/exec.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1426,12 +1426,8 @@ static void check_unsafe_exec(struct linux_binprm *bprm)
14261426
struct task_struct *p = current, *t;
14271427
unsigned n_fs;
14281428

1429-
if (p->ptrace) {
1430-
if (ptracer_capable(p, current_user_ns()))
1431-
bprm->unsafe |= LSM_UNSAFE_PTRACE_CAP;
1432-
else
1433-
bprm->unsafe |= LSM_UNSAFE_PTRACE;
1434-
}
1429+
if (p->ptrace)
1430+
bprm->unsafe |= LSM_UNSAFE_PTRACE;
14351431

14361432
/*
14371433
* This isn't strictly necessary, but it makes it harder for LSMs to

include/linux/security.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,7 @@ struct request_sock;
140140
/* bprm->unsafe reasons */
141141
#define LSM_UNSAFE_SHARE 1
142142
#define LSM_UNSAFE_PTRACE 2
143-
#define LSM_UNSAFE_PTRACE_CAP 4
144-
#define LSM_UNSAFE_NO_NEW_PRIVS 8
143+
#define LSM_UNSAFE_NO_NEW_PRIVS 4
145144

146145
#ifdef CONFIG_MMU
147146
extern int mmap_min_addr_handler(struct ctl_table *table, int write,

security/apparmor/domain.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ int apparmor_bprm_set_creds(struct linux_binprm *bprm)
469469
;
470470
}
471471

472-
if (bprm->unsafe & (LSM_UNSAFE_PTRACE | LSM_UNSAFE_PTRACE_CAP)) {
472+
if (bprm->unsafe & LSM_UNSAFE_PTRACE) {
473473
error = may_change_ptraced_domain(new_profile);
474474
if (error)
475475
goto audit;

security/commoncap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ int cap_bprm_set_creds(struct linux_binprm *bprm)
548548

549549
if ((is_setid ||
550550
!cap_issubset(new->cap_permitted, old->cap_permitted)) &&
551-
((bprm->unsafe & ~(LSM_UNSAFE_PTRACE | LSM_UNSAFE_PTRACE_CAP)) ||
551+
((bprm->unsafe & ~LSM_UNSAFE_PTRACE) ||
552552
!ptracer_capable(current, new->user_ns))) {
553553
/* downgrade; they get no more than they had, and maybe less */
554554
if (!ns_capable(new->user_ns, CAP_SETUID) ||

security/selinux/hooks.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2404,8 +2404,7 @@ static int selinux_bprm_set_creds(struct linux_binprm *bprm)
24042404

24052405
/* Make sure that anyone attempting to ptrace over a task that
24062406
* changes its SID has the appropriate permit */
2407-
if (bprm->unsafe &
2408-
(LSM_UNSAFE_PTRACE | LSM_UNSAFE_PTRACE_CAP)) {
2407+
if (bprm->unsafe & LSM_UNSAFE_PTRACE) {
24092408
u32 ptsid = ptrace_parent_sid(current);
24102409
if (ptsid != 0) {
24112410
rc = avc_has_perm(ptsid, new_tsec->sid,

security/smack/smack_lsm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -934,7 +934,7 @@ static int smack_bprm_set_creds(struct linux_binprm *bprm)
934934
isp->smk_task != sbsp->smk_root)
935935
return 0;
936936

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

0 commit comments

Comments
 (0)