public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Khadija Kamran <kamrankhadijadj@gmail.com>
To: "Mickaël Salaün" <mic@digikod.net>,
	"Paul Moore" <paul@paul-moore.com>,
	"James Morris" <jmorris@namei.org>,
	"Serge E. Hallyn" <serge@hallyn.com>,
	linux-security-module@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	"Stephen Smalley" <stephen.smalley.work@gmail.com>,
	"Eric Paris" <eparis@parisplace.org>,
	selinux@vger.kernel.org, ztarkhani@microsoft.com,
	alison.schofield@intel.com
Subject: [PATCH] lsm: constify 'sb' parameter in security_sb_remount()
Date: Wed, 23 Aug 2023 13:51:27 +0500	[thread overview]
Message-ID: <ZOXIjzLnnbuoLOrF@gmail.com> (raw)

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 <kamrankhadijadj@gmail.com>
---
 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(-)

diff --git a/include/linux/lsm_hook_defs.h b/include/linux/lsm_hook_defs.h
index 6bb55e61e8e8..dca689c9ac04 100644
--- a/include/linux/lsm_hook_defs.h
+++ b/include/linux/lsm_hook_defs.h
@@ -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)
diff --git a/include/linux/security.h b/include/linux/security.h
index e2734e9e44d5..ce08ed7d5437 100644
--- a/include/linux/security.h
+++ b/include/linux/security.h
@@ -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);
diff --git a/security/landlock/fs.c b/security/landlock/fs.c
index 1c0c198f6fdb..fabe324922ec 100644
--- a/security/landlock/fs.c
+++ b/security/landlock/fs.c
@@ -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;
diff --git a/security/security.c b/security/security.c
index d5ff7ff45b77..acc8a92ba857 100644
--- a/security/security.c
+++ b/security/security.c
@@ -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);
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index 79b4890e9936..e4de42150b87 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -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);
-- 
2.34.1


             reply	other threads:[~2023-08-23  9:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-23  8:51 Khadija Kamran [this message]
2023-08-23 12:44 ` [PATCH] lsm: constify 'sb' parameter in security_sb_remount() Mickaël Salaün
2023-09-13 22:05   ` Paul Moore

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZOXIjzLnnbuoLOrF@gmail.com \
    --to=kamrankhadijadj@gmail.com \
    --cc=alison.schofield@intel.com \
    --cc=eparis@parisplace.org \
    --cc=jmorris@namei.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=mic@digikod.net \
    --cc=paul@paul-moore.com \
    --cc=selinux@vger.kernel.org \
    --cc=serge@hallyn.com \
    --cc=stephen.smalley.work@gmail.com \
    --cc=ztarkhani@microsoft.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox