LSM: turn sb_eat_lsm_opts() into a method
authorAl Viro <viro@zeniv.linux.org.uk>
Thu, 13 Dec 2018 01:13:29 +0000 (20:13 -0500)
committerAl Viro <viro@zeniv.linux.org.uk>
Fri, 21 Dec 2018 16:47:41 +0000 (11:47 -0500)
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>
include/linux/lsm_hooks.h
security/security.c
security/selinux/hooks.c
security/smack/smack_lsm.c

index f432123..c418909 100644 (file)
@@ -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;
index 3d8b729..feb18c9 100644 (file)
@@ -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);
 
index 630fe88..ce0511f 100644 (file)
@@ -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),
index 50e6e88..835cca2 100644 (file)
@@ -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),