selftests/bpf: Add verifier test for release_reference()
authorYoulin Li <liulin063@gmail.com>
Thu, 3 Nov 2022 09:34:40 +0000 (17:34 +0800)
committerDaniel Borkmann <daniel@iogearbox.net>
Thu, 3 Nov 2022 23:24:29 +0000 (00:24 +0100)
commit475244f5e06beeda7b557d9dde46a5f439bf3379
treebd6a4cb8ea564282be843971485e78babdc8016b
parentf1db20814af532f85e091231223e5e4818e8464b
selftests/bpf: Add verifier test for release_reference()

Add a test case to ensure that released pointer registers will not be
leaked into the map.

Before fix:

  ./test_verifier 984
    984/u reference tracking: try to leak released ptr reg FAIL
    Unexpected success to load!
    verification time 67 usec
    stack depth 4
    processed 23 insns (limit 1000000) max_states_per_insn 0 total_states 2
    peak_states 2 mark_read 1
    984/p reference tracking: try to leak released ptr reg OK
    Summary: 1 PASSED, 0 SKIPPED, 1 FAILED

After fix:

  ./test_verifier 984
    984/u reference tracking: try to leak released ptr reg OK
    984/p reference tracking: try to leak released ptr reg OK
    Summary: 2 PASSED, 0 SKIPPED, 0 FAILED

Signed-off-by: Youlin Li <liulin063@gmail.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20221103093440.3161-2-liulin063@gmail.com
tools/testing/selftests/bpf/verifier/ref_tracking.c