lsm: constify 'sb' parameter in security_sb_remount()
Subsystems (3)
PATCH 1/1 lsm: constify 'sb' parameter in security_sb_remount()
The "sb_remount" hook has implementations registered in SELinux and Landlock. Looking at the function implementations we observe that the "sb" parameter is not changing.
Mark the "sb" parameter of LSM hook security_sb_remount() as "const" since it will not be changing in the LSM hook.
--- include/linux/lsm_hook_defs.h | 2 +- include/linux/security.h | 2 +- security/landlock/fs.c | 2 +- security/security.c | 2 +- security/selinux/hooks.c | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-)
include/linux/lsm_hook_defs.h +1 -1
@@ -64,7 +64,7 @@ LSM_HOOK(void, LSM_RET_VOID, sb_free_security, struct super_block *sb) 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_remount, const struct super_block *sb, void *mnt_opts) LSM_HOOK(int, 0, sb_kern_mount, 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)
include/linux/security.h +1 -1
@@ -301,7 +301,7 @@ void security_sb_free(struct super_block *sb);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_remount (const struct super_block *sb,void *mnt_opts);int security_sb_kern_mount (struct super_block *sb);int security_sb_show_options (struct seq_file *m,struct super_block *sb);int security_sb_statfs (struct dentry *dentry);
security/landlock/fs.c +1 -1
@@ -1074,7 +1074,7 @@ static int hook_sb_umount(struct vfsmount *const mnt, const int flags)return -EPERM ; } -static int hook_sb_remount (struct super_block *const sb,void *const mnt_opts) +static int hook_sb_remount (const struct super_block *const sb,void *const mnt_opts) {if (!landlock_get_current_domain ())return 0 ;
security/security.c +1 -1
@@ -1289,7 +1289,7 @@ EXPORT_SYMBOL(security_sb_mnt_opts_compat);* * Return: Returns 0 if permission is granted. */ -int security_sb_remount (struct super_block *sb, +int security_sb_remount (const struct super_block *sb,void *mnt_opts) {return call_int_hook (sb_remount,0 , sb, mnt_opts);
security/selinux/hooks.c +1 -1
@@ -2628,7 +2628,7 @@ static int selinux_sb_mnt_opts_compat(struct super_block *sb, void *mnt_opts)return 0 ; } -static int selinux_sb_remount (struct super_block *sb,void *mnt_opts) +static int selinux_sb_remount (const struct super_block *sb,void *mnt_opts) {struct selinux_mnt_opts *opts = mnt_opts;struct superblock_security_struct *sbsec =selinux_superblock (sb);
Signature · 1 line
2.34.1
Mickaël Salaün
maintainerHi Khadija,
Quoted 21 lines · Khadija Kamran
The "
sb_remount" hook has implementations registered in SELinux and Landlock. Looking at the function implementations we observe that the "sb" parameter is not changing.Mark the "sb" parameter of LSM hook
security_sb_remount()as "const" since it will not be changing in the LSM hook.Signed-off-by Khadija Kamran <[email protected]>--- include/linux/lsm_hook_defs.h | 2 +- include/linux/security.h | 2 +- security/landlock/fs.c | 2 +- security/security.c | 2 +- security/selinux/hooks.c | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-)security/landlock/fs.c +0
-0
security/landlock/fs.c static int hook_sb_umount(struct vfsmount *const mnt, const int flags) · line 1077
Quoted 5 lines
security/landlock/fs.c +1
-1@@ -1074,7 +1074,7 @@ static int hook_sb_umount(struct vfsmount *const mnt, const int flags)return -EPERM ; } -static int hook_sb_remount (struct super_block *const sb,void *const mnt_opts) +static int hook_sb_remount (const struct super_block *const sb,void *const mnt_opts)
Please format with clang-format -i security/landlock/*.[ch]
Quoted 3 lines
security/landlock/fs.c +0
-0{if (!landlock_get_current_domain ())return 0 ;
Paul Moore
maintainerQuoted 28 lines · Mickaël Salaün
Hi Khadija,
Quoted 24 lines · Khadija Kamran
The "
sb_remount" hook has implementations registered in SELinux and Landlock. Looking at the function implementations we observe that the "sb" parameter is not changing.Mark the "sb" parameter of LSM hook
security_sb_remount()as "const" since it will not be changing in the LSM hook.Signed-off-by Khadija Kamran <[email protected]>--- include/linux/lsm_hook_defs.h | 2 +- include/linux/security.h | 2 +- security/landlock/fs.c | 2 +- security/security.c | 2 +- security/selinux/hooks.c | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-)security/landlock/fs.c +0
-0@@ -1074,7 +1074,7 @@ static int hook_sb_umount(struct vfsmount *const mnt, const int flags)return -EPERM ; }
Quoted 4 lines
security/landlock/fs.c static int hook_sb_umount(struct vfsmount *const mnt, const int flags) · line 1077
Quoted 2 lines
security/landlock/fs.c +1
-1-static int hook_sb_remount (struct super_block *const sb,void *const mnt_opts) +static int hook_sb_remount (const struct super_block *const sb,void *const mnt_opts)Please format with clang-format -i security/landlock/*.[ch]
Hi Khadija, can you please format the security/landlock/fs.c change as requested by Mickaël?
You can find information on running clang-format on the Linux kernel at the link below:
* https://www.kernel.org/doc/html/next/process/clang-format.html
Signature · 1 line
paul-moore.com