Skip to content

Commit

Permalink
exec: Rename bprm->cred_prepared to called_set_creds
Browse files Browse the repository at this point in the history
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 <[email protected]>
Cc: Stephen Smalley <[email protected]>
Cc: Casey Schaufler <[email protected]>
Signed-off-by: Kees Cook <[email protected]>
Acked-by: John Johansen <[email protected]>
Acked-by: James Morris <[email protected]>
Acked-by: Paul Moore <[email protected]>
Acked-by: Serge Hallyn <[email protected]>
  • Loading branch information
kees committed Aug 1, 2017
1 parent 520eccd commit ddb4a14
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion fs/binfmt_flat.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion fs/exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 6 additions & 2 deletions include/linux/binfmts.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
2 changes: 1 addition & 1 deletion security/apparmor/domain.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion security/selinux/hooks.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
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 @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion security/tomoyo/tomoyo.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
/*
Expand Down

0 comments on commit ddb4a14

Please sign in to comment.