Skip to content

Commit a721f7b

Browse files
KhadijaKamranpcmoore
authored andcommitted
lsm: constify 'bprm' parameter in security_bprm_committed_creds()
Three LSMs register the implementations for the 'bprm_committed_creds()' hook: AppArmor, SELinux and tomoyo. Looking at the function implementations we may observe that the 'bprm' parameter is not changing. Mark the 'bprm' parameter of LSM hook security_bprm_committed_creds() as 'const' since it will not be changing in the LSM hook. Signed-off-by: Khadija Kamran <kamrankhadijadj@gmail.com> [PM: minor merge fuzzing due to other constification patches] Signed-off-by: Paul Moore <paul@paul-moore.com>
1 parent 64fc952 commit a721f7b

6 files changed

Lines changed: 7 additions & 7 deletions

File tree

include/linux/lsm_hook_defs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ 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)
5555
LSM_HOOK(void, LSM_RET_VOID, bprm_committing_creds, const struct linux_binprm *bprm)
56-
LSM_HOOK(void, LSM_RET_VOID, bprm_committed_creds, struct linux_binprm *bprm)
56+
LSM_HOOK(void, LSM_RET_VOID, bprm_committed_creds, const 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,
5959
struct fs_context *src_sc)

include/linux/security.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ 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);
295295
void security_bprm_committing_creds(const struct linux_binprm *bprm);
296-
void security_bprm_committed_creds(struct linux_binprm *bprm);
296+
void security_bprm_committed_creds(const 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);
299299
int security_fs_context_parse_param(struct fs_context *fc, struct fs_parameter *param);
@@ -627,7 +627,7 @@ static inline void security_bprm_committing_creds(const struct linux_binprm *bpr
627627
{
628628
}
629629

630-
static inline void security_bprm_committed_creds(struct linux_binprm *bprm)
630+
static inline void security_bprm_committed_creds(const struct linux_binprm *bprm)
631631
{
632632
}
633633

security/apparmor/lsm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -756,7 +756,7 @@ static void apparmor_bprm_committing_creds(const struct linux_binprm *bprm)
756756
* apparmor_bprm_committed_creds() - do cleanup after new creds committed
757757
* @bprm: binprm for the exec (NOT NULL)
758758
*/
759-
static void apparmor_bprm_committed_creds(struct linux_binprm *bprm)
759+
static void apparmor_bprm_committed_creds(const struct linux_binprm *bprm)
760760
{
761761
/* clear out temporary/transitional state from the context */
762762
aa_clear_task_ctx_trans(task_ctx(current));

security/security.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1134,7 +1134,7 @@ void security_bprm_committing_creds(const struct linux_binprm *bprm)
11341134
* process such as clearing out non-inheritable signal state. This is called
11351135
* immediately after commit_creds().
11361136
*/
1137-
void security_bprm_committed_creds(struct linux_binprm *bprm)
1137+
void security_bprm_committed_creds(const struct linux_binprm *bprm)
11381138
{
11391139
call_void_hook(bprm_committed_creds, bprm);
11401140
}

security/selinux/hooks.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2501,7 +2501,7 @@ static void selinux_bprm_committing_creds(const struct linux_binprm *bprm)
25012501
* Clean up the process immediately after the installation of new credentials
25022502
* due to exec
25032503
*/
2504-
static void selinux_bprm_committed_creds(struct linux_binprm *bprm)
2504+
static void selinux_bprm_committed_creds(const struct linux_binprm *bprm)
25052505
{
25062506
const struct task_security_struct *tsec = selinux_cred(current_cred());
25072507
u32 osid, sid;

security/tomoyo/tomoyo.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ static int tomoyo_cred_prepare(struct cred *new, const struct cred *old,
5252
*
5353
* @bprm: Pointer to "struct linux_binprm".
5454
*/
55-
static void tomoyo_bprm_committed_creds(struct linux_binprm *bprm)
55+
static void tomoyo_bprm_committed_creds(const struct linux_binprm *bprm)
5656
{
5757
/* Clear old_domain_info saved by execve() request. */
5858
struct tomoyo_task *s = tomoyo_task(current);

0 commit comments

Comments
 (0)