lsm: constify 'sb' parameter in security_sb_kern_mount()
authorKhadija Kamran <kamrankhadijadj@gmail.com>
Wed, 23 Aug 2023 09:01:28 +0000 (14:01 +0500)
committerPaul Moore <paul@paul-moore.com>
Thu, 14 Sep 2023 19:35:36 +0000 (15:35 -0400)
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>
include/linux/lsm_hook_defs.h
include/linux/security.h
security/security.c
security/selinux/hooks.c

index 3b0f5cfca4641f3329bb4c7ecc3b27434ef561a4..99b8176c3738d12a21b601789c5cac2e9bfd7893 100644 (file)
@@ -66,7 +66,7 @@ LSM_HOOK(void, LSM_RET_VOID, sb_free_mnt_opts, void *mnt_opts)
 LSM_HOOK(int, 0, sb_eat_lsm_opts, char *orig, void **mnt_opts)
 LSM_HOOK(int, 0, sb_mnt_opts_compat, struct super_block *sb, void *mnt_opts)
 LSM_HOOK(int, 0, sb_remount, struct super_block *sb, void *mnt_opts)
-LSM_HOOK(int, 0, sb_kern_mount, struct super_block *sb)
+LSM_HOOK(int, 0, sb_kern_mount, const struct super_block *sb)
 LSM_HOOK(int, 0, sb_show_options, struct seq_file *m, struct super_block *sb)
 LSM_HOOK(int, 0, sb_statfs, struct dentry *dentry)
 LSM_HOOK(int, 0, sb_mount, const char *dev_name, const struct path *path,
index 3148103123fb41de8ffdc5707f1dcd4e32b0071e..1d1df326c881c7e1a97d748066d046590c4aea72 100644 (file)
@@ -304,7 +304,7 @@ void security_free_mnt_opts(void **mnt_opts);
 int security_sb_eat_lsm_opts(char *options, void **mnt_opts);
 int security_sb_mnt_opts_compat(struct super_block *sb, void *mnt_opts);
 int security_sb_remount(struct super_block *sb, void *mnt_opts);
-int security_sb_kern_mount(struct super_block *sb);
+int security_sb_kern_mount(const struct super_block *sb);
 int security_sb_show_options(struct seq_file *m, struct super_block *sb);
 int security_sb_statfs(struct dentry *dentry);
 int security_sb_mount(const char *dev_name, const struct path *path,
index e4aec0f65f7546208084c7352b04d268bea3f97a..7b0052e9680619ed98b49d51de4b821d74ccc397 100644 (file)
@@ -1319,7 +1319,7 @@ EXPORT_SYMBOL(security_sb_remount);
  *
  * Return: Returns 0 if permission is granted.
  */
-int security_sb_kern_mount(struct super_block *sb)
+int security_sb_kern_mount(const struct super_block *sb)
 {
        return call_int_hook(sb_kern_mount, 0, sb);
 }
index e9ee008a9537db85367b744e3b035d490b5ad70d..195db92ac99c2481d857ee8ee2369efc175863ee 100644 (file)
@@ -2721,7 +2721,7 @@ out_bad_option:
        return -EINVAL;
 }
 
-static int selinux_sb_kern_mount(struct super_block *sb)
+static int selinux_sb_kern_mount(const struct super_block *sb)
 {
        const struct cred *cred = current_cred();
        struct common_audit_data ad;