# \[PATCH net-next 2/7\] xdp: Reject frames with unreadable fragments

- From: Björn Töpel \<bjorn@kernel.org\>
- Date: 2026-11-17 16:47:33 
- List: netdev
- Page: https://ratatoskr.run/netdev/2026/11/17954174
- Thread: https://ratatoskr.run/netdev/2026/11/17954172/t.md

```text
An xdp_frame can be sent to another device, processed on another CPU,
or copied into an AF_XDP socket. These paths do not support provider
fragments that the kernel cannot read or remap for transmit.

Reject conversion of such buffers to xdp_frame and reject AF_XDP
copies. A failed redirect leaves buffer ownership with the driver,
which drops and frees the packet.

Signed-off-by: Björn Töpel <bjorn@kernel.org>
---
 include/net/xdp.h | 3 +++
 net/xdp/xsk.c     | 5 +++++
 2 files changed, 8 insertions(+)

diff --git a/include/net/xdp.h b/include/net/xdp.h
index 16693cf9653e..20d173fe163c 100644
--- a/include/net/xdp.h
+++ b/include/net/xdp.h
@@ -432,6 +432,9 @@ int xdp_update_frame_from_buff(const struct xdp_buff *xdp,
 		return -ENOSPC;
 	}
 
+	if (unlikely(xdp_buff_is_frag_unreadable(xdp)))
+		return -EFAULT;
+
 	xdp_frame->data = xdp->data;
 	xdp_frame->len  = xdp->data_end - xdp->data;
 	xdp_frame->headroom = headroom - sizeof(*xdp_frame);
diff --git a/net/xdp/xsk.c b/net/xdp/xsk.c
index f22f9a2cdbbe..25b95ec19334 100644
--- a/net/xdp/xsk.c
+++ b/net/xdp/xsk.c
@@ -489,6 +489,11 @@ static int xsk_rcv(struct xdp_sock *xs, struct xdp_buff *xdp)
 		return xsk_rcv_zc(xs, xdp, len);
 	}
 
+	if (unlikely(xdp_buff_is_frag_unreadable(xdp))) {
+		xs->rx_dropped++;
+		return -EFAULT;
+	}
+
 	err = __xsk_rcv(xs, xdp, len);
 	if (!err)
 		xdp_return_buff(xdp);
-- 
2.56.1

```
