From aefecdbf5d2c3b767f3ab1993d4dbb554345d80a Mon Sep 17 00:00:00 2001 From: "Eric W. Biederman" Date: Mon, 21 Nov 2011 16:40:54 -0800 Subject: [PATCH] --- yaml --- r: 346321 b: refs/heads/master c: 3cdf5b45ffbac294bcdfac0393df72f7687c01e8 h: refs/heads/master i: 346319: fb16227a04f7fc294941b346fc602e7adaa51431 v: v3 --- [refs] | 2 +- trunk/fs/exec.c | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/[refs] b/[refs] index c3b87acfe134..0490a510f2c8 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: ae11e0f18482bfe0cd83b9b61434ea7e0bd94e25 +refs/heads/master: 3cdf5b45ffbac294bcdfac0393df72f7687c01e8 diff --git a/trunk/fs/exec.c b/trunk/fs/exec.c index 0039055b1fc6..aef0c2f19750 100644 --- a/trunk/fs/exec.c +++ b/trunk/fs/exec.c @@ -1266,14 +1266,13 @@ int prepare_binprm(struct linux_binprm *bprm) bprm->cred->egid = current_egid(); if (!(bprm->file->f_path.mnt->mnt_flags & MNT_NOSUID) && - !current->no_new_privs) { + !current->no_new_privs && + kuid_has_mapping(bprm->cred->user_ns, inode->i_uid) && + kgid_has_mapping(bprm->cred->user_ns, inode->i_gid)) { /* Set-uid? */ if (mode & S_ISUID) { - if (!kuid_has_mapping(bprm->cred->user_ns, inode->i_uid)) - return -EPERM; bprm->per_clear |= PER_CLEAR_ON_SETID; bprm->cred->euid = inode->i_uid; - } /* Set-gid? */ @@ -1283,8 +1282,6 @@ int prepare_binprm(struct linux_binprm *bprm) * executable. */ if ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP)) { - if (!kgid_has_mapping(bprm->cred->user_ns, inode->i_gid)) - return -EPERM; bprm->per_clear |= PER_CLEAR_ON_SETID; bprm->cred->egid = inode->i_gid; }