Re: [PATCH net-next 02/15] xdp: Keep the shared info of a buffer in kernel memory
From: Björn Töpel
Date: Wed Nov 25 2026 - 14:36:11 EST
Maciej Fijalkowski <maciej.fijalkowski@xxxxxxxxx> writes:
> On Tue, Nov 24, 2026 at 01:56:37PM +0100, Björn Töpel wrote:
>> Currently, the shared info of an XDP buffer, with the fragment list of
>> a multi-buffer packet, lives at the end of the buffer's frame, in
>> memory that the device writes. Helpers follow its fragments, drivers
>> free them through it, and frame and skb conversion copy it, so memory
>> that others may write while the kernel uses it must not hold it.
>> Classic AF_XDP zero copy keeps it in the tail of a UMEM chunk, where
>> userspace can rewrite it.
>>
>> Let an RX queue keep the shared info of its buffers in kernel memory.
>> The queue gets one from xdp_rxq_info_reg_ext_sinfo(), and
>> xdp_rxq_info_unreg_mem_model() frees it. A buffer with the new
>> XDP_FLAGS_SINFO_EXT finds its shared info there.
>>
>> Whoever prepares a buffer sets the flag before adding fragments. The
>> queue NAPI builds one buffer at a time, so one shared info per queue
>> is enough. It is valid until the buffer is redirected, dropped or
>> copied. Frame conversion and skb construction refuse buffers with the
>> flag, as a frame or an skb would keep its shared info in the buffer.
>> Nothing sets the flag until later in this series.
>>
>> xdp_data_hard_end() reserves no shared-info tailroom for such a
>> buffer, so its data may reach the end of the frame. frame_sz then
>> bounds every write past the data, such as tail growth and
>> bpf_xdp_pull_data(), so the frame must not cover memory of other
>> buffers. Drivers may then pack such buffers tighter.
>>
>> Signed-off-by: Björn Töpel <bjorn@xxxxxxxxxx>
>> ---
>> include/net/xdp.h | 41 +++++++++++++++++++++++++++++++++++------
>> net/core/xdp.c | 30 ++++++++++++++++++++++++++++++
>> 2 files changed, 65 insertions(+), 6 deletions(-)
>
> couldn't this effort be sent separately and address classic zc as well?
Yes, and it should. This is a security issue for AF_XDP implementations
supporting xdp.frags. :-(