Spdk/test/nvmf/target
Jim Harris fcff455365 test/nvmf: fuzz nvmf target using LLVM's libFuzzer
LLVM provides libFuzzer which does coverage-guided
fuzzing of a library or application under test.  For
SPDK, we can use this as a new and better way to
generate random commands to the SPDK nvmf target.

By default, libFuzzer provides the main() and your
source file just provides the function called by
LLVM for each iteration of random data.  But this
doesn't really work for SPDK since we need to start
the app framework and the nvmf target.  So we
specify -fsanitizer=fuzzer-no-link, explicitly
specify the location of the fuzzer_no_main library
and then call LLVMFuzzerRunDriver to start the
fuzzing process once we are ready.

Since this is all coverage-guided, we invoke the
fuzzer inside the nvmf target application.  So this
patch creates a new target application called
'llvm_nvme_fuzz'. One core is needed to run the
nvmf target, then we spawn a pthread to run the
fuzzer against it.

Currently there are two fuzzers defined.  Fuzzer 0
does random testing of admin commands.  Fuzzer 1
is focused solely on GET_LOG_PAGE and fuzzes a
smaller subset of the bytes in the spdk_nvme_cmd.

Additional fuzzers can be added in the future for
other commands, testing I/O queues, data payloads,
etc.

You do need to specify CC and CXX when running
configure, as well as specify the location of the
special clang_rt.fuzz_no_main library. The path of
that library is dependent on your clang version and
architecture. If using clang-12 on x86_64 platform,
it will look like:

CC=clang-12 CXX=clang++-12 ./configure --with-fuzzer= \
  /usr/lib/llvm-12/lib/clang/12.0.0/lib/linux/libclang_rt.fuzzer_no_main-x86_64.a

Then just do the following to demonstrate the fuzzer
tool.

make
test/nvmf/target/llvm_nvme_fuzz.sh --time=60 --fuzzer=0

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: Iee0997501893ac284a3947a1db7a155c5ceb7849
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/10038
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2022-06-30 13:32:29 -04:00
..
abort.sh logs: create a log level flag in abort and hotplug applications 2022-06-30 13:32:29 -04:00
bdev_io_wait.sh test/nvmf: Handle multiple arguments in nvmfappstart() 2020-05-13 07:46:04 +00:00
bdevio.sh test/nvmf: Handle multiple arguments in nvmfappstart() 2020-05-13 07:46:04 +00:00
connect_disconnect.sh test/nvmf: Handle multiple arguments in nvmfappstart() 2020-05-13 07:46:04 +00:00
connect_stress.sh test: add connect_stress test 2021-07-19 13:50:29 +00:00
create_transport.sh test/nvmf: Handle multiple arguments in nvmfappstart() 2020-05-13 07:46:04 +00:00
delete_subsystem.sh spelling: test 2022-06-30 13:32:28 -04:00
dif.sh test/nvmf: use recommended nvmf_create_subsystem rpc 2021-05-20 15:00:22 +00:00
discovery.sh test/nvmf: Handle multiple arguments in nvmfappstart() 2020-05-13 07:46:04 +00:00
fabrics_fuzz.sh test/vfio_user: add vfio-user fuzzing test 2022-06-30 13:32:28 -04:00
filesystem.sh test/nvmf: increase malloc size in filesystem test 2022-06-30 13:32:29 -04:00
fio.sh autotest: Replace fio.py with a bash wrapper in tests 2021-05-12 08:48:10 +00:00
fuzz_json.conf test/nvmf: fuzz nvmf target using LLVM's libFuzzer 2022-06-30 13:32:29 -04:00
host_management.sh nvmf: nvmf_subsystem_remove_host RPC now disconnects hosts 2020-10-22 03:55:57 +00:00
identify_passthru.sh nvmf: The maximum number of namespaces a subsystem may contain must now 2020-12-01 10:20:43 +00:00
initiator_timeout.sh autotest: Replace fio.py with a bash wrapper in tests 2021-05-12 08:48:10 +00:00
invalid.sh spelling: test 2022-06-30 13:32:28 -04:00
llvm_nvme_fuzz.sh test/nvmf: fuzz nvmf target using LLVM's libFuzzer 2022-06-30 13:32:29 -04:00
multiconnection.sh autotest: Replace fio.py with a bash wrapper in tests 2021-05-12 08:48:10 +00:00
multipath.sh spelling: test 2022-06-30 13:32:28 -04:00
multitarget_rpc.py test/nvmf: test the new nvmf RPCs. 2019-09-26 15:21:44 +00:00
multitarget.sh test/nvmf: Handle multiple arguments in nvmfappstart() 2020-05-13 07:46:04 +00:00
nmic.sh autotest: Replace fio.py with a bash wrapper in tests 2021-05-12 08:48:10 +00:00
ns_hotplug_stress.sh nvmf: do not pause a namespace when resizing 2021-02-22 10:05:11 +00:00
nvme_cli.sh test/nvmf: Simplify get_nvme_devs() 2021-06-04 19:58:56 +00:00
nvmf_example.sh test/nvmf_example: Remove duplicated test code. 2020-12-14 14:34:14 +00:00
nvmf_lvol.sh build: Example applications build to build/example 2020-06-15 15:27:16 +00:00
nvmf_vfio_user.sh nvme/deallocated_value: add vfio-user transport support 2022-06-30 13:32:29 -04:00
nvmf_vhost_fio.job create nvmf+vhost test. 2019-05-21 10:01:50 +00:00
nvmf_vhost.sh check_format: Reformat the Bash code in compliance with shfmt 2020-05-07 20:52:21 +00:00
rpc.sh test/nvmf: reduce number of loops in rpc.sh test 2021-08-20 07:29:25 +00:00
shutdown.sh test/nvmf: only disable test cases in top-level script 2020-07-31 08:21:23 +00:00
srq_overwhelm.sh spelling: test 2022-06-30 13:32:28 -04:00
vfio_user_fuzz.sh test/vfio_user: add vfio-user fuzzing test 2022-06-30 13:32:28 -04:00