|
|
212ad1 |
From 7cb30b316eda0b2aa8adeaba28a8afe15fc58c28 Mon Sep 17 00:00:00 2001
|
|
|
212ad1 |
From: Nicolas Iooss <nicolas.iooss@m4x.org>
|
|
|
212ad1 |
Date: Sun, 14 Mar 2021 19:25:58 +0100
|
|
|
212ad1 |
Subject: [PATCH] libsepol/cil: fix NULL pointer dereference in
|
|
|
212ad1 |
__cil_insert_name
|
|
|
212ad1 |
|
|
|
212ad1 |
OSS-Fuzz found a Null-dereference in __cil_insert_name when trying to
|
|
|
212ad1 |
compile the following policy:
|
|
|
212ad1 |
|
|
|
212ad1 |
(macro MACRO ()
|
|
|
212ad1 |
(classmap CLASS (PERM))
|
|
|
212ad1 |
(type TYPE)
|
|
|
212ad1 |
(typetransition TYPE TYPE CLASS "name" TYPE)
|
|
|
212ad1 |
)
|
|
|
212ad1 |
(call MACRO)
|
|
|
212ad1 |
|
|
|
212ad1 |
When using a macro with no argument, macro->params is NULL and
|
|
|
212ad1 |
cil_list_for_each(item, macro->params) dereferenced a NULL pointer.
|
|
|
212ad1 |
Fix this by checking that macro->params is not NULL before using it.
|
|
|
212ad1 |
|
|
|
212ad1 |
Fixes: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=28565
|
|
|
212ad1 |
Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
|
|
|
212ad1 |
---
|
|
|
212ad1 |
libsepol/cil/src/cil_resolve_ast.c | 2 +-
|
|
|
212ad1 |
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
|
212ad1 |
|
|
|
212ad1 |
diff --git a/libsepol/cil/src/cil_resolve_ast.c b/libsepol/cil/src/cil_resolve_ast.c
|
|
|
212ad1 |
index ae334620..91e08633 100644
|
|
|
212ad1 |
--- a/libsepol/cil/src/cil_resolve_ast.c
|
|
|
212ad1 |
+++ b/libsepol/cil/src/cil_resolve_ast.c
|
|
|
212ad1 |
@@ -82,7 +82,7 @@ static struct cil_name * __cil_insert_name(struct cil_db *db, hashtab_key_t key,
|
|
|
212ad1 |
} else if (parent->flavor == CIL_MACRO) {
|
|
|
212ad1 |
macro = parent->data;
|
|
|
212ad1 |
}
|
|
|
212ad1 |
- if (macro != NULL) {
|
|
|
212ad1 |
+ if (macro != NULL && macro->params != NULL) {
|
|
|
212ad1 |
struct cil_list_item *item;
|
|
|
212ad1 |
cil_list_for_each(item, macro->params) {
|
|
|
212ad1 |
if (((struct cil_param*)item->data)->str == key) {
|
|
|
212ad1 |
--
|
|
|
212ad1 |
2.30.2
|
|
|
212ad1 |
|