Skip to content

Commit 551007a

Browse files
committed
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
2 parents 25b20ae + 186edf7 commit 551007a

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

security/selinux/ss/conditional.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,8 @@ static void cond_list_destroy(struct policydb *p)
152152
for (i = 0; i < p->cond_list_len; i++)
153153
cond_node_destroy(&p->cond_list[i]);
154154
kfree(p->cond_list);
155+
p->cond_list = NULL;
156+
p->cond_list_len = 0;
155157
}
156158

157159
void cond_policydb_destroy(struct policydb *p)
@@ -441,7 +443,6 @@ int cond_read_list(struct policydb *p, void *fp)
441443
return 0;
442444
err:
443445
cond_list_destroy(p);
444-
p->cond_list = NULL;
445446
return rc;
446447
}
447448

0 commit comments

Comments
 (0)