History

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()

Linus Torvalds committed 4 years ago

Commit 6decbf72 parents 48a23ec cad140d1 file · +4 −7Browse files

Unified · Split

security/selinux/hooks.c+4−7
@@ -2600,8 +2600,9 @@ static int selinux_sb_eat_lsm_opts(char *options, void **mnt_opts) · 2599 unmodified lines
26002600 }
26012601 }
26022602 rc = selinux_add_opt(token, arg, mnt_opts);
2603+ kfree(arg);
2604+ arg = NULL;
26032605 if (unlikely(rc)) {
2604− kfree(arg);
26052606 goto free_opt;
26062607 }
26072608 } else {
@@ -2792,17 +2793,13 @@ static int selinux_fs_context_parse_param(struct fs_context *fc, · 184 unmodified lines
27922793 struct fs_parameter *param)
27932794 {
27942795 struct fs_parse_result result;
2795− int opt, rc;
2796+ int opt;
27962797
27972798 opt = fs_parse(fc, selinux_fs_parameters, param, &result);
27982799 if (opt < 0)
27992800 return opt;
28002801
2801− rc = selinux_add_opt(opt, param->string, &fc->security);
2802− if (!rc)
2803− param->string = NULL;
2804−
2805− return rc;
2802+ return selinux_add_opt(opt, param->string, &fc->security);
28062803 }
28072804
28082805 /* inode security operations */