ubpf icon indicating copy to clipboard operation
ubpf copied to clipboard

Add libfuzzer based test with

Open Alan-Jowett opened this issue 9 months ago • 1 comments

This pull request introduces fuzzing capabilities to the project, including a new GitHub Actions workflow, and modifies the project's build system to support fuzzing. The most significant changes include the addition of the fuzzing.yml workflow, the introduction of a new ubpf_fuzzer executable, and the modification of the ubpf_vm structure to include an instruction limit.

New GitHub Actions workflow:

  • .github/workflows/fuzzing.yml: Added a new workflow to perform fuzzing. This workflow includes steps to build the project with fuzzing enabled, run the fuzzer, and upload any found artifacts.

Modifications to existing GitHub Actions workflow:

  • .github/workflows/main.yml: Modified the permissions field to have write access to contents, changed the push and pull_request branches to main from *, and added a job to use the new fuzzing.yml workflow. [1] [2] [3]

Changes to build system:

  • CMakeLists.txt, cmake/options.cmake, cmake/settings.cmake: Added options to enable libfuzzer and coverage, and set compiler flags accordingly. [1] [2] [3]

New fuzzer executable:

  • libfuzzer/CMakeLists.txt, libfuzzer/libfuzz_harness.cc: Added a new executable ubpf_fuzzer that is built when fuzzing is enabled. This executable uses libfuzzer to fuzz the uBPF virtual machine. [1] [2]

Modifications to uBPF VM:

  • vm/inc/ubpf.h, vm/ubpf_int.h, vm/ubpf_vm.c: Modified the ubpf_vm structure to include an instruction limit, added a method to set this limit, and modified the ubpf_exec function to respect this limit. Also, the bounds check function was updated for better error handling and reporting. [1] [2] [3] [4] [5] [6]

Alan-Jowett avatar May 05 '24 23:05 Alan-Jowett

Coverage Status

coverage: 81.235%. first build when pulling 0d4af149b4ee4ca9faa55669a98587f0aaa64b08 on Alan-Jowett:fuzz_test into 664410c775c5a42ec5fb2e51c4523797382bd3d2 on iovisor:main.

coveralls avatar May 06 '24 17:05 coveralls