summaryrefslogtreecommitdiffstats
path: root/security/security.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 /security/security.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 'security/security.c')
-rw-r--r--security/security.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/security/security.c b/security/security.c
index feb18c925349..b7a5a0051807 100644
--- a/security/security.c
+++ b/security/security.c
@@ -384,16 +384,25 @@ void security_sb_free(struct super_block *sb)
384 call_void_hook(sb_free_security, sb); 384 call_void_hook(sb_free_security, sb);
385} 385}
386 386
387int security_sb_eat_lsm_opts(char *options, struct security_mnt_opts *opts) 387void security_free_mnt_opts(void **mnt_opts)
388{ 388{
389 return call_int_hook(sb_eat_lsm_opts, 0, options, opts); 389 if (!*mnt_opts)
390 return;
391 call_void_hook(sb_free_mnt_opts, *mnt_opts);
392 *mnt_opts = NULL;
393}
394EXPORT_SYMBOL(security_free_mnt_opts);
395
396int security_sb_eat_lsm_opts(char *options, void **mnt_opts)
397{
398 return call_int_hook(sb_eat_lsm_opts, 0, options, mnt_opts);
390} 399}
391EXPORT_SYMBOL(security_sb_eat_lsm_opts); 400EXPORT_SYMBOL(security_sb_eat_lsm_opts);
392 401
393int security_sb_remount(struct super_block *sb, 402int security_sb_remount(struct super_block *sb,
394 struct security_mnt_opts *opts) 403 void *mnt_opts)
395{ 404{
396 return call_int_hook(sb_remount, 0, sb, opts); 405 return call_int_hook(sb_remount, 0, sb, mnt_opts);
397} 406}
398EXPORT_SYMBOL(security_sb_remount); 407EXPORT_SYMBOL(security_sb_remount);
399 408
@@ -429,13 +438,13 @@ int security_sb_pivotroot(const struct path *old_path, const struct path *new_pa
429} 438}
430 439
431int security_sb_set_mnt_opts(struct super_block *sb, 440int security_sb_set_mnt_opts(struct super_block *sb,
432 struct security_mnt_opts *opts, 441 void *mnt_opts,
433 unsigned long kern_flags, 442 unsigned long kern_flags,
434 unsigned long *set_kern_flags) 443 unsigned long *set_kern_flags)
435{ 444{
436 return call_int_hook(sb_set_mnt_opts, 445 return call_int_hook(sb_set_mnt_opts,
437 opts->num_mnt_opts ? -EOPNOTSUPP : 0, sb, 446 mnt_opts ? -EOPNOTSUPP : 0, sb,
438 opts, kern_flags, set_kern_flags); 447 mnt_opts, kern_flags, set_kern_flags);
439} 448}
440EXPORT_SYMBOL(security_sb_set_mnt_opts); 449EXPORT_SYMBOL(security_sb_set_mnt_opts);
441 450
@@ -449,9 +458,9 @@ int security_sb_clone_mnt_opts(const struct super_block *oldsb,
449} 458}
450EXPORT_SYMBOL(security_sb_clone_mnt_opts); 459EXPORT_SYMBOL(security_sb_clone_mnt_opts);
451 460
452int security_sb_parse_opts_str(char *options, struct security_mnt_opts *opts) 461int security_sb_parse_opts_str(char *options, void **mnt_opts)
453{ 462{
454 return call_int_hook(sb_parse_opts_str, 0, options, opts); 463 return call_int_hook(sb_parse_opts_str, 0, options, mnt_opts);
455} 464}
456EXPORT_SYMBOL(security_sb_parse_opts_str); 465EXPORT_SYMBOL(security_sb_parse_opts_str);
457 466