summaryrefslogtreecommitdiffstats
path: root/security
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2018-12-01 22:42:44 -0500
committerAl Viro <viro@zeniv.linux.org.uk>2018-12-21 11:45:30 -0500
commit6be8750b4cba8c37170f46b29841d112f1be749b (patch)
tree0b3386c080d73fc666afcdcd1db5290b990af349 /security
parent6466f3d193a99426db067855345e763de2160f1c (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.c5
-rw-r--r--security/selinux/hooks.c24
-rw-r--r--security/smack/smack_lsm.c23
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
398int security_sb_kern_mount(struct super_block *sb, int flags, void *data) 398int 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
403int security_sb_show_options(struct seq_file *m, struct super_block *sb) 404int 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
2900static int selinux_sb_kern_mount(struct super_block *sb, int flags, void *data) 2900static 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
2919out:
2920 rc = selinux_set_mnt_opts(sb, &opts, 0, NULL);
2921
2922out_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 */
862static int smack_sb_kern_mount(struct super_block *sb, int flags, void *data) 862static 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
877out:
878 rc = smack_set_mnt_opts(sb, &opts, 0, NULL);
879
880out_err:
881 security_free_mnt_opts(&opts);
882 return rc;
883} 866}
884 867
885/** 868/**