Skip to content

net: xdp: fix bpf_xdp_shrink_data() page handling on generic XDP and veth

Jiayuan Chen bpf linux-kselftest lkml netdev sashiko-reviews 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest2 patches 8 repliesIn review
  2. v22 patches 9 repliesSuperseded

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2bpf, veth: xdp: fix page_pool page leak on skb-backed XDPdrivers/net/veth.c include/net/xdp.h net/core/dev.c +1 more+48 -15 replies
2/2selftests/bpf: add xdp_shrink_fragstools/testing/selftests/bpf/prog_tests/xdp_shrink_frags.c tools/testing/selftests/bpf/progs/xdp_shrink_frags.c+322 -01 reply

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v3 yet.

Read the v3 thread

Cover letter [PATCH bpf v3 0/2] net: xdp: fix bpf_xdp_shrink_data() page handling on generic XDP and veth

I'm always confused which tree(net or bpf) should XDP target.

bpf_xdp_shrink_data() frees a page_pool frag with the wrong memory type on skb-backed XDP, hitting "Bad page state ... page_pool leak". Both the generic XDP path and the veth path are affected.

Patch 1 fixes it by tagging the xdp_buff, so it no longer depends on rxq->mem.type (which is shared on generic XDP and gets reset on veth). It is reported by syzbot.

Patch 2 adds a selftest that reproduces the leak on both paths.

v2 -> v3: handle some feedback from AI review.
v2: https://lore.kernel.org/bpf/[email protected]/
v1 -> v2: AI found the fix was insufficient and we need a general way
to fix them.
v1: https://lore.kernel.org/bpf/[email protected]/

Jiayuan Chen (2):
bpf, veth: xdp: fix page_pool page leak on skb-backed XDP selftests/bpf: add xdp_shrink_frags

 drivers/net/veth.c                            |   6 +
 include/net/xdp.h                             |  30 +-
 net/core/dev.c                                |   6 +
 net/core/filter.c                             |   7 +
 .../bpf/prog_tests/xdp_shrink_frags.c         | 288 ++++++++++++++++++
 .../selftests/bpf/progs/xdp_shrink_frags.c    |  34 +++
 6 files changed, 370 insertions(+), 1 deletion(-)
 create mode 100644 tools/testing/selftests/bpf/prog_tests/xdp_shrink_frags.c
 create mode 100644 tools/testing/selftests/bpf/progs/xdp_shrink_frags.c
Signature · 1 line
2.43.0