summaryrefslogtreecommitdiffstats
path: root/fs/super.c
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2018-12-13 13:41:47 -0500
committerAl Viro <viro@zeniv.linux.org.uk>2018-12-21 11:48:34 -0500
commit204cc0ccf1d49c6292aeef4c8edd1b3d10ff933c (patch)
treeb372464222a21a2a0356fde8421eb86cb991a378 /fs/super.c
parente3489f8974e178d723259a842a1e61708dd7dc1e (diff)
LSM: hide struct security_mnt_opts from any generic code
Keep void * instead, allocate on demand (in parse_str_opts, at the moment). Eventually both selinux and smack will be better off with private structures with several strings in those, rather than this "counter and two pointers to dynamically allocated arrays" ugliness. This commit allows to do that at leisure, without disrupting anything outside of given module. Changes: * instead of struct security_mnt_opt use an opaque pointer initialized to NULL. * security_sb_eat_lsm_opts(), security_sb_parse_opts_str() and security_free_mnt_opts() take it as var argument (i.e. as void **); call sites are unchanged. * security_sb_set_mnt_opts() and security_sb_remount() take it by value (i.e. as void *). * new method: ->sb_free_mnt_opts(). Takes void *, does whatever freeing that needs to be done. * ->sb_set_mnt_opts() and ->sb_remount() might get NULL as mnt_opts argument, meaning "empty". Reviewed-by: David Howells <dhowells@redhat.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/super.c')
-rw-r--r--fs/super.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/fs/super.c b/fs/super.c
index 1f75fe312597..a5511c4ba69b 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -1247,12 +1247,10 @@ mount_fs(struct file_system_type *type, int flags, const char *name, void *data)
1247 struct dentry *root; 1247 struct dentry *root;
1248 struct super_block *sb; 1248 struct super_block *sb;
1249 int error = -ENOMEM; 1249 int error = -ENOMEM;
1250 struct security_mnt_opts opts; 1250 void *sec_opts = NULL;
1251
1252 security_init_mnt_opts(&opts);
1253 1251
1254 if (data && !(type->fs_flags & FS_BINARY_MOUNTDATA)) { 1252 if (data && !(type->fs_flags & FS_BINARY_MOUNTDATA)) {
1255 error = security_sb_eat_lsm_opts(data, &opts); 1253 error = security_sb_eat_lsm_opts(data, &sec_opts);
1256 if (error) 1254 if (error)
1257 return ERR_PTR(error); 1255 return ERR_PTR(error);
1258 } 1256 }
@@ -1275,7 +1273,7 @@ mount_fs(struct file_system_type *type, int flags, const char *name, void *data)
1275 smp_wmb(); 1273 smp_wmb();
1276 sb->s_flags |= SB_BORN; 1274 sb->s_flags |= SB_BORN;
1277 1275
1278 error = security_sb_set_mnt_opts(sb, &opts, 0, NULL); 1276 error = security_sb_set_mnt_opts(sb, sec_opts, 0, NULL);
1279 if (error) 1277 if (error)
1280 goto out_sb; 1278 goto out_sb;
1281 1279
@@ -1295,13 +1293,13 @@ mount_fs(struct file_system_type *type, int flags, const char *name, void *data)
1295 "negative value (%lld)\n", type->name, sb->s_maxbytes); 1293 "negative value (%lld)\n", type->name, sb->s_maxbytes);
1296 1294
1297 up_write(&sb->s_umount); 1295 up_write(&sb->s_umount);
1298 security_free_mnt_opts(&opts); 1296 security_free_mnt_opts(&sec_opts);
1299 return root; 1297 return root;
1300out_sb: 1298out_sb:
1301 dput(root); 1299 dput(root);
1302 deactivate_locked_super(sb); 1300 deactivate_locked_super(sb);
1303out_free_secdata: 1301out_free_secdata:
1304 security_free_mnt_opts(&opts); 1302 security_free_mnt_opts(&sec_opts);
1305 return ERR_PTR(error); 1303 return ERR_PTR(error);
1306} 1304}
1307 1305