Skip to contentSkip to conversation

checkpolicy-fuzzer: do not abort on invalid policies or other errors during conversion

PATCH In review Stephen Smalley 1 participant 3 messages Aug 24 – Aug 25 SELinux security module

lore
Share & tools
lore

Stephen Smalley

author maintainer
#0 lore raw

PATCH 1/1 checkpolicy-fuzzer: do not abort on invalid policies or other errors during conversion

The purpose of the fuzzer is to detect crashes on the fuzzer inputs, not to detect invalid policies or other conversion errors. checkpolicy itself does not call policydb_validate() before writing the binary policy, so an error at that point is not a checkpolicy failure.

---
This was motivated by https://issues.oss-fuzz.com/issues/550672317
which is aborting on policydb_validate() error. I am not entirely clear on exactly how that is happening but I don't think it is what we want from the fuzzer.

 checkpolicy/fuzz/checkpolicy-fuzzer.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
checkpolicy/fuzz/checkpolicy-fuzzer.c +5 -5
index 401f24e3..9fa0bd6c 100644
@@ -250,26 +250,26 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
 
 	if (policydb_validate(NULL, finalpolicydb))
 		/* never generate an invalid policy */
-		abort();
+		goto exit;
 
 	devnull = fopen("/dev/null", "we");
 	if (devnull == NULL)
 		goto exit;
 
 	if (write_binary_policy(devnull, finalpolicydb))
-		abort();
+		goto exit;
 
 	if (finalpolicydb->policy_type == POLICY_KERN &&
 	    sepol_kernel_policydb_to_conf(devnull, finalpolicydb))
-		abort();
+		goto exit;
 
 	if (finalpolicydb->policy_type == POLICY_KERN &&
 	    sepol_kernel_policydb_to_cil(devnull, finalpolicydb))
-		abort();
+		goto exit;
 
 	if (finalpolicydb->policy_type == POLICY_MOD &&
 	    sepol_module_policydb_to_cil(devnull, finalpolicydb, /*linked=*/0))
-		abort();
+		goto exit;
 
 exit:
 	if (devnull != NULL)
Signature · 1 line
2.55.0
author maintainer
#1 lore raw
Quoted 7 lines · Stephen Smalley

The purpose of the fuzzer is to detect crashes on the fuzzer inputs, not to detect invalid policies or other conversion errors. checkpolicy itself does not call policydb_validate() before writing the binary policy, so an error at that point is not a checkpolicy failure.

Quoted 6 lines

---
This was motivated by https://issues.oss-fuzz.com/issues/550672317
which is aborting on policydb_validate() error. I am not entirely clear on exactly how that is happening but I don't think it is what we want from the fuzzer.

NAK'ing my own patch - we likely need to figure out why policydb_validate() is failing here and maybe checkpolicy, checkmodule, and secilc should all be calling it?

author maintainer
#2 lore raw
Quoted 17 lines · Stephen Smalley
Quoted 7 lines · Stephen Smalley

The purpose of the fuzzer is to detect crashes on the fuzzer inputs, not to detect invalid policies or other conversion errors. checkpolicy itself does not call policydb_validate() before writing the binary policy, so an error at that point is not a checkpolicy failure.

Quoted 6 lines

---
This was motivated by https://issues.oss-fuzz.com/issues/550672317
which is aborting on policydb_validate() error. I am not entirely clear on exactly how that is happening but I don't think it is what we want from the fuzzer.

Quoted 3 lines

NAK'ing my own patch - we likely need to figure out why policydb_validate() is failing here and maybe checkpolicy, checkmodule, and secilc should all be calling it?

Root cause for this oss-fuzz report found and fixed via:
https://lore.kernel.org/selinux/[email protected]/T/#u