[PATCH bpf 0/2] bpf: test_run: Fix false -EBADMSG with BPF_F_TEST_SKB_CHECKSUM_COMPLETE

From: Maxim Skokov

Date: Wed Oct 07 2026 - 14:13:46 EST


BPF_PROG_TEST_RUN with BPF_F_TEST_SKB_CHECKSUM_COMPLETE returns -EBADMSG
for correct tc programs that call bpf_skb_change_tail(). The helper
moves the skb to CHECKSUM_NONE and leaves skb->csum stale, but the
post-run check added by commit a3cfe84cca28 ("bpf: Add CHECKSUM_COMPLETE
to bpf test progs") still compares against it.

Patch 1 only does the check while the skb is still CHECKSUM_COMPLETE.
Patch 2 adds selftests for a trim, a grow followed by a write, and a
negative case that keeps the skb CHECKSUM_COMPLETE with a stale
skb->csum.

Tested in a VM on bpf, with two kernels that differ only by patch 1
(subtest results):

without patch 1 with patch 1
change_tail_trim FAIL (-EBADMSG) OK
change_tail_grow_write FAIL (-EBADMSG) OK
store_no_recompute OK OK
test_skb_pkt_end OK OK

Maxim Skokov (2):
bpf: test_run: Fix false -EBADMSG after skb leaves CHECKSUM_COMPLETE
selftests/bpf: Cover test_run csum validation after
bpf_skb_change_tail()

net/bpf/test_run.c | 7 ++-
.../bpf/prog_tests/skb_csum_complete.c | 39 ++++++++++++++++
.../selftests/bpf/progs/skb_csum_complete.c | 44 +++++++++++++++++++
3 files changed, 89 insertions(+), 1 deletion(-)
create mode 100644 tools/testing/selftests/bpf/prog_tests/skb_csum_complete.c
create mode 100644 tools/testing/selftests/bpf/progs/skb_csum_complete.c


base-commit: ff47652a4b66c067c765a7ad464d930b5a9367cc
--
2.47.3