diff options
author | Linus Torvalds | 2022-06-16 15:50:36 -0700 |
---|---|---|
committer | Linus Torvalds | 2022-06-16 15:50:36 -0700 |
commit | 6decbf75c93e654ce6cb0e93a02ca6575dce9922 (patch) | |
tree | 01ea12b655e462dc0b373112a5060dba89a3dbbf | |
parent | 48a23ec6ff2b2a5effe8d3ae5f17fc6b7f35df65 (diff) | |
parent | cad140d00899e7a9cb6fe93b282051df589e671c (diff) |
Merge tag 'selinux-pr-20220616' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/selinux
Pull selinux fix from Paul Moore:
"A single SELinux patch to fix memory leaks when mounting filesystems
with SELinux mount options"
* tag 'selinux-pr-20220616' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/selinux:
selinux: free contexts previously transferred in selinux_add_opt()
-rw-r--r-- | security/selinux/hooks.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index beceb89f68d9..1bbd53321d13 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c @@ -2600,8 +2600,9 @@ static int selinux_sb_eat_lsm_opts(char *options, void **mnt_opts) } } rc = selinux_add_opt(token, arg, mnt_opts); + kfree(arg); + arg = NULL; if (unlikely(rc)) { - kfree(arg); goto free_opt; } } else { @@ -2792,17 +2793,13 @@ static int selinux_fs_context_parse_param(struct fs_context *fc, struct fs_parameter *param) { struct fs_parse_result result; - int opt, rc; + int opt; opt = fs_parse(fc, selinux_fs_parameters, param, &result); if (opt < 0) return opt; - rc = selinux_add_opt(opt, param->string, &fc->security); - if (!rc) - param->string = NULL; - - return rc; + return selinux_add_opt(opt, param->string, &fc->security); } /* inode security operations */ |