]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
LSM: split ->sb_set_mnt_opts() out of ->sb_kern_mount()
authorAl Viro <viro@zeniv.linux.org.uk>
Wed, 5 Dec 2018 16:58:35 +0000 (11:58 -0500)
committerAl Viro <viro@zeniv.linux.org.uk>
Fri, 21 Dec 2018 16:46:42 +0000 (11:46 -0500)
... leaving the "is it kernel-internal" logics in the caller.

Reviewed-by: David Howells <dhowells@redhat.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/super.c
include/linux/lsm_hooks.h
include/linux/security.h
security/security.c
security/selinux/hooks.c
security/smack/smack_lsm.c

index d571527cb8b8a2ece62f2a6b0ba96df48dae2037..1f75fe3125977089db8f1416f3a3fa6fda6f1b46 100644 (file)
@@ -1275,10 +1275,16 @@ mount_fs(struct file_system_type *type, int flags, const char *name, void *data)
        smp_wmb();
        sb->s_flags |= SB_BORN;
 
-       error = security_sb_kern_mount(sb, flags, &opts);
+       error = security_sb_set_mnt_opts(sb, &opts, 0, NULL);
        if (error)
                goto out_sb;
 
+       if (!(flags & MS_KERNMOUNT)) {
+               error = security_sb_kern_mount(sb);
+               if (error)
+                       goto out_sb;
+       }
+
        /*
         * filesystems should never set s_maxbytes larger than MAX_LFS_FILESIZE
         * but s_maxbytes was an unsigned long long for many releases. Throw
index e1a12a1e2b321985545da5db2164b68553ab6139..f432123af0e340a5bb2949e55c35d8a1e28b8da1 100644 (file)
@@ -1464,8 +1464,7 @@ union security_list_options {
        int (*sb_copy_data)(char *orig, char *copy);
        int (*sb_remount)(struct super_block *sb,
                          struct security_mnt_opts *opts);
-       int (*sb_kern_mount)(struct super_block *sb, int flags,
-                            struct security_mnt_opts *opts);
+       int (*sb_kern_mount)(struct super_block *sb);
        int (*sb_show_options)(struct seq_file *m, struct super_block *sb);
        int (*sb_statfs)(struct dentry *dentry);
        int (*sb_mount)(const char *dev_name, const struct path *path,
index 262e59838803f7fb1bfe192a23d867f633672b7d..d000933635701897960cad0b9d02dcde82e314ff 100644 (file)
@@ -250,8 +250,7 @@ int security_sb_alloc(struct super_block *sb);
 void security_sb_free(struct super_block *sb);
 int security_sb_eat_lsm_opts(char *options, struct security_mnt_opts *opts);
 int security_sb_remount(struct super_block *sb, struct security_mnt_opts *opts);
-int security_sb_kern_mount(struct super_block *sb, int flags,
-                          struct security_mnt_opts *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);
 int security_sb_mount(const char *dev_name, const struct path *path,
@@ -568,8 +567,7 @@ static inline int security_sb_remount(struct super_block *sb,
        return 0;
 }
 
-static inline int security_sb_kern_mount(struct super_block *sb, int flags,
-                                        struct security_mnt_opts *opts)
+static inline int security_sb_kern_mount(struct super_block *sb)
 {
        return 0;
 }
index 02c656dd5c0ca43505473314c2b2bf8b1c3ed496..afb05646d41b7e9acc96459dc4e60026f764c14c 100644 (file)
@@ -405,10 +405,9 @@ int security_sb_remount(struct super_block *sb,
        return call_int_hook(sb_remount, 0, sb, opts);
 }
 
-int security_sb_kern_mount(struct super_block *sb, int flags,
-                          struct security_mnt_opts *opts)
+int security_sb_kern_mount(struct super_block *sb)
 {
-       return call_int_hook(sb_kern_mount, 0, sb, flags, opts);
+       return call_int_hook(sb_kern_mount, 0, sb);
 }
 
 int security_sb_show_options(struct seq_file *m, struct super_block *sb)
index ba3e2917bd24d358d8bd28e914b9cb3579bbc096..59b164d7134d0b463375363b64431cddc2a49455 100644 (file)
@@ -2874,18 +2874,10 @@ static int selinux_sb_remount(struct super_block *sb,
        return -EINVAL;
 }
 
-static int selinux_sb_kern_mount(struct super_block *sb, int flags,
-                                struct security_mnt_opts *opts)
+static int selinux_sb_kern_mount(struct super_block *sb)
 {
        const struct cred *cred = current_cred();
        struct common_audit_data ad;
-       int rc = selinux_set_mnt_opts(sb, opts, 0, NULL);
-       if (rc)
-               return rc;
-
-       /* Allow all mounts performed by the kernel */
-       if (flags & MS_KERNMOUNT)
-               return 0;
 
        ad.type = LSM_AUDIT_DATA_DENTRY;
        ad.u.dentry = sb->s_root;
index 1d465ae3d11cd423bccda0f6bf826c0903c1b436..50e6e88bfe705ab19931f668ee29cc16d45f7446 100644 (file)
@@ -851,20 +851,6 @@ static int smack_set_mnt_opts(struct super_block *sb,
        return 0;
 }
 
-/**
- * smack_sb_kern_mount - Smack specific mount processing
- * @sb: the file system superblock
- * @flags: the mount flags
- * @data: the smack mount options
- *
- * Returns 0 on success, an error code on failure
- */
-static int smack_sb_kern_mount(struct super_block *sb, int flags,
-                              struct security_mnt_opts *opts)
-{
-       return smack_set_mnt_opts(sb, opts, 0, NULL);
-}
-
 /**
  * smack_sb_statfs - Smack check on statfs
  * @dentry: identifies the file system in question
@@ -4652,7 +4638,6 @@ 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_kern_mount, smack_sb_kern_mount),
        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),