diff options
author | Alexei Starovoitov <ast@kernel.org> | 2024-04-25 12:40:20 -0700 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2024-04-25 12:42:43 -0700 |
commit | a311c3f9c342fc12e6c8a27e22c81955ab2a336c (patch) | |
tree | dce5b752510c9ff8741a4cac01ea49fb0a7d3d99 /tools/testing/selftests/bpf/prog_tests/tcp_rtt.c | |
parent | 638a485c4996be1d38303cf25ea8d12dfd16011b (diff) | |
parent | 6a2d30d3c5bf9f088dcfd5f3746b04d84f2fab83 (diff) | |
download | linux-a311c3f9c342fc12e6c8a27e22c81955ab2a336c.tar.gz linux-a311c3f9c342fc12e6c8a27e22c81955ab2a336c.tar.bz2 linux-a311c3f9c342fc12e6c8a27e22c81955ab2a336c.zip |
Merge branch 'check-bpf_dummy_struct_ops-program-params-for-test-runs'
Eduard Zingerman says:
====================
check bpf_dummy_struct_ops program params for test runs
When doing BPF_PROG_TEST_RUN for bpf_dummy_struct_ops programs,
execution should be rejected when NULL is passed for non-nullable
params, because for such params verifier assumes that such params are
never NULL and thus might optimize out NULL checks.
This problem was reported by Jose E. Marchesi in off-list discussion.
The code generated by GCC for dummy_st_ops_success/test_1() function
differs from LLVM variant in a way that allows verifier to remove the
NULL check. The test dummy_st_ops/dummy_init_ret_value actually sets
the 'state' parameter to NULL, thus GCC-generated version of the test
triggers NULL pointer dereference when BPF program is executed.
This patch-set addresses the issue in the following steps:
- patch #1 marks bpf_dummy_struct_ops.test_1 parameter as nullable,
for verifier to have correct assumptions about test_1() programs;
- patch #2 modifies dummy_st_ops/dummy_init_ret_value to trigger NULL
dereference with both GCC and LLVM (if patch #1 is not applied);
- patch #3 adjusts a few dummy_st_ops test cases to avoid passing NULL
for 'state' parameter of test_2() and test_sleepable() functions,
as parameters of these functions are not marked as nullable;
- patch #4 adjusts bpf_dummy_struct_ops to reject test execution of
programs if NULL is passed for non-nullable parameter;
- patch #5 adds a test to verify logic from patch #4.
====================
Link: https://lore.kernel.org/r/20240424012821.595216-1-eddyz87@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'tools/testing/selftests/bpf/prog_tests/tcp_rtt.c')
0 files changed, 0 insertions, 0 deletions