This is part 1 of https://lore.kernel.org/bpf/20221018135920.726360-1-memxor@xxxxxxxxx. This thread also gives some background on why the refactor is being done: https://lore.kernel.org/bpf/CAEf4Bzb4beTHgVo+G+jehSj8oCeAjRbRcm6MRe=Gr+cajRBwEw@xxxxxxxxxxxxxx As requested in patch 6 by Alexei, it only includes patches which refactors the code, on top of which further fixes will be made in part 2. The refactor itself fixes another issue as a side effect. No functional change is intended (except a few modified log messages). Changelog: ---------- v1 -> v2 v1: https://lore.kernel.org/bpf/20221115000130.1967465-1-memxor@xxxxxxxxx * Address feedback from Joanne and David, add acks Fixes v1 -> v1 Fixes v1: https://lore.kernel.org/bpf/20221018135920.726360-1-memxor@xxxxxxxxx * Collect acks from Joanne and David * Fix misc nits pointed out by Joanne, David * Split move of reg->off alignment check for dynptr into separate change (Alexei) Kumar Kartikeya Dwivedi (7): bpf: Refactor ARG_PTR_TO_DYNPTR checks into process_dynptr_func bpf: Propagate errors from process_* checks in check_func_arg bpf: Rework process_dynptr_func bpf: Rework check_func_arg_reg_off bpf: Move PTR_TO_STACK alignment check to process_dynptr_func bpf: Use memmove for bpf_dynptr_{read,write} selftests/bpf: Add test for dynptr reinit in user_ringbuf callback include/linux/bpf.h | 4 +- include/linux/bpf_verifier.h | 8 +- include/uapi/linux/bpf.h | 8 +- kernel/bpf/helpers.c | 30 +- kernel/bpf/verifier.c | 435 ++++++++++++------ scripts/bpf_doc.py | 1 + tools/include/uapi/linux/bpf.h | 8 +- .../bpf/prog_tests/kfunc_dynptr_param.c | 7 +- .../selftests/bpf/prog_tests/user_ringbuf.c | 6 +- .../bpf/progs/test_kfunc_dynptr_param.c | 12 - .../selftests/bpf/progs/user_ringbuf_fail.c | 51 +- tools/testing/selftests/bpf/verifier/calls.c | 2 +- .../testing/selftests/bpf/verifier/ringbuf.c | 2 +- 13 files changed, 371 insertions(+), 203 deletions(-) base-commit: e9b4aeed56699b469206d05e706ddf2db95700a9 -- 2.38.1