... 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>
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
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,
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,
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;
}
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)
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;
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
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),