check bpf_dummy_struct_ops program params for test runs
Status from this message: This series was applied to bpf/bpf-next.git (master)
Get series with b4
b4 am [email protected]Versions newest first
Patches in v1 All 5 applied
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/5 | bpf: mark bpf_dummy_struct_ops.test_1 parameter as nullablenet/ | +2 | 0 replies | Applied |
| 2/5 | selftests/bpf: adjust dummy_st_ops_success to detect additional errortools/ | +11 | 0 replies | Applied |
| 3/5 | selftests/bpf: do not pass NULL for non-nullable params in dummy_st_opstools/ tools/ | +6 | 0 replies | Applied |
| 4/5 | bpf: check bpf_dummy_struct_ops program params for test runsnet/ | +50 | 0 replies | Applied |
| 5/5 | selftests/bpf: dummy_st_ops should reject 0 for non-nullable paramstools/ | +27 | 0 replies | Applied |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [PATCH bpf-next 0/5] 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.
Eduard Zingerman (5):
bpf: mark bpf_dummy_struct_ops.test_1 parameter as nullable selftests/bpf: adjust dummy_st_ops_success to detect additional error selftests/bpf: do not pass NULL for non-nullable params in
dummy_st_ops
bpf: check bpf_dummy_struct_ops program params for test runs selftests/bpf: dummy_st_ops should reject 0 for non-nullable params
net/bpf/bpf_dummy_struct_ops.c | 55 ++++++++++++++++++- .../selftests/bpf/prog_tests/dummy_st_ops.c | 34 +++++++++++- .../bpf/progs/dummy_st_ops_success.c | 15 ++++- 3 files changed, 96 insertions(+), 8 deletions(-)
Signature · 1 line
2.34.1