libsepol: add fuzzer for reading binary policies
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v3 Latest36 patches 3 repliesIn review
- v2 RFC36 patches 6 repliesSuperseded
- v1 RFC35 patches 12 repliesSuperseded
Changes in v3 from the cover letter
- Drop RFC status
- [10] libsepol: add checks for read sizes
use PERM_SYMTAB_SIZE instead of bare 32 as limit
- [11] libsepol: enforce avtab item limit
take zero based numbering of variable items into account
- [30] libsepol: validate ocontexts
only check FS and NETIF ocons in selinux policies (not xen)
Patches in v3 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/36 | cifuzz: enable report-unreproducible-crashes.github/ | +1 | 0 replies | |
| 2/36 | cifuzz: use the default runtime of 600 seconds.github/ | +1 | 0 replies | |
| 3/36 | libsepol/fuzz: silence secilc-fuzzerlibsepol/ | +5 | 0 replies | |
| 4/36 | libsepol: add libfuzz based fuzzer for reading binary policieslibsepol/ libsepol/ scripts/ | +78 | 0 replies | |
| 5/36 | libsepol/fuzz: limit element sizes for fuzzinglibsepol/ | +6 | 0 replies | |
| 6/36 | libsepol: use logging framework in conditional.clibsepol/ | +11 | 0 replies | |
| 7/36 | libsepol: use logging framework in ebitmap.clibsepol/ | +10 | 0 replies | |
| 8/36 | libsepol: use mallocarray wrapper to avoid overflowslibsepol/ libsepol/ libsepol/ +10 more | +36 | 0 replies | |
| 9/36 | libsepol: use reallocarray wrapper to avoid overflowslibsepol/ libsepol/ libsepol/ +6 more | +46 | 0 replies | |
| 10/36 | libsepol: add checks for read sizeslibsepol/ | +9 | 0 replies | |
| 11/36 | libsepol: enforce avtab item limitlibsepol/ | +6 | 1 reply | |
| 12/36 | libsepol: clean memory on conditional insertion failurelibsepol/ | +9 | 0 replies | |
| 13/36 | libsepol: reject abnormal huge sid idslibsepol/ | +4 | 0 replies | |
| 14/36 | libsepol: reject invalid filetrans source typelibsepol/ | +4 | 0 replies | |
| 15/36 | libsepol: zero member before potential dereferencelibsepol/ | +1 | 0 replies | |
| 16/36 | libsepol: use size_t for indexes in strs helperslibsepol/ libsepol/ | +6 | 0 replies | |
| 17/36 | libsepol: do not underflow on short format argumentslibsepol/ | +3 | 0 replies | |
| 18/36 | libsepol: do not crash on class gapslibsepol/ libsepol/ | +17 | 0 replies | |
| 19/36 | libsepol: do not crash on user gapslibsepol/ libsepol/ | +2 | 0 replies | |
| 20/36 | libsepol: use correct size for initial string listlibsepol/ | +1 | 0 replies | |
| 21/36 | libsepol: do not create a string list with initial size zerolibsepol/ | +5 | 0 replies | |
| 22/36 | libsepol: split validation of datum array gaps and entrieslibsepol/ | +73 | 0 replies | |
| 23/36 | libsepol: validate MLS levelslibsepol/ | +24 | 0 replies | |
| 24/36 | libsepol: validate expanded user range and levellibsepol/ | +19 | 0 replies | |
| 25/36 | libsepol: validate permission count of classeslibsepol/ | +24 | 0 replies | |
| 26/36 | libsepol: resolve log message mismatchlibsepol/ | +1 | 0 replies | |
| 27/36 | libsepol: validate avtab and avrule typeslibsepol/ | +31 | 0 replies | |
| 28/36 | libsepol: validate constraint expression operators and attributeslibsepol/ | +43 | 0 replies | |
| 29/36 | libsepol: validate type of avtab type ruleslibsepol/ | +10 | 0 replies | |
| 30/36 | libsepol: validate ocontextslibsepol/ | +46 | 0 replies | |
| 31/36 | libsepol: validate genfs contextslibsepol/ | +22 | 0 replies | |
| 32/36 | libsepol: validate permissive typeslibsepol/ | +20 | 0 replies | |
| 33/36 | libsepol: validate policy propertieslibsepol/ | +51 | 0 replies | |
| 34/36 | libsepol: validate categorieslibsepol/ | +11 | 0 replies | |
| 35/36 | libsepol: validate fsuse typeslibsepol/ | +10 | 0 replies | |
| 36/36 | libsepol: validate class default targetslibsepol/ | +41 | 0 replies |
Reviews trailers per patch
None of the 36 patches has a Reviewed-by or Acked-by of their own; the series has one for all of them.
| Patch | James Carter |
|---|---|
| Series | A-b |
| 1/36 | |
| 2/36 | |
| 3/36 | |
| 4/36 | |
| 5/36 | |
| 6/36 | |
| 7/36 | |
| 8/36 | |
| 9/36 | |
| 10/36 | |
| 11/36 | |
| 12/36 | |
| 13/36 | |
| 14/36 | |
| 15/36 | |
| 16/36 | |
| 17/36 | |
| 18/36 | |
| 19/36 | |
| 20/36 | |
| 21/36 | |
| 22/36 | |
| 23/36 | |
| 24/36 | |
| 25/36 | |
| 26/36 | |
| 27/36 | |
| 28/36 | |
| 29/36 | |
| 30/36 | |
| 31/36 | |
| 32/36 | |
| 33/36 | |
| 34/36 | |
| 35/36 | |
| 36/36 |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH v3 00/36] libsepol: add fuzzer for reading binary policies
Add a libfuzz[1] based fuzzer testing the reading and parsing of binary policy files. This fuzzer will be run within the OSS-Fuzz service.
Handle and reject a variety of edge cases causing crashes or resource leaks.
The fifth patch ("libsepol/fuzz: limit element sizes for fuzzing") limits, to avoid oom reports from the fuzzer, caused by huge memory allocations, all identifiers to a length of 2^16 for the fuzzer build only.
A potential limit for the release build needs further discussion.
[1]: https://llvm.org/docs/LibFuzzer.html
v3:
- Drop RFC status
- [10] libsepol: add checks for read sizes
use PERM_SYMTAB_SIZE instead of bare 32 as limit
- [11] libsepol: enforce avtab item limit
take zero based numbering of variable items into account
- [30] libsepol: validate ocontexts
only check FS and NETIF ocons in selinux policies (not xen)
v2:
- reorder patches
1. oss-fuzz related
2. libsepol parsing and other crashesand UB
3. enhance policy validation
- misc changes based on review by James Carter
Christian Göttsche (36):
cifuzz: enable report-unreproducible-crashes
cifuzz: use the default runtime of 600 seconds libsepol/fuzz: silence secilc-fuzzer
libsepol: add libfuzz based fuzzer for reading binary policies libsepol/fuzz: limit element sizes for fuzzing
libsepol: use logging framework in conditional.c
libsepol: use logging framework in ebitmap.c
libsepol: use mallocarray wrapper to avoid overflows
libsepol: use reallocarray wrapper to avoid overflows
libsepol: add checks for read sizes
libsepol: enforce avtab item limit
libsepol: clean memory on conditional insertion failure
libsepol: reject abnormal huge sid ids
libsepol: reject invalid filetrans source type
libsepol: zero member before potential dereference
libsepol: use size_t for indexes in strs helpers
libsepol: do not underflow on short format arguments
libsepol: do not crash on class gaps
libsepol: do not crash on user gaps
libsepol: use correct size for initial string list
libsepol: do not create a string list with initial size zero
libsepol: split validation of datum array gaps and entries
libsepol: validate MLS levels
libsepol: validate expanded user range and level
libsepol: validate permission count of classes
libsepol: resolve log message mismatch
libsepol: validate avtab and avrule types
libsepol: validate constraint expression operators and attributes
libsepol: validate type of avtab type rules
libsepol: validate ocontexts
libsepol: validate genfs contexts
libsepol: validate permissive types
libsepol: validate policy properties
libsepol: validate categories
libsepol: validate fsuse types
libsepol: validate class default targets
.github/workflows/cifuzz.yml | 3 +- libsepol/fuzz/binpolicy-fuzzer.c | 63 ++++ libsepol/fuzz/policy.bin | Bin 0 -> 1552 bytes libsepol/fuzz/secilc-fuzzer.c | 5 + libsepol/src/Makefile | 6 + libsepol/src/avtab.c | 6 + libsepol/src/conditional.c | 53 ++-- libsepol/src/ebitmap.c | 27 +- libsepol/src/expand.c | 4 +- libsepol/src/hashtab.c | 4 +- libsepol/src/kernel_to_cil.c | 10 + libsepol/src/kernel_to_common.c | 23 +- libsepol/src/kernel_to_common.h | 4 +- libsepol/src/kernel_to_conf.c | 13 +- libsepol/src/link.c | 3 +- libsepol/src/module.c | 4 +- libsepol/src/module_to_cil.c | 13 +- libsepol/src/optimize.c | 11 +- libsepol/src/policydb.c | 27 +- libsepol/src/policydb_validate.c | 477 +++++++++++++++++++++++++++---- libsepol/src/private.h | 27 +- libsepol/src/services.c | 12 +- libsepol/src/sidtab.c | 3 +- libsepol/src/user_record.c | 8 +- libsepol/src/users.c | 12 +- libsepol/src/util.c | 11 +- libsepol/src/write.c | 2 +- scripts/oss-fuzz.sh | 17 +- 28 files changed, 686 insertions(+), 162 deletions(-) create mode 100644 libsepol/fuzz/binpolicy-fuzzer.c create mode 100644 libsepol/fuzz/policy.bin
Signature · 1 line
2.34.1