Skip to content

Commit 64fc952

Browse files
KhadijaKamranpcmoore
authored andcommitted
lsm: constify 'bprm' parameter in security_bprm_committing_creds()
The 'bprm_committing_creds' hook has implementations registered in SELinux and Apparmor. Looking at the function implementations we observe that the 'bprm' parameter is not changing. Mark the 'bprm' parameter of LSM hook security_bprm_committing_creds() as 'const' since it will not be changing in the LSM hook. Signed-off-by: Khadija Kamran <kamrankhadijadj@gmail.com> Signed-off-by: Paul Moore <paul@paul-moore.com>
1 parent 4a00c67 commit 64fc952

5 files changed

Lines changed: 6 additions & 6 deletions

File tree

include/linux/lsm_hook_defs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ LSM_HOOK(int, 0, vm_enough_memory, struct mm_struct *mm, long pages)
5252
LSM_HOOK(int, 0, bprm_creds_for_exec, struct linux_binprm *bprm)
5353
LSM_HOOK(int, 0, bprm_creds_from_file, struct linux_binprm *bprm, const struct file *file)
5454
LSM_HOOK(int, 0, bprm_check_security, struct linux_binprm *bprm)
55-
LSM_HOOK(void, LSM_RET_VOID, bprm_committing_creds, struct linux_binprm *bprm)
55+
LSM_HOOK(void, LSM_RET_VOID, bprm_committing_creds, const struct linux_binprm *bprm)
5656
LSM_HOOK(void, LSM_RET_VOID, bprm_committed_creds, struct linux_binprm *bprm)
5757
LSM_HOOK(int, 0, fs_context_submount, struct fs_context *fc, struct super_block *reference)
5858
LSM_HOOK(int, 0, fs_context_dup, struct fs_context *fc,

include/linux/security.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ int security_vm_enough_memory_mm(struct mm_struct *mm, long pages);
292292
int security_bprm_creds_for_exec(struct linux_binprm *bprm);
293293
int security_bprm_creds_from_file(struct linux_binprm *bprm, const struct file *file);
294294
int security_bprm_check(struct linux_binprm *bprm);
295-
void security_bprm_committing_creds(struct linux_binprm *bprm);
295+
void security_bprm_committing_creds(const struct linux_binprm *bprm);
296296
void security_bprm_committed_creds(struct linux_binprm *bprm);
297297
int security_fs_context_submount(struct fs_context *fc, struct super_block *reference);
298298
int security_fs_context_dup(struct fs_context *fc, struct fs_context *src_fc);
@@ -623,7 +623,7 @@ static inline int security_bprm_check(struct linux_binprm *bprm)
623623
return 0;
624624
}
625625

626-
static inline void security_bprm_committing_creds(struct linux_binprm *bprm)
626+
static inline void security_bprm_committing_creds(const struct linux_binprm *bprm)
627627
{
628628
}
629629

security/apparmor/lsm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -734,7 +734,7 @@ static int apparmor_setprocattr(const char *name, void *value,
734734
* apparmor_bprm_committing_creds - do task cleanup on committing new creds
735735
* @bprm: binprm for the exec (NOT NULL)
736736
*/
737-
static void apparmor_bprm_committing_creds(struct linux_binprm *bprm)
737+
static void apparmor_bprm_committing_creds(const struct linux_binprm *bprm)
738738
{
739739
struct aa_label *label = aa_current_raw_label();
740740
struct aa_label *new_label = cred_label(bprm->cred);

security/security.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1118,7 +1118,7 @@ int security_bprm_check(struct linux_binprm *bprm)
11181118
* open file descriptors to which access will no longer be granted when the
11191119
* attributes are changed. This is called immediately before commit_creds().
11201120
*/
1121-
void security_bprm_committing_creds(struct linux_binprm *bprm)
1121+
void security_bprm_committing_creds(const struct linux_binprm *bprm)
11221122
{
11231123
call_void_hook(bprm_committing_creds, bprm);
11241124
}

security/selinux/hooks.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2455,7 +2455,7 @@ static inline void flush_unauthorized_files(const struct cred *cred,
24552455
/*
24562456
* Prepare a process for imminent new credential changes due to exec
24572457
*/
2458-
static void selinux_bprm_committing_creds(struct linux_binprm *bprm)
2458+
static void selinux_bprm_committing_creds(const struct linux_binprm *bprm)
24592459
{
24602460
struct task_security_struct *new_tsec;
24612461
struct rlimit *rlim, *initrlim;

0 commit comments

Comments
 (0)