libsepol/fuzz: Validate output of expand_module() before proceeding
PATCH 1/1 libsepol/fuzz: Validate output of expand_module() before proceeding
When creating actual policies the output of expand_module() is written to disk. Converting that policy to CIL or performing other operations on it will require it to be read by policydb_read() which calls policydb_validate(). The fuzzer is not validating the policy, so it is reporting bugs that would be caught by validation.
Have the fuzzer call policydb_validate() after expanding modules so it will not report bugs that are caught by validation.
--- libsepol/fuzz/binpolicy-fuzzer.c | 3 +++ 1 file changed, 3 insertions(+)
libsepol/fuzz/binpolicy-fuzzer.c +3 -0
@@ -88,6 +88,9 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) /*check_assertions=*/0)) goto exit; +if (policydb_validate (NULL , &out)) + goto exit; + (void )check_assertions (NULL , &out, out.global->branch_list->avrules); (void )hierarchy_check_constraints (NULL , &out);
Signature · 1 line
2.55.0
Quoted 11 lines · James Carter
When creating actual policies the output of
expand_module()is written to disk. Converting that policy to CIL or performing other operations on it will require it to be read bypolicydb_read()which callspolicydb_validate(). The fuzzer is not validating the policy, so it is reporting bugs that would be caught by validation.Have the fuzzer call
policydb_validate()after expanding modules so it will not report bugs that are caught by validation.Signed-off-by James Carter <[email protected]>
Quoted 21 lines
--- libsepol/fuzz/binpolicy-fuzzer.c | 3 +++ 1 file changed, 3 insertions(+)libsepol/fuzz/binpolicy-fuzzer.c +3
-1@@ -88,6 +88,9 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) /*check_assertions=*/0)) goto exit; +if (policydb_validate (NULL , &out)) + goto exit; + (void )check_assertions (NULL , &out, out.global->branch_list->avrules); (void )hierarchy_check_constraints (NULL , &out); --2.55.0
Stephen Smalley
maintainerQuoted 9 lines · Stephen Smalley
Quoted 7 lines · James Carter
When creating actual policies the output of
expand_module()is written to disk. Converting that policy to CIL or performing other operations on it will require it to be read bypolicydb_read()which callspolicydb_validate(). The fuzzer is not validating the policy, so it is reporting bugs that would be caught by validation.
Quoted 6 lines
Quoted 4 lines
Have the fuzzer call
policydb_validate()after expanding modules so it will not report bugs that are caught by validation.Signed-off-by James Carter <[email protected]>Acked-by Stephen Smalley <[email protected]>
Merged.