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: ---------- 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/btf.c | 22 +- kernel/bpf/helpers.c | 22 +- kernel/bpf/verifier.c | 416 ++++++++++++------ scripts/bpf_doc.py | 1 + tools/include/uapi/linux/bpf.h | 8 +- .../bpf/prog_tests/kfunc_dynptr_param.c | 5 +- .../selftests/bpf/prog_tests/user_ringbuf.c | 12 +- .../bpf/progs/test_kfunc_dynptr_param.c | 12 - .../selftests/bpf/progs/user_ringbuf_fail.c | 35 ++ .../testing/selftests/bpf/verifier/ringbuf.c | 2 +- 13 files changed, 355 insertions(+), 200 deletions(-) base-commit: de763fbb2c5bfad1ab7c4232e6a804726f0b0744 -- 2.38.1