Commit 551007a8 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'selinux-pr-20220203' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/selinux

Pull selinux fix from Paul Moore:
 "One small SELinux patch to ensure that a policy structure field is
  properly reset after freeing so that we don't inadvertently do a
  double-free on certain error conditions"

* tag 'selinux-pr-20220203' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/selinux:
  selinux: fix double free of cond_list on error paths
parents 25b20ae8 186edf7e
...@@ -152,6 +152,8 @@ static void cond_list_destroy(struct policydb *p) ...@@ -152,6 +152,8 @@ static void cond_list_destroy(struct policydb *p)
for (i = 0; i < p->cond_list_len; i++) for (i = 0; i < p->cond_list_len; i++)
cond_node_destroy(&p->cond_list[i]); cond_node_destroy(&p->cond_list[i]);
kfree(p->cond_list); kfree(p->cond_list);
p->cond_list = NULL;
p->cond_list_len = 0;
} }
void cond_policydb_destroy(struct policydb *p) void cond_policydb_destroy(struct policydb *p)
...@@ -441,7 +443,6 @@ int cond_read_list(struct policydb *p, void *fp) ...@@ -441,7 +443,6 @@ int cond_read_list(struct policydb *p, void *fp)
return 0; return 0;
err: err:
cond_list_destroy(p); cond_list_destroy(p);
p->cond_list = NULL;
return rc; return rc;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment