Skip to contentSkip to conversation

libsepol/cil: fix NULL pointer dereference in cil_fill_ipaddr

PATCH In review lutianxiong 3 participants 3 messages Feb 25, 2021 – Feb 28, 2021 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libsepol/cil: fix NULL pointer dereference in cil_fill_ipaddr

Found a NULL pointer dereference by fuzzing, reproducing:

    $ echo "(nodecon(())o(e()))" > tmp.cil
    $ secilc tmp.cil
    Segmentation fault (core dumped)

Add NULL check for addr_node->data in cil_fill_ipaddr.

---
 libsepol/cil/src/cil_build_ast.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
libsepol/cil/src/cil_build_ast.c +1 -1
index 726f46c..4e53f06 100644
@@ -5660,7 +5660,7 @@ int cil_fill_ipaddr(struct cil_tree_node *addr_node, struct cil_ipaddr *addr)
 {
 	int rc = SEPOL_ERR;
 
-	if (addr_node == NULL || addr == NULL) {
+	if (addr_node == NULL || addr_node->data == NULL || addr == NULL) {
 		goto exit;
 	}
 
Signature · 1 line
2.23.0
Acked-by on v1 1/1
#1 lore raw
Quoted 9 lines · lutianxiong

Found a NULL pointer dereference by fuzzing, reproducing:

    $ echo "(nodecon(())o(e()))" > tmp.cil
    $ secilc tmp.cil
    Segmentation fault (core dumped)

Add NULL check for addr_node->data in cil_fill_ipaddr.

Quoted 20 lines
---
 libsepol/cil/src/cil_build_ast.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
libsepol/cil/src/cil_build_ast.c +1 -2
index 726f46c..4e53f06 100644
@@ -5660,7 +5660,7 @@ int cil_fill_ipaddr(struct cil_tree_node *addr_node, struct cil_ipaddr *addr)
 {
        int rc = SEPOL_ERR;
 
-       if (addr_node == NULL || addr == NULL) {
+       if (addr_node == NULL || addr_node->data == NULL || addr == NULL) {
                goto exit;
        }
 
--

2.23.0

#2 lore raw
Quoted 8 lines · James Carter
Quoted 6 lines · lutianxiong

Found a NULL pointer dereference by fuzzing, reproducing:

    $ echo "(nodecon(())o(e()))" > tmp.cil
    $ secilc tmp.cil
    Segmentation fault (core dumped)
Quoted 5 lines
Quoted 3 lines

Add NULL check for addr_node->data in cil_fill_ipaddr.

Merged. Thanks!
Nicolas

Quoted 20 lines
Quoted 20 lines
---
 libsepol/cil/src/cil_build_ast.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
libsepol/cil/src/cil_build_ast.c +1 -2
index 726f46c..4e53f06 100644
@@ -5660,7 +5660,7 @@ int cil_fill_ipaddr(struct cil_tree_node *addr_node, struct cil_ipaddr *addr)
 {
        int rc = SEPOL_ERR;
 
-       if (addr_node == NULL || addr == NULL) {
+       if (addr_node == NULL || addr_node->data == NULL || addr == NULL) {
                goto exit;
        }
 
--

2.23.0