lkml.org 
[lkml]   [2020]   [May]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Date
Subject[PATCH 08/11] exec: In bprm_fill_uid remove unnecessary no new privs check

When the no new privs code was added[1], a test was added to
cap_bprm_set_creds to ensure that the credential change were always
reverted if no new privs was set.

That test has been refactored into a test to not make the credential
change in bprm_fill_uid when no new privs is set. Remove that
unncessary test as it can now been seen by a quick inspection that
execution can never make it to the test with no new privs set.

The same change[1] also added a test that guaranteed the credentials
would never change when no_new_privs was set, so the test I am removing
was never necessary but historically that was far from obvious.

[1]: 259e5e6c75a9 ("Add PR_{GET,SET}_NO_NEW_PRIVS to prevent execve from granting privs")
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
---
fs/exec.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/fs/exec.c b/fs/exec.c
index 8dd7254931dc..af108ecf9632 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -1636,16 +1636,12 @@ static void bprm_fill_uid(struct linux_binprm *bprm)

if (mode & S_ISUID) {
bprm->per_clear = 1;
- if (!need_cap ||
- (ns_capable(new->user_ns, CAP_SETUID) &&
- !(bprm->unsafe & LSM_UNSAFE_NO_NEW_PRIVS)))
+ if (!need_cap || ns_capable(new->user_ns, CAP_SETUID))
new->suid = new->fsuid = new->euid = uid;
}
if ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP)) {
bprm->per_clear = 1;
- if (!need_cap ||
- (ns_capable(new->user_ns, CAP_SETGID) &&
- !(bprm->unsafe & LSM_UNSAFE_NO_NEW_PRIVS)))
+ if (!need_cap || ns_capable(new->user_ns, CAP_SETGID))
new->sgid = new->fsgid = new->egid = gid;
}

--
2.25.0
\
 
 \ /
  Last update: 2020-05-28 17:53    [W:0.595 / U:0.640 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site