diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2018-12-01 22:42:44 -0500 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2018-12-21 11:45:30 -0500 |
commit | 6be8750b4cba8c37170f46b29841d112f1be749b (patch) | |
tree | 0b3386c080d73fc666afcdcd1db5290b990af349 /security | |
parent | 6466f3d193a99426db067855345e763de2160f1c (diff) |
LSM: lift parsing LSM options into the caller of ->sb_kern_mount()
This paves the way for retaining the LSM options from a common filesystem
mount context during a mount parameter parsing phase to be instituted prior
to actual mount/reconfiguration actions.
Reviewed-by: David Howells <dhowells@redhat.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'security')
-rw-r--r-- | security/security.c | 5 | ||||
-rw-r--r-- | security/selinux/hooks.c | 24 | ||||
-rw-r--r-- | security/smack/smack_lsm.c | 23 |
3 files changed, 9 insertions, 43 deletions
diff --git a/security/security.c b/security/security.c index 04d173eb93f6..b5fc8e1e849c 100644 --- a/security/security.c +++ b/security/security.c | |||
@@ -395,9 +395,10 @@ int security_sb_remount(struct super_block *sb, void *data) | |||
395 | return call_int_hook(sb_remount, 0, sb, data); | 395 | return call_int_hook(sb_remount, 0, sb, data); |
396 | } | 396 | } |
397 | 397 | ||
398 | int security_sb_kern_mount(struct super_block *sb, int flags, void *data) | 398 | int security_sb_kern_mount(struct super_block *sb, int flags, |
399 | struct security_mnt_opts *opts) | ||
399 | { | 400 | { |
400 | return call_int_hook(sb_kern_mount, 0, sb, flags, data); | 401 | return call_int_hook(sb_kern_mount, 0, sb, flags, opts); |
401 | } | 402 | } |
402 | 403 | ||
403 | int security_sb_show_options(struct seq_file *m, struct super_block *sb) | 404 | int security_sb_show_options(struct seq_file *m, struct super_block *sb) |
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index 4bd6f9435e2f..ba229d4a64d3 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c | |||
@@ -2897,30 +2897,12 @@ out_bad_option: | |||
2897 | goto out_free_opts; | 2897 | goto out_free_opts; |
2898 | } | 2898 | } |
2899 | 2899 | ||
2900 | static int selinux_sb_kern_mount(struct super_block *sb, int flags, void *data) | 2900 | static int selinux_sb_kern_mount(struct super_block *sb, int flags, |
2901 | struct security_mnt_opts *opts) | ||
2901 | { | 2902 | { |
2902 | char *options = data; | ||
2903 | const struct cred *cred = current_cred(); | 2903 | const struct cred *cred = current_cred(); |
2904 | struct common_audit_data ad; | 2904 | struct common_audit_data ad; |
2905 | int rc = 0; | 2905 | int rc = selinux_set_mnt_opts(sb, opts, 0, NULL); |
2906 | struct security_mnt_opts opts; | ||
2907 | |||
2908 | security_init_mnt_opts(&opts); | ||
2909 | |||
2910 | if (!data) | ||
2911 | goto out; | ||
2912 | |||
2913 | BUG_ON(sb->s_type->fs_flags & FS_BINARY_MOUNTDATA); | ||
2914 | |||
2915 | rc = selinux_parse_opts_str(options, &opts); | ||
2916 | if (rc) | ||
2917 | goto out_err; | ||
2918 | |||
2919 | out: | ||
2920 | rc = selinux_set_mnt_opts(sb, &opts, 0, NULL); | ||
2921 | |||
2922 | out_err: | ||
2923 | security_free_mnt_opts(&opts); | ||
2924 | if (rc) | 2906 | if (rc) |
2925 | return rc; | 2907 | return rc; |
2926 | 2908 | ||
diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c index 73e41797960e..1d465ae3d11c 100644 --- a/security/smack/smack_lsm.c +++ b/security/smack/smack_lsm.c | |||
@@ -859,27 +859,10 @@ static int smack_set_mnt_opts(struct super_block *sb, | |||
859 | * | 859 | * |
860 | * Returns 0 on success, an error code on failure | 860 | * Returns 0 on success, an error code on failure |
861 | */ | 861 | */ |
862 | static int smack_sb_kern_mount(struct super_block *sb, int flags, void *data) | 862 | static int smack_sb_kern_mount(struct super_block *sb, int flags, |
863 | struct security_mnt_opts *opts) | ||
863 | { | 864 | { |
864 | int rc = 0; | 865 | return smack_set_mnt_opts(sb, opts, 0, NULL); |
865 | char *options = data; | ||
866 | struct security_mnt_opts opts; | ||
867 | |||
868 | security_init_mnt_opts(&opts); | ||
869 | |||
870 | if (!options) | ||
871 | goto out; | ||
872 | |||
873 | rc = smack_parse_opts_str(options, &opts); | ||
874 | if (rc) | ||
875 | goto out_err; | ||
876 | |||
877 | out: | ||
878 | rc = smack_set_mnt_opts(sb, &opts, 0, NULL); | ||
879 | |||
880 | out_err: | ||
881 | security_free_mnt_opts(&opts); | ||
882 | return rc; | ||
883 | } | 866 | } |
884 | 867 | ||
885 | /** | 868 | /** |