瀏覽代碼

Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security

Pull selinux fix from James Morris:
 "Fix for a double free bug in SELinux"

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security:
  selinux: fix double free in selinux_parse_opts_str()
Linus Torvalds 8 年之前
父節點
當前提交
550ad8ef39
共有 1 個文件被更改,包括 2 次插入3 次删除
  1. 2 3
      security/selinux/hooks.c

+ 2 - 3
security/selinux/hooks.c

@@ -1106,10 +1106,8 @@ static int selinux_parse_opts_str(char *options,
 
 
 	opts->mnt_opts_flags = kcalloc(NUM_SEL_MNT_OPTS, sizeof(int),
 	opts->mnt_opts_flags = kcalloc(NUM_SEL_MNT_OPTS, sizeof(int),
 				       GFP_KERNEL);
 				       GFP_KERNEL);
-	if (!opts->mnt_opts_flags) {
-		kfree(opts->mnt_opts);
+	if (!opts->mnt_opts_flags)
 		goto out_err;
 		goto out_err;
-	}
 
 
 	if (fscontext) {
 	if (fscontext) {
 		opts->mnt_opts[num_mnt_opts] = fscontext;
 		opts->mnt_opts[num_mnt_opts] = fscontext;
@@ -1132,6 +1130,7 @@ static int selinux_parse_opts_str(char *options,
 	return 0;
 	return 0;
 
 
 out_err:
 out_err:
+	security_free_mnt_opts(opts);
 	kfree(context);
 	kfree(context);
 	kfree(defcontext);
 	kfree(defcontext);
 	kfree(fscontext);
 	kfree(fscontext);