mbox series

[net,0/3] ENETC bug fixes for bpf_xdp_adjust_head() and bpf_xdp_adjust_tail()

Message ID 20250417120005.3288549-1-vladimir.oltean@nxp.com (mailing list archive)
Headers show
Series ENETC bug fixes for bpf_xdp_adjust_head() and bpf_xdp_adjust_tail() | expand

Message

Vladimir Oltean April 17, 2025, noon UTC
It has been reported that on the ENETC driver, bpf_xdp_adjust_head()
and bpf_xdp_adjust_tail() are broken in combination with the XDP_PASS
verdict. I have constructed a series a simple XDP programs and tested
with various packet sizes and confirmed that this is the case.

Patch 3/3 fixes the core issue, which is that the sk_buff created on
XDP_PASS is created by the driver as if XDP never ran, but in fact the
geometry needs to be adjusted according to the delta applied by the
program on the original xdp_buff. It depends on commit 539c1fba1ac7
("xdp: add generic xdp_build_skb_from_buff()") which is not available in
"stable" but perhaps should be.

Patch 2/3 is a small refactor necessary for 3/3.

Patch 1/3 fixes a related issue I noticed, which is that
bpf_xdp_adjust_tail() with a positive offset works for linear XDP
buffers, but returns an error for non-linear ones, even if there is
plenty of space in the final page fragment.

Vladimir Oltean (3):
  net: enetc: register XDP RX queues with frag_size
  net: enetc: refactor bulk flipping of RX buffers to separate function
  net: enetc: fix frame corruption on bpf_xdp_adjust_head/tail() and
    XDP_PASS

 drivers/net/ethernet/freescale/enetc/enetc.c | 45 ++++++++++++--------
 1 file changed, 28 insertions(+), 17 deletions(-)