mirror of
https://github.com/SELinuxProject/selinux
synced 2025-01-05 04:59:42 +00:00
b320291888
When __cil_validate_constrain_expr() fails, cil_constrain_to_policydb_helper() does not destroy the constraint expression. This leads to a memory leak reported by OSS-Fuzz with the following CIL policy: (class CLASS (PERM)) (classorder (CLASS)) (sid SID) (sidorder (SID)) (user USER) (role ROLE) (type TYPE) (category CAT) (categoryorder (CAT)) (sensitivity SENS) (sensitivityorder (SENS)) (sensitivitycategory SENS (CAT)) (allow TYPE self (CLASS (PERM))) (roletype ROLE TYPE) (userrole USER ROLE) (userlevel USER (SENS)) (userrange USER ((SENS)(SENS (CAT)))) (sidcontext SID (USER ROLE TYPE ((SENS)(SENS)))) (constrain (CLASS (PERM)) (or (eq t1 TYPE) (or (eq t1 TYPE) (or (eq t1 TYPE) (or (eq t1 TYPE) (or (eq t1 TYPE) (eq t1 TYPE) ) ) ) ) ) ) Add constraint_expr_destroy(sepol_expr) to destroy the expression. Moreover constraint_expr_destroy() was not freeing all items of an expression. Code in libsepol/src and checkpolicy contained while loop to free all the items of a constraint expression, but not the one in libsepol/cil. As freeing only the first item of an expression is misleading, change the semantic of constraint_expr_destroy() to iterate the list of constraint_expr_t and to free all items. Fixes: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=28938 Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org> Acked-by: James Carter <jwcart2@gmail.com> |
||
---|---|---|
.. | ||
cil | ||
include | ||
man | ||
src | ||
tests | ||
utils | ||
.gitignore | ||
COPYING | ||
Makefile | ||
VERSION |