From: "Björn Töpel" <bjorn@kernel.org>
To: netdev-bot+sashiko@kernel.org
Cc: magnus.karlsson@intel.com, maciej.fijalkowski@intel.com,
davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
pabeni@redhat.com, andrew+netdev@lunn.ch, ast@kernel.org,
daniel@iogearbox.net, hawk@kernel.org, john.fastabend@gmail.com,
andrii@kernel.org, eddyz87@gmail.com, memxor@gmail.com,
ilias.apalodimas@linaro.org, alexanderduyck@fb.com,
saeedm@nvidia.com, tariqt@nvidia.com, mbloch@nvidia.com,
leon@kernel.org, michael.chan@broadcom.com,
pavan.chebbi@broadcom.com, corbet@lwn.net, shuah@kernel.org,
bpf@vger.kernel.org, netdev@vger.kernel.org, stuclar@meta.com,
sdf@fomichev.me, horms@kernel.org, martin.lau@linux.dev,
almasrymina@google.com, song@kernel.org, yonghong.song@linux.dev,
jolsa@kernel.org, emil@etsalapatis.com, ihor.solodrai@linux.dev,
rdunlap@infradead.org, kernel-team@meta.com,
dimitri.daskalakis1@gmail.com, bobbyeshleman@meta.com,
mohsin.bashr@gmail.com, kees@kernel.org, leitao@debian.org,
maxime.chevallier@bootlin.com, cuitao@kylinos.cn,
vadim.fedorenko@linux.dev, mike.marciniszyn@gmail.com,
kuniyu@google.com, jiayuan.chen@linux.dev, mkarsten@uwaterloo.ca,
razor@blackwall.org, dw@davidwei.uk, asml.silence@gmail.com,
linux-rdma@vger.kernel.org, linux-kselftest@vger.kernel.org,
linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next 05/15] xdp: Run programs on buffers that must not hold kernel structures
Date: Wed, 25 Nov 2026 20:55:14 +0100 [thread overview]
Message-ID: <8733soofdp.fsf@all.your.base.are.belong.to.us> (raw)
In-Reply-To: <179561569289.3135.1423395269344157578@kernel.org>
netdev-bot+sashiko@kernel.org writes:
> Thank you for your contribution! Sashiko AI review found 2 potential
> issue(s) to consider.
>
> Critical: 0 · High: 1 · Medium: 0 · Low: 1
>
> If you believe none of the issues are legitimate, please reply to each
> issue of Medium severity or higher and explain why the AI is wrong.
> If any of them are legitimate and you plan to respin, please let patchwork
> know by including "pw-bot: cr" as a separate line at the end of your reply
> (one such reply per series is enough).
>
> - [High] The new XDP_FLAGS_SINK contract in include/net/xdp.h says a
> helper that checks bytes and reads them again later must check a copy,…
> - [Low] The commit message opens with "Currently, the core refuses native
> XDP programs next to a memory provider." That was no longer true when…
>
> --
>
> xdp: Run programs on buffers that must not hold kernel structures
>
> This lets native XDP programs run on AF_XDP sink buffers (UMEM chunks
> that userspace may write at any time). Such buffers are marked with
> XDP_FLAGS_SINK and XDP_FLAGS_SINFO_EXT, and their shared info moves into
> the rxq. XDP_TX and XDP_PASS become XDP_DROP, and frame and skb
> construction refuse sink buffers.
>
>> Currently, the core refuses native XDP programs next to a memory
>> provider. An AF_XDP sink needs XDP to steer its packets and to use the
>
> [Severity: Low]
> Is this opening sentence still accurate at this point in the series?
I'll address this in the next version.
> The previous commit, "net: Add memory providers that only feed XDP",
> already exempts MP_XDP_ONLY providers in dev_mp_blocks_xdp():
>
> net/core/dev.c:dev_mp_blocks_xdp() {
> ...
> if (ops && !(ops->flags & MP_XDP_ONLY))
> return true;
> ...
> }
>
> That commit also relaxed the dev_xdp_prog_count() check in
> __netif_mp_open_rxq() for XDP-only providers.
>
> This patch touches neither net/core/dev.c nor netdev_rx_queue.c. Could
> the message be reworded so it doesn't suggest that this patch lifts the
> refusal?
>
>> diff --git a/include/net/xdp.h b/include/net/xdp.h
>> index 944418111a86e..c7cb0ba4e16f4 100644
>> --- a/include/net/xdp.h
>> +++ b/include/net/xdp.h
>
> [ ... ]
>
>> @@ -95,6 +99,15 @@ enum xdp_buff_flags {
>> * frame, see xdp_data_hard_end(): the frame must hold nothing else.
>> */
>> XDP_FLAGS_SINFO_EXT = BIT(3),
>> + /* AF_XDP sink memory, see %MP_XDP_ONLY: the buffer may only go to the
>> + * AF_XDP socket of its queue. Userspace may write it at any time,
>> + * also while the kernel reads it. So the kernel takes bounds only
>> + * from its own fields, and only the XDP program and its helpers read
>> + * the bytes. A helper that checks bytes and reads them again later
>> + * must check a copy, see bpf_syncookie_th(). Nothing builds a frame
>> + * or an skb in the buffer.
>> + */
>> + XDP_FLAGS_SINK = BIT(4),
>
> [Severity: High]
> Where is bpf_syncookie_th() defined? I can't find it in this commit or
> later in the series. This comment is the only place the name appears.
>
> The syncookie helpers that XDP programs can call still read th->doff
> twice from packet memory:
>
> net/core/filter.c:bpf_tcp_raw_gen_syncookie_ipv4() {
> ...
> if (unlikely(th_len < sizeof(*th) || th_len != th->doff * 4))
> return -EINVAL;
>
> mss = tcp_parse_mss_option(th, 0) ?: TCP_MSS_DEFAULT;
> ...
> }
>
> tcp_parse_mss_option() then reads doff again to decide how many option
> bytes to walk:
>
> int length = (th->doff * 4) - sizeof(struct tcphdr);
>
> bpf_tcp_raw_gen_syncookie_ipv6() does the same thing. So does
> bpf_tcp_gen_syncookie(), which checks doff and then re-parses the
> options through tcp_v4/v6_get_syncookie().
>
> The verifier only checks th_len bytes, because arg2 is ARG_PTR_TO_MEM and
> arg3 is ARG_MEM_SIZE_OR_ZERO. With a sink buffer, a userspace thread can
> change doff from 5 to 15 between the check and tcp_parse_mss_option().
> Could the parse then read up to 40 bytes beyond the region the verifier
> checked?
>
> xdp_sink_mark() also sets XDP_FLAGS_SINFO_EXT on sink buffers, so
> xdp_data_hard_end() reserves no shared-info tailroom. A program can grow
> the tail to the end of the frame. If the TCP header sits at the end of
> the last UMEM chunk, can the extra read go past xdp_vaddr + xdp_vsize
> and fault in NAPI context?
>
> Classic AF_XDP zero copy has the same double fetch, but there the
> shared-info tailroom keeps the extra read inside the chunk.
>
> Should this patch add the copy-and-check that the comment describes for
> these helpers? Or, if it is meant to come later, should the comment
> point to something that already exists?
Yeah, the double read of th->doff is real, and older than this series.
I'll think about a fix.
next prev parent reply other threads:[~2026-11-25 19:55 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 11:26 [PATCH net-next 00/15] xsk: Receive in the device's buffer layout Björn Töpel
2026-11-24 12:56 ` [PATCH net-next 01/15] xdp: Let memory providers offer XDP a view of their net_iovs Björn Töpel
2026-11-25 14:07 ` netdev-bot+sashiko
2026-11-25 19:34 ` Björn Töpel
2026-11-24 12:56 ` [PATCH net-next 02/15] xdp: Keep the shared info of a buffer in kernel memory Björn Töpel
2026-11-25 14:07 ` netdev-bot+sashiko
2026-11-25 19:39 ` Björn Töpel
2026-11-25 15:17 ` Maciej Fijalkowski
2026-11-25 19:36 ` Björn Töpel
2026-11-24 12:56 ` [PATCH net-next 03/15] net: Add memory providers that only feed XDP Björn Töpel
2026-11-25 14:08 ` netdev-bot+sashiko
2026-11-25 19:43 ` Björn Töpel
2026-11-24 12:56 ` [PATCH net-next 04/15] page_pool: Let memory providers take back net_iovs Björn Töpel
2026-11-25 14:08 ` netdev-bot+sashiko
2026-11-25 19:45 ` Björn Töpel
2026-11-24 12:56 ` [PATCH net-next 05/15] xdp: Run programs on buffers that must not hold kernel structures Björn Töpel
2026-11-25 14:08 ` netdev-bot+sashiko
2026-11-25 19:55 ` Björn Töpel [this message]
2026-11-25 15:22 ` Maciej Fijalkowski
2026-11-25 15:28 ` Maciej Fijalkowski
2026-11-25 19:50 ` Björn Töpel
2026-11-24 12:56 ` [PATCH net-next 06/15] xsk: Lend UMEM chunks to the page pools of a queue Björn Töpel
2026-11-24 14:34 ` Magnus Karlsson
2026-11-24 15:12 ` Björn Töpel
2026-11-25 14:08 ` netdev-bot+sashiko
2026-11-25 20:02 ` Björn Töpel
2026-11-24 12:56 ` [PATCH net-next 07/15] xsk: Deliver to the socket in the device's buffer layout Björn Töpel
2026-11-25 14:08 ` netdev-bot+sashiko
2026-11-25 20:11 ` Björn Töpel
2026-11-24 12:56 ` [PATCH net-next 08/15] xsk: Receive " Björn Töpel
2026-11-25 14:08 ` netdev-bot+sashiko
2026-11-25 20:16 ` Björn Töpel
2026-11-24 12:56 ` [PATCH net-next 09/15] eth: fbnic: Support XDP redirect Björn Töpel
2026-11-24 12:56 ` [PATCH net-next 10/15] eth: fbnic: Receive into XDP-only memory providers Björn Töpel
2026-11-24 12:56 ` [PATCH net-next 11/15] net: Add netif_rxq_has_xdp_only_mp() Björn Töpel
2026-11-24 12:56 ` [PATCH net-next 12/15] eth: mlx5e: Receive into XDP-only memory providers Björn Töpel
2026-11-25 14:08 ` netdev-bot+sashiko
2026-11-25 20:26 ` Björn Töpel
2026-11-24 12:56 ` [PATCH net-next 13/15] eth: bnxt: " Björn Töpel
2026-11-25 14:08 ` netdev-bot+sashiko
2026-11-25 20:33 ` Björn Töpel
2026-11-24 12:56 ` [PATCH net-next 14/15] selftests: net: xsk: Test the device's RX buffer layout Björn Töpel
2026-11-25 14:08 ` netdev-bot+sashiko
2026-11-24 12:56 ` [PATCH net-next 15/15] Documentation: networking: Describe AF_XDP RX in the device's layout Björn Töpel
2026-11-25 14:08 ` netdev-bot+sashiko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8733soofdp.fsf@all.your.base.are.belong.to.us \
--to=bjorn@kernel.org \
--cc=alexanderduyck@fb.com \
--cc=almasrymina@google.com \
--cc=andrew+netdev@lunn.ch \
--cc=andrii@kernel.org \
--cc=asml.silence@gmail.com \
--cc=ast@kernel.org \
--cc=bobbyeshleman@meta.com \
--cc=bpf@vger.kernel.org \
--cc=corbet@lwn.net \
--cc=cuitao@kylinos.cn \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=dimitri.daskalakis1@gmail.com \
--cc=dw@davidwei.uk \
--cc=eddyz87@gmail.com \
--cc=edumazet@kernel.org \
--cc=emil@etsalapatis.com \
--cc=hawk@kernel.org \
--cc=horms@kernel.org \
--cc=ihor.solodrai@linux.dev \
--cc=ilias.apalodimas@linaro.org \
--cc=jiayuan.chen@linux.dev \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kees@kernel.org \
--cc=kernel-team@meta.com \
--cc=kuba@kernel.org \
--cc=kuniyu@google.com \
--cc=leitao@debian.org \
--cc=leon@kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=maciej.fijalkowski@intel.com \
--cc=magnus.karlsson@intel.com \
--cc=martin.lau@linux.dev \
--cc=maxime.chevallier@bootlin.com \
--cc=mbloch@nvidia.com \
--cc=memxor@gmail.com \
--cc=michael.chan@broadcom.com \
--cc=mike.marciniszyn@gmail.com \
--cc=mkarsten@uwaterloo.ca \
--cc=mohsin.bashr@gmail.com \
--cc=netdev-bot+sashiko@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pavan.chebbi@broadcom.com \
--cc=razor@blackwall.org \
--cc=rdunlap@infradead.org \
--cc=saeedm@nvidia.com \
--cc=sdf@fomichev.me \
--cc=shuah@kernel.org \
--cc=song@kernel.org \
--cc=stuclar@meta.com \
--cc=tariqt@nvidia.com \
--cc=vadim.fedorenko@linux.dev \
--cc=yonghong.song@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®