All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH 00/35] libsepol: add fuzzer for reading binary policies
@ 2021-10-11 16:24 Christian Göttsche
  2021-10-11 16:24 ` [RFC PATCH 01/35] cifuzz: enable report-unreproducible-crashes Christian Göttsche
                   ` (36 more replies)
  0 siblings, 37 replies; 135+ messages in thread
From: Christian Göttsche @ 2021-10-11 16:24 UTC (permalink / raw)
  To: selinux

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") needs some
discussion: To avoid oom reports from the fuzzer, caused by huge memory
allocations, all identifiers are limited to a length of 2^16 for the fuzzer
build only.  Probably there should be a limit for the release build too.
Is there a specification for the binary policy format saying something about
the maximum length of identifiers?
After a quick look at the kernel sources (most interesting is str_read()) I
could not find any limits either.

[1]: https://llvm.org/docs/LibFuzzer.html

Christian Göttsche (35):
  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 read failure
  libsepol: validate MLS levels
  libsepol: reject invalid fsuse types
  libsepol: reject invalid default targets
  libsepol: validate expanded user range and level
  libsepol: validate types
  libsepol: use size_t for indexes in strs helpers
  libsepol: reject abnormal huge sid ids
  libsepol: do not crash on class gaps
  libsepol: do not crash on user gaps
  libsepol: validate permission count of classes
  libsepol: resolve log message mismatch
  libsepol: zero member before potential dereference
  libsepol: validate avtab 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: do not underflow on short format arguments
  libsepol: validate categories
  libsepol: use correct size for initial string list
  libsepol: do not create a string list with initial size zero

 .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       |  36 ++--
 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          |  68 +++++++-
 libsepol/src/policydb_validate.c | 274 +++++++++++++++++++++++++++++--
 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              |  19 ++-
 28 files changed, 556 insertions(+), 115 deletions(-)
 create mode 100644 libsepol/fuzz/binpolicy-fuzzer.c
 create mode 100644 libsepol/fuzz/policy.bin

-- 
2.33.0


^ permalink raw reply	[flat|nested] 135+ messages in thread

end of thread, other threads:[~2021-12-17 14:00 UTC | newest]

Thread overview: 135+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-11 16:24 [RFC PATCH 00/35] libsepol: add fuzzer for reading binary policies Christian Göttsche
2021-10-11 16:24 ` [RFC PATCH 01/35] cifuzz: enable report-unreproducible-crashes Christian Göttsche
2021-10-11 16:25 ` [RFC PATCH 02/35] cifuzz: use the default runtime of 600 seconds Christian Göttsche
2021-10-11 16:25 ` [RFC PATCH 03/35] libsepol/fuzz: silence secilc-fuzzer Christian Göttsche
2021-10-11 16:25 ` [RFC PATCH 04/35] libsepol: add libfuzz based fuzzer for reading binary policies Christian Göttsche
2021-10-11 16:25 ` [RFC PATCH 05/35] libsepol/fuzz: limit element sizes for fuzzing Christian Göttsche
2021-10-11 16:25 ` [RFC PATCH 06/35] libsepol: use logging framework in conditional.c Christian Göttsche
2021-10-11 16:25 ` [RFC PATCH 07/35] libsepol: use logging framework in ebitmap.c Christian Göttsche
2021-10-11 16:25 ` [RFC PATCH 08/35] libsepol: use mallocarray wrapper to avoid overflows Christian Göttsche
2021-10-11 16:25 ` [RFC PATCH 09/35] libsepol: use reallocarray " Christian Göttsche
2021-10-11 16:25 ` [RFC PATCH 10/35] libsepol: add checks for read sizes Christian Göttsche
2021-10-11 16:25 ` [RFC PATCH 11/35] libsepol: enforce avtab item limit Christian Göttsche
2021-10-11 16:25 ` [RFC PATCH 12/35] libsepol: clean memory on conditional read failure Christian Göttsche
2021-10-13 14:10   ` James Carter
2021-10-11 16:25 ` [RFC PATCH 13/35] libsepol: validate MLS levels Christian Göttsche
2021-10-13 15:38   ` James Carter
2021-10-11 16:25 ` [RFC PATCH 14/35] libsepol: reject invalid fsuse types Christian Göttsche
2021-10-18 19:57   ` James Carter
2021-10-11 16:25 ` [RFC PATCH 15/35] libsepol: reject invalid default targets Christian Göttsche
2021-10-18 19:58   ` James Carter
2021-10-11 16:25 ` [RFC PATCH 16/35] libsepol: validate expanded user range and level Christian Göttsche
2021-10-11 16:25 ` [RFC PATCH 17/35] libsepol: validate types Christian Göttsche
2021-10-13 15:39   ` James Carter
2021-10-11 16:25 ` [RFC PATCH 18/35] libsepol: use size_t for indexes in strs helpers Christian Göttsche
2021-10-11 16:25 ` [RFC PATCH 19/35] libsepol: reject abnormal huge sid ids Christian Göttsche
2021-10-11 16:25 ` [RFC PATCH 20/35] libsepol: do not crash on class gaps Christian Göttsche
2021-10-11 16:25 ` [RFC PATCH 21/35] libsepol: do not crash on user gaps Christian Göttsche
2021-10-11 16:25 ` [RFC PATCH 22/35] libsepol: validate permission count of classes Christian Göttsche
2021-10-13 15:41   ` James Carter
2021-10-11 16:25 ` [RFC PATCH 23/35] libsepol: resolve log message mismatch Christian Göttsche
2021-10-11 16:25 ` [RFC PATCH 24/35] libsepol: zero member before potential dereference Christian Göttsche
2021-10-11 16:25 ` [RFC PATCH 25/35] libsepol: validate avtab types Christian Göttsche
2021-10-18 19:54   ` James Carter
2021-10-11 16:25 ` [RFC PATCH 26/35] libsepol: validate constraint expression operators and attributes Christian Göttsche
2021-10-11 16:25 ` [RFC PATCH 27/35] libsepol: validate type of avtab type rules Christian Göttsche
2021-10-13 15:44   ` James Carter
2021-10-11 16:25 ` [RFC PATCH 28/35] libsepol: validate ocontexts Christian Göttsche
2021-10-14 14:10   ` James Carter
2021-10-11 16:25 ` [RFC PATCH 29/35] libsepol: validate genfs contexts Christian Göttsche
2021-10-14 14:10   ` James Carter
2021-10-11 16:25 ` [RFC PATCH 30/35] libsepol: validate permissive types Christian Göttsche
2021-10-11 16:25 ` [RFC PATCH 31/35] libsepol: validate policy properties Christian Göttsche
2021-10-11 16:25 ` [RFC PATCH 32/35] libsepol: do not underflow on short format arguments Christian Göttsche
2021-10-11 16:25 ` [RFC PATCH 33/35] libsepol: validate categories Christian Göttsche
2021-10-13 15:40   ` James Carter
2021-10-11 16:25 ` [RFC PATCH 34/35] libsepol: use correct size for initial string list Christian Göttsche
2021-10-11 16:25 ` [RFC PATCH 35/35] libsepol: do not create a string list with initial size zero Christian Göttsche
2021-10-13 14:07 ` [RFC PATCH 00/35] libsepol: add fuzzer for reading binary policies James Carter
2021-11-05 15:45 ` [RFC PATCH v2 00/36] " Christian Göttsche
2021-11-05 15:45   ` [RFC PATCH v2 01/36] cifuzz: enable report-unreproducible-crashes Christian Göttsche
2021-11-05 15:45   ` [RFC PATCH v2 02/36] cifuzz: use the default runtime of 600 seconds Christian Göttsche
2021-11-05 15:45   ` [RFC PATCH v2 03/36] libsepol/fuzz: silence secilc-fuzzer Christian Göttsche
2021-11-05 15:45   ` [RFC PATCH v2 04/36] libsepol: add libfuzz based fuzzer for reading binary policies Christian Göttsche
2021-11-05 15:45   ` [RFC PATCH v2 05/36] libsepol/fuzz: limit element sizes for fuzzing Christian Göttsche
2021-11-05 15:45   ` [RFC PATCH v2 06/36] libsepol: use logging framework in conditional.c Christian Göttsche
2021-11-05 15:45   ` [RFC PATCH v2 07/36] libsepol: use logging framework in ebitmap.c Christian Göttsche
2021-11-05 15:45   ` [RFC PATCH v2 08/36] libsepol: use mallocarray wrapper to avoid overflows Christian Göttsche
2021-11-05 15:45   ` [RFC PATCH v2 09/36] libsepol: use reallocarray " Christian Göttsche
2021-11-05 15:45   ` [RFC PATCH v2 10/36] libsepol: add checks for read sizes Christian Göttsche
2021-11-09 18:46     ` James Carter
2021-11-09 18:58       ` Christian Göttsche
2021-11-09 19:17         ` James Carter
2021-11-05 15:45   ` [RFC PATCH v2 11/36] libsepol: enforce avtab item limit Christian Göttsche
2021-11-05 15:45   ` [RFC PATCH v2 12/36] libsepol: clean memory on conditional insertion failure Christian Göttsche
2021-11-05 15:45   ` [RFC PATCH v2 13/36] libsepol: reject abnormal huge sid ids Christian Göttsche
2021-11-05 15:45   ` [RFC PATCH v2 14/36] libsepol: reject invalid filetrans source type Christian Göttsche
2021-11-05 15:45   ` [RFC PATCH v2 15/36] libsepol: zero member before potential dereference Christian Göttsche
2021-11-05 15:45   ` [RFC PATCH v2 16/36] libsepol: use size_t for indexes in strs helpers Christian Göttsche
2021-11-05 15:45   ` [RFC PATCH v2 17/36] libsepol: do not underflow on short format arguments Christian Göttsche
2021-11-05 15:45   ` [RFC PATCH v2 18/36] libsepol: do not crash on class gaps Christian Göttsche
2021-11-05 15:45   ` [RFC PATCH v2 19/36] libsepol: do not crash on user gaps Christian Göttsche
2021-11-05 15:45   ` [RFC PATCH v2 20/36] libsepol: use correct size for initial string list Christian Göttsche
2021-11-05 15:45   ` [RFC PATCH v2 21/36] libsepol: do not create a string list with initial size zero Christian Göttsche
2021-11-05 15:45   ` [RFC PATCH v2 22/36] libsepol: split validation of datum array gaps and entries Christian Göttsche
2021-11-05 15:45   ` [RFC PATCH v2 23/36] libsepol: validate MLS levels Christian Göttsche
2021-11-05 15:45   ` [RFC PATCH v2 24/36] libsepol: validate expanded user range and level Christian Göttsche
2021-11-05 15:45   ` [RFC PATCH v2 25/36] libsepol: validate permission count of classes Christian Göttsche
2021-11-05 15:45   ` [RFC PATCH v2 26/36] libsepol: resolve log message mismatch Christian Göttsche
2021-11-05 15:45   ` [RFC PATCH v2 27/36] libsepol: validate avtab and avrule types Christian Göttsche
2021-11-05 15:45   ` [RFC PATCH v2 28/36] libsepol: validate constraint expression operators and attributes Christian Göttsche
2021-11-05 15:45   ` [RFC PATCH v2 29/36] libsepol: validate type of avtab type rules Christian Göttsche
2021-11-05 15:45   ` [RFC PATCH v2 30/36] libsepol: validate ocontexts Christian Göttsche
2021-11-09 19:04     ` James Carter
2021-11-05 15:45   ` [RFC PATCH v2 31/36] libsepol: validate genfs contexts Christian Göttsche
2021-11-05 15:45   ` [RFC PATCH v2 32/36] libsepol: validate permissive types Christian Göttsche
2021-11-05 15:45   ` [RFC PATCH v2 33/36] libsepol: validate policy properties Christian Göttsche
2021-11-05 15:45   ` [RFC PATCH v2 34/36] libsepol: validate categories Christian Göttsche
2021-11-05 15:45   ` [RFC PATCH v2 35/36] libsepol: validate fsuse types Christian Göttsche
2021-11-05 15:45   ` [RFC PATCH v2 36/36] libsepol: validate class default targets Christian Göttsche
2021-11-05 15:45   ` [RFC PATCH v2 37/40] [WIP] libsepol: export policydb_validate Christian Göttsche
2021-11-05 15:45   ` [RFC PATCH v2 38/40] [WIP] checkpolicy: validate generated policies Christian Göttsche
2021-11-05 15:45   ` [RFC PATCH v2 39/40] [CROSS-PATCH] libsepol: avoid passing NULL pointer to memcpy Christian Göttsche
2021-11-05 15:45   ` [RFC PATCH v2 40/40] [CROSS-PATCH] libsepol: do not pass NULL " Christian Göttsche
2021-11-09 18:42   ` [RFC PATCH v2 00/36] libsepol: add fuzzer for reading binary policies James Carter
2021-11-09 18:43     ` James Carter
2021-12-09 16:48   ` [PATCH v3 " Christian Göttsche
2021-12-09 16:48     ` [PATCH v3 01/36] cifuzz: enable report-unreproducible-crashes Christian Göttsche
2021-12-09 16:48     ` [PATCH v3 02/36] cifuzz: use the default runtime of 600 seconds Christian Göttsche
2021-12-09 16:48     ` [PATCH v3 03/36] libsepol/fuzz: silence secilc-fuzzer Christian Göttsche
2021-12-09 16:48     ` [PATCH v3 04/36] libsepol: add libfuzz based fuzzer for reading binary policies Christian Göttsche
2021-12-09 16:48     ` [PATCH v3 05/36] libsepol/fuzz: limit element sizes for fuzzing Christian Göttsche
2021-12-09 16:48     ` [PATCH v3 06/36] libsepol: use logging framework in conditional.c Christian Göttsche
2021-12-09 16:48     ` [PATCH v3 07/36] libsepol: use logging framework in ebitmap.c Christian Göttsche
2021-12-09 16:49     ` [PATCH v3 08/36] libsepol: use mallocarray wrapper to avoid overflows Christian Göttsche
2021-12-09 16:49     ` [PATCH v3 09/36] libsepol: use reallocarray " Christian Göttsche
2021-12-09 16:49     ` [PATCH v3 10/36] libsepol: add checks for read sizes Christian Göttsche
2021-12-09 16:49     ` [PATCH v3 11/36] libsepol: enforce avtab item limit Christian Göttsche
2021-12-15 17:39       ` James Carter
2021-12-09 16:49     ` [PATCH v3 12/36] libsepol: clean memory on conditional insertion failure Christian Göttsche
2021-12-09 16:49     ` [PATCH v3 13/36] libsepol: reject abnormal huge sid ids Christian Göttsche
2021-12-09 16:49     ` [PATCH v3 14/36] libsepol: reject invalid filetrans source type Christian Göttsche
2021-12-09 16:49     ` [PATCH v3 15/36] libsepol: zero member before potential dereference Christian Göttsche
2021-12-09 16:49     ` [PATCH v3 16/36] libsepol: use size_t for indexes in strs helpers Christian Göttsche
2021-12-09 16:49     ` [PATCH v3 17/36] libsepol: do not underflow on short format arguments Christian Göttsche
2021-12-09 16:49     ` [PATCH v3 18/36] libsepol: do not crash on class gaps Christian Göttsche
2021-12-09 16:49     ` [PATCH v3 19/36] libsepol: do not crash on user gaps Christian Göttsche
2021-12-09 16:49     ` [PATCH v3 20/36] libsepol: use correct size for initial string list Christian Göttsche
2021-12-09 16:49     ` [PATCH v3 21/36] libsepol: do not create a string list with initial size zero Christian Göttsche
2021-12-09 16:49     ` [PATCH v3 22/36] libsepol: split validation of datum array gaps and entries Christian Göttsche
2021-12-09 16:49     ` [PATCH v3 23/36] libsepol: validate MLS levels Christian Göttsche
2021-12-09 16:49     ` [PATCH v3 24/36] libsepol: validate expanded user range and level Christian Göttsche
2021-12-09 16:49     ` [PATCH v3 25/36] libsepol: validate permission count of classes Christian Göttsche
2021-12-09 16:49     ` [PATCH v3 26/36] libsepol: resolve log message mismatch Christian Göttsche
2021-12-09 16:49     ` [PATCH v3 27/36] libsepol: validate avtab and avrule types Christian Göttsche
2021-12-09 16:49     ` [PATCH v3 28/36] libsepol: validate constraint expression operators and attributes Christian Göttsche
2021-12-09 16:49     ` [PATCH v3 29/36] libsepol: validate type of avtab type rules Christian Göttsche
2021-12-09 16:49     ` [PATCH v3 30/36] libsepol: validate ocontexts Christian Göttsche
2021-12-09 16:49     ` [PATCH v3 31/36] libsepol: validate genfs contexts Christian Göttsche
2021-12-09 16:49     ` [PATCH v3 32/36] libsepol: validate permissive types Christian Göttsche
2021-12-09 16:49     ` [PATCH v3 33/36] libsepol: validate policy properties Christian Göttsche
2021-12-09 16:49     ` [PATCH v3 34/36] libsepol: validate categories Christian Göttsche
2021-12-09 16:49     ` [PATCH v3 35/36] libsepol: validate fsuse types Christian Göttsche
2021-12-09 16:49     ` [PATCH v3 36/36] libsepol: validate class default targets Christian Göttsche
2021-12-15 17:41     ` [PATCH v3 00/36] libsepol: add fuzzer for reading binary policies James Carter
2021-12-17 13:59       ` James Carter

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.