summary refs log tree commit diff
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2018-12-12 20:13:29 -0500
committerAl Viro <viro@zeniv.linux.org.uk>2018-12-21 11:47:41 -0500
commit5b4002391153acebce2557af318bbdc17e235134 (patch)
treeb5c6afc5fbffd01ca682332e2893bad477e59b9d
parent6a0440e5b7562512c021aa1b5a706fcc545773db (diff)
downloadlinux-5b4002391153acebce2557af318bbdc17e235134.tar.gz
LSM: turn sb_eat_lsm_opts() into a method
Kill ->sb_copy_data() - it's used only in combination with immediately
following ->sb_parse_opts_str().  Turn that combination into a new
method.

This is just a mechanical move - cleanups will be the next step.

Reviewed-by: David Howells <dhowells@redhat.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r--include/linux/lsm_hooks.h4
-rw-r--r--security/security.c11
-rw-r--r--security/selinux/hooks.c16
-rw-r--r--security/smack/smack_lsm.c16
4 files changed, 33 insertions, 14 deletions
diff --git a/include/linux/lsm_hooks.h b/include/linux/lsm_hooks.h
index f432123af0e3..c418909c178c 100644
--- a/include/linux/lsm_hooks.h
+++ b/include/linux/lsm_hooks.h
@@ -1461,7 +1461,7 @@ union security_list_options {
 
 	int (*sb_alloc_security)(struct super_block *sb);
 	void (*sb_free_security)(struct super_block *sb);
-	int (*sb_copy_data)(char *orig, char *copy);
+	int (*sb_eat_lsm_opts)(char *orig, struct security_mnt_opts *opts);
 	int (*sb_remount)(struct super_block *sb,
 			  struct security_mnt_opts *opts);
 	int (*sb_kern_mount)(struct super_block *sb);
@@ -1801,7 +1801,7 @@ struct security_hook_heads {
 	struct hlist_head bprm_committed_creds;
 	struct hlist_head sb_alloc_security;
 	struct hlist_head sb_free_security;
-	struct hlist_head sb_copy_data;
+	struct hlist_head sb_eat_lsm_opts;
 	struct hlist_head sb_remount;
 	struct hlist_head sb_kern_mount;
 	struct hlist_head sb_show_options;
diff --git a/security/security.c b/security/security.c
index 3d8b72904e00..feb18c925349 100644
--- a/security/security.c
+++ b/security/security.c
@@ -386,16 +386,7 @@ void security_sb_free(struct super_block *sb)
 
 int security_sb_eat_lsm_opts(char *options, struct security_mnt_opts *opts)
 {
-	char *s = (char *)get_zeroed_page(GFP_KERNEL);
-	int err;
-
-	if (!s)
-		return -ENOMEM;
-	err = call_int_hook(sb_copy_data, 0, options, s);
-	if (!err)
-		err = call_int_hook(sb_parse_opts_str, 0, s, opts);
-	free_page((unsigned long)s);
-	return err;
+	return call_int_hook(sb_eat_lsm_opts, 0, options, opts);
 }
 EXPORT_SYMBOL(security_sb_eat_lsm_opts);
 
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index 630fe8883957..ce0511f024e0 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -2810,6 +2810,20 @@ out:
 	return rc;
 }
 
+static int selinux_sb_eat_lsm_opts(char *options, struct security_mnt_opts *opts)
+{
+	char *s = (char *)get_zeroed_page(GFP_KERNEL);
+	int err;
+
+	if (!s)
+		return -ENOMEM;
+	err = selinux_sb_copy_data(options, s);
+	if (!err)
+		err = selinux_parse_opts_str(s, opts);
+	free_page((unsigned long)s);
+	return err;
+}
+
 static int selinux_sb_remount(struct super_block *sb,
 			      struct security_mnt_opts *opts)
 {
@@ -6863,7 +6877,7 @@ static struct security_hook_list selinux_hooks[] __lsm_ro_after_init = {
 
 	LSM_HOOK_INIT(sb_alloc_security, selinux_sb_alloc_security),
 	LSM_HOOK_INIT(sb_free_security, selinux_sb_free_security),
-	LSM_HOOK_INIT(sb_copy_data, selinux_sb_copy_data),
+	LSM_HOOK_INIT(sb_eat_lsm_opts, selinux_sb_eat_lsm_opts),
 	LSM_HOOK_INIT(sb_remount, selinux_sb_remount),
 	LSM_HOOK_INIT(sb_kern_mount, selinux_sb_kern_mount),
 	LSM_HOOK_INIT(sb_show_options, selinux_sb_show_options),
diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
index 50e6e88bfe70..835cca277c2a 100644
--- a/security/smack/smack_lsm.c
+++ b/security/smack/smack_lsm.c
@@ -739,6 +739,20 @@ out_err:
 	return rc;
 }
 
+static int smack_sb_eat_lsm_opts(char *options, struct security_mnt_opts *opts)
+{
+	char *s = (char *)get_zeroed_page(GFP_KERNEL);
+	int err;
+
+	if (!s)
+		return -ENOMEM;
+	err = smack_sb_copy_data(options, s);
+	if (!err)
+		err = smack_parse_opts_str(s, opts);
+	free_page((unsigned long)s);
+	return err;
+}
+
 /**
  * smack_set_mnt_opts - set Smack specific mount options
  * @sb: the file system superblock
@@ -4637,7 +4651,7 @@ static struct security_hook_list smack_hooks[] __lsm_ro_after_init = {
 
 	LSM_HOOK_INIT(sb_alloc_security, smack_sb_alloc_security),
 	LSM_HOOK_INIT(sb_free_security, smack_sb_free_security),
-	LSM_HOOK_INIT(sb_copy_data, smack_sb_copy_data),
+	LSM_HOOK_INIT(sb_eat_lsm_opts, smack_sb_eat_lsm_opts),
 	LSM_HOOK_INIT(sb_statfs, smack_sb_statfs),
 	LSM_HOOK_INIT(sb_set_mnt_opts, smack_set_mnt_opts),
 	LSM_HOOK_INIT(sb_parse_opts_str, smack_parse_opts_str),