]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
exec: Rename bprm->cred_prepared to called_set_creds
authorKees Cook <keescook@chromium.org>
Tue, 18 Jul 2017 22:25:23 +0000 (15:25 -0700)
committerKees Cook <keescook@chromium.org>
Tue, 1 Aug 2017 19:02:48 +0000 (12:02 -0700)
The cred_prepared bprm flag has a misleading name. It has nothing to do
with the bprm_prepare_cred hook, and actually tracks if bprm_set_creds has
been called. Rename this flag and improve its comment.

Cc: David Howells <dhowells@redhat.com>
Cc: Stephen Smalley <sds@tycho.nsa.gov>
Cc: Casey Schaufler <casey@schaufler-ca.com>
Signed-off-by: Kees Cook <keescook@chromium.org>
Acked-by: John Johansen <john.johansen@canonical.com>
Acked-by: James Morris <james.l.morris@oracle.com>
Acked-by: Paul Moore <paul@paul-moore.com>
Acked-by: Serge Hallyn <serge@hallyn.com>
fs/binfmt_flat.c
fs/exec.c
include/linux/binfmts.h
security/apparmor/domain.c
security/selinux/hooks.c
security/smack/smack_lsm.c
security/tomoyo/tomoyo.c

index a1e6860b6f46a091e28855eb5b6ed48c937aebac..604a176df0c2a4f1b9b7ee9a465b3a36a47b3c26 100644 (file)
@@ -890,7 +890,7 @@ static int load_flat_shared_library(int id, struct lib_info *libs)
         * as we're past the point of no return and are dealing with shared
         * libraries.
         */
-       bprm.cred_prepared = 1;
+       bprm.called_set_creds = 1;
 
        res = prepare_binprm(&bprm);
 
index 62175cbcc80171df25da8e8bdd07547c83515b06..a0fff86269e415336defae5a535e27957208d9d3 100644 (file)
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -1548,7 +1548,7 @@ int prepare_binprm(struct linux_binprm *bprm)
        retval = security_bprm_set_creds(bprm);
        if (retval)
                return retval;
-       bprm->cred_prepared = 1;
+       bprm->called_set_creds = 1;
 
        memset(bprm->buf, 0, BINPRM_BUF_SIZE);
        return kernel_read(bprm->file, 0, bprm->buf, BINPRM_BUF_SIZE);
index 3ae9013eeaaa4367bb160aef88b36ab549b0446d..9023e1d2d5cd9c9e4a44f0836c927e8751ef09c0 100644 (file)
@@ -25,8 +25,12 @@ struct linux_binprm {
        struct mm_struct *mm;
        unsigned long p; /* current top of mem */
        unsigned int
-               cred_prepared:1,/* true if creds already prepared (multiple
-                                * preps happen for interpreters) */
+               /*
+                * True after the bprm_set_creds hook has been called once
+                * (multiple calls can be made via prepare_binprm() for
+                * binfmt_script/misc).
+                */
+               called_set_creds:1,
                cap_effective:1;/* true if has elevated effective capabilities,
                                 * false if not; except for init which inherits
                                 * its parent's caps anyway */
index d0594446ae3ffffc85c3963c0f3ca5a43fe33b38..67ec52cfc52385f9586930333ed6a6db1738a776 100644 (file)
@@ -758,7 +758,7 @@ int apparmor_bprm_set_creds(struct linux_binprm *bprm)
                file_inode(bprm->file)->i_mode
        };
 
-       if (bprm->cred_prepared)
+       if (bprm->called_set_creds)
                return 0;
 
        ctx = cred_ctx(bprm->cred);
index 33fd061305c40376c7f632ebcdf6fe5fd7b1e3fc..1db40195d178e450fa008e64745c950e99980e1c 100644 (file)
@@ -2356,7 +2356,7 @@ static int selinux_bprm_set_creds(struct linux_binprm *bprm)
 
        /* SELinux context only depends on initial program or script and not
         * the script interpreter */
-       if (bprm->cred_prepared)
+       if (bprm->called_set_creds)
                return 0;
 
        old_tsec = current_security();
index 463af86812c7ac295e5d5c02b3c20a79c5f8242a..db8e16ec223bdc285b84eb3e2206734487b225dc 100644 (file)
@@ -917,7 +917,7 @@ static int smack_bprm_set_creds(struct linux_binprm *bprm)
        struct superblock_smack *sbsp;
        int rc;
 
-       if (bprm->cred_prepared)
+       if (bprm->called_set_creds)
                return 0;
 
        isp = inode->i_security;
index 130b4fa4f65fde0771952399a8bc4e2db60b790c..d25b705360e068c73922a0d1ca671efe72925636 100644 (file)
@@ -76,7 +76,7 @@ static int tomoyo_bprm_set_creds(struct linux_binprm *bprm)
         * Do only if this function is called for the first time of an execve
         * operation.
         */
-       if (bprm->cred_prepared)
+       if (bprm->called_set_creds)
                return 0;
 #ifndef CONFIG_SECURITY_TOMOYO_OMIT_USERSPACE_LOADER
        /*