While stable 6.12 has commit 1a4607ffba35 ("bpf: consider that tail calls invalidate packet pointers") backported, that alone is not enough to fix the issue reported by Nick Zavaritsky[1]. This is evident when running the verifier_sock/invalidate_pkt_pointers_from_global_func and verifier_sock/invalidate_pkt_pointers_by_tail_call BPF selftests[2].
Error: #529 verifier_sock Error: #529/57 verifier_sock/invalidate_pkt_pointers_from_global_func run_subtest:PASS:obj_open_mem 0 nsec run_subtest:FAIL:unexpected_load_success unexpected success: 0 Error: #529/58 verifier_sock/invalidate_pkt_pointers_by_tail_call run_subtest:PASS:obj_open_mem 0 nsec run_subtest:FAIL:unexpected_load_success unexpected success: 0
Fix the issue by backporting the entire "bpf: track changes_pkt_data property for global functions" series[3], along with the follow up, "bpf: fix NPE when computing changes_pkt_data of program w/o subprograms" series[4]; both from Eduard. With this series applied the test above no longer fails[5].
1: https://lore.kernel.org/bpf/0498CA22-5779-4767-9C0C-A9515CEA711F@gmail.com/ 2: https://github.com/shunghsiyu/libbpf/actions/runs/14591085098/job/4092630316... 3: https://lore.kernel.org/all/20241210041100.1898468-1-eddyz87@gmail.com/ 4: https://lore.kernel.org/all/20241212070711.427443-1-eddyz87@gmail.com/ 5: https://github.com/shunghsiyu/libbpf/actions/runs/14609494070/job/4098475698...
Eduard Zingerman (8): bpf: add find_containing_subprog() utility function bpf: track changes_pkt_data property for global functions selftests/bpf: test for changing packet data from global functions bpf: check changes_pkt_data property for extension programs selftests/bpf: freplace tests for tracking of changes_packet_data selftests/bpf: validate that tail call invalidates packet pointers bpf: fix null dereference when computing changes_pkt_data of prog w/o subprogs selftests/bpf: extend changes_pkt_data with cases w/o subprograms
include/linux/bpf.h | 1 + include/linux/bpf_verifier.h | 1 + kernel/bpf/verifier.c | 79 +++++++++++-- .../bpf/prog_tests/changes_pkt_data.c | 107 ++++++++++++++++++ .../selftests/bpf/progs/changes_pkt_data.c | 39 +++++++ .../bpf/progs/changes_pkt_data_freplace.c | 18 +++ .../selftests/bpf/progs/verifier_sock.c | 56 +++++++++ 7 files changed, 292 insertions(+), 9 deletions(-) create mode 100644 tools/testing/selftests/bpf/prog_tests/changes_pkt_data.c create mode 100644 tools/testing/selftests/bpf/progs/changes_pkt_data.c create mode 100644 tools/testing/selftests/bpf/progs/changes_pkt_data_freplace.c