libsepol/fuzz: Exercise module to CIL code when fuzzing
PATCH 1/1 libsepol/fuzz: Exercise module to CIL code when fuzzing
When fuzzing a kernel policy both sepol_kernel_policydb_to_conf() and sepol_kernel_policydb_to_cil() are called to test those parts of the code base. Call sepol_module_policydb_to_cil() for base and module policies to test that part of the code base.
--- libsepol/fuzz/binpolicy-fuzzer.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
libsepol/fuzz/binpolicy-fuzzer.c +5 -1
@@ -72,8 +72,12 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)if (sepol_kernel_policydb_to_cil (devnull, &policydb))abort (); + }else { +if (sepol_module_policydb_to_cil (devnull, &policydb,0 )) +abort (); + } - }else if (policydb.policy_type ==POLICY_BASE ) { +if (policydb.policy_type ==POLICY_BASE ) {if (link_modules (NULL , &policydb,NULL ,0 ,VERBOSE )) goto exit;
Signature · 1 line
2.55.0
Stephen Smalley
maintainerQuoted 16 lines · James Carter
When fuzzing a kernel policy both
sepol_kernel_policydb_to_conf()andsepol_kernel_policydb_to_cil()are called to test those parts of the code base. Callsepol_module_policydb_to_cil()for base and module policies to test that part of the code base.Signed-off-by James Carter <[email protected]>--- libsepol/fuzz/binpolicy-fuzzer.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)libsepol/fuzz/binpolicy-fuzzer.c +0
-0
libsepol/fuzz/binpolicy-fuzzer.c int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) · line 78
Quoted 7 lines
libsepol/fuzz/binpolicy-fuzzer.c +4
-0@@ -72,8 +72,12 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)if (sepol_kernel_policydb_to_cil (devnull, &policydb))abort (); + }else { +if (sepol_module_policydb_to_cil (devnull, &policydb,0 )) +abort (); + }
Missing #include <sepol/module_to_cil.h> which breaks ./scripts/oss-fuzz.sh:libsepol/fuzz/binpolicy-fuzzer.c:76:7: error: call to undeclared function
'sepol_module_policydb_to_cil'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
76 | if (sepol_module_policydb_to_cil(devnull, &policydb, 0))
| ^libsepol/fuzz/binpolicy-fuzzer.c:76:7: note: did you mean
'sepol_kernel_policydb_to_cil'?
/DESTDIR/usr/include/sepol/kernel_to_cil.h:5:5: note:
'sepol_kernel_policydb_to_cil' declared here
5 | int sepol_kernel_policydb_to_cil(FILE *out, struct policydb *pdb);
| ^