Skip to content

Commit 20a2aa4

Browse files
KhadijaKamranpcmoore
authored andcommitted
lsm: constify 'sb' parameter in security_sb_kern_mount()
The "sb_kern_mount" hook has implementation registered in SELinux. Looking at the function implementation we observe that the "sb" parameter is not changing. Mark the "sb" parameter of LSM hook security_sb_kern_mount() 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 a721f7b commit 20a2aa4

4 files changed

Lines changed: 4 additions & 4 deletions

File tree

include/linux/lsm_hook_defs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ LSM_HOOK(void, LSM_RET_VOID, sb_free_mnt_opts, void *mnt_opts)
6666
LSM_HOOK(int, 0, sb_eat_lsm_opts, char *orig, void **mnt_opts)
6767
LSM_HOOK(int, 0, sb_mnt_opts_compat, struct super_block *sb, void *mnt_opts)
6868
LSM_HOOK(int, 0, sb_remount, struct super_block *sb, void *mnt_opts)
69-
LSM_HOOK(int, 0, sb_kern_mount, struct super_block *sb)
69+
LSM_HOOK(int, 0, sb_kern_mount, const struct super_block *sb)
7070
LSM_HOOK(int, 0, sb_show_options, struct seq_file *m, struct super_block *sb)
7171
LSM_HOOK(int, 0, sb_statfs, struct dentry *dentry)
7272
LSM_HOOK(int, 0, sb_mount, const char *dev_name, const struct path *path,

include/linux/security.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ void security_free_mnt_opts(void **mnt_opts);
304304
int security_sb_eat_lsm_opts(char *options, void **mnt_opts);
305305
int security_sb_mnt_opts_compat(struct super_block *sb, void *mnt_opts);
306306
int security_sb_remount(struct super_block *sb, void *mnt_opts);
307-
int security_sb_kern_mount(struct super_block *sb);
307+
int security_sb_kern_mount(const struct super_block *sb);
308308
int security_sb_show_options(struct seq_file *m, struct super_block *sb);
309309
int security_sb_statfs(struct dentry *dentry);
310310
int security_sb_mount(const char *dev_name, const struct path *path,

security/security.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1319,7 +1319,7 @@ EXPORT_SYMBOL(security_sb_remount);
13191319
*
13201320
* Return: Returns 0 if permission is granted.
13211321
*/
1322-
int security_sb_kern_mount(struct super_block *sb)
1322+
int security_sb_kern_mount(const struct super_block *sb)
13231323
{
13241324
return call_int_hook(sb_kern_mount, 0, sb);
13251325
}

security/selinux/hooks.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2721,7 +2721,7 @@ static int selinux_sb_remount(struct super_block *sb, void *mnt_opts)
27212721
return -EINVAL;
27222722
}
27232723

2724-
static int selinux_sb_kern_mount(struct super_block *sb)
2724+
static int selinux_sb_kern_mount(const struct super_block *sb)
27252725
{
27262726
const struct cred *cred = current_cred();
27272727
struct common_audit_data ad;

0 commit comments

Comments
 (0)