Article View: linux.kernel.netdev
Article #22723Re: [PATCH net-next 05/15] xdp: Run programs on buffers that must not hold kernel structures
From: Björn Töpel
Date: Wed, 25 Nov 2026 19:55
Date: Wed, 25 Nov 2026 19:55
123 lines
13719 bytes
13719 bytes
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.
Technical Details
Message-ID:
<8733soofdp.fsf@all.your.base.are.belong.to.us>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!3.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!peer02.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-371639-linux-kernel-netdev=dewy.ruReferences:
<20261124125654.183091-5-bjorn@kernel.org> <179561569289.3135.1423395269344157578@kernel.org>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!3.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!peer02.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-371639-linux-kernel-netdev=dewy.ru From: bjorn@kernel.org (Björn Töpel) Newsgroups: linux.kernel.netdev 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 Organization: Usenet Network Message-ID: <8733soofdp.fsf@all.your.base.are.belong.to.us> References: <20261124125654.183091-5-bjorn@kernel.org> <179561569289.3135.1423395269344157578@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: usenet.network; logging-data="289860"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:QPJclZEDbA1eDHxbmrQKUnwa0Bw= sha256:k75kP0OH8QMZ3CESf5cdoWHhulZOMV6QlBXUPSk0D0E= sha1:7ZBF3gtUXBFSGJBqYxEtyScMkiQ= sha256:0h3K5S1dOTi62PfK7XCnl8XsGqE6vakV77ay6tXuCpg= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 797E7125E9C; Wed, 25 Nov 2026 22:55:37 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.401 X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 8DuyJjuxZkWY; Wed, 25 Nov 2026 22:55:34 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-371639-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id 93BF9125E9B; Wed, 25 Nov 2026 22:55:23 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id E8E304190B; Wed, 25 Nov 2026 19:55:19 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1795636519; b=Bv2AbFVUxW+Pb23GnUxuAlE5KPDxHs71K4AoGVSZllEn6ISu64BNa778Odi0MIEZ5f+w 5ZWlEeveY+OF6KJkw64myrTAJq3shO3ZtqpuY1TYvKZDlxPSv6pA0uNNmRe2OyUEe+VlB UYQXPIvlRSOhrZo0XCT+UNvOA3A7cGORkbLPSuI+DlvkdI+sOuW8JzvCpUw95uSxon/FC +8rbLRdiumTR+RQI02RV6aMB6NFUlUTBRiyZ/jPMtA60fWKTFc9ok1bf+Pbay620V+2US DJb6Ii+ZocQvsI0W5Yi8FPPFCgSqT/gx0yphmyYXb9RzW8rDVIyBw7Qik9Teixcimig== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795636519; h=X-Original-To:Received:Received:DKIM-Signature:From:To:Cc:Subject: In-Reply-To:References:Date:Message-ID:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version:Content-Type:Content-Transfer-Encoding; bh=VrIp4UuqLML5zpUv0LIQhFdRxW0WUPrcltu+dCKTMog=; b=szf6DRfA5qRoqkRXh4lGFD9tSj9QrPBD82oKIUCLV6Jk2AOcvxzFRO5uujQRGeSySUie 6yrOJA9ANFKUmgB0vWNrOdBb0nYo1fJu5doPexk+CASTywCeBt1s9RroTXGe4pOzMGPI/ hnoMZGAec5WXeY6rduxtQpcR6akKaeSqT9kdVqXlGJl8cbIUjzPdXtqwtvaG0+sBrGEyH av7f0/XHP9jf/AsJBAnW4dwuT5pkYziyvTz1jyOQ8E5OsBMeSch30dmzyxrH/WlAn40Yt tt4wN06htOu8MwPf1G+fD3aDqfxOprSnSsCH4HmNh2bGJwJrk18GgjtwACyQM+ViPvg== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=VmiPb1GP; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B7BB9606A334; Wed, 25 Nov 2026 19:55:19 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=VmiPb1GP X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795636518; b=LXpXwyhcI4/0rBI3m3huL5um3m6xQg3lHz1iZWccBQcgcYO/wqQOepZFpsN4RK7ez210 2rpsrz8Eeav1xo7c2a1+JhnywrmapTHc4/nQevEznBkBGkw9xy65nLMUC5yBql9QydTTO VhDCJVjq8Xh6b+OVw5uCLdOYUBaYXJHxrYoN/nBNd5ADKVXRjrh4fA0OkwbTIk8R2+MEP 2Dhpikt33bXXNUJati9m7qm0JpYzuPUofnSoCbhyOjsNwEVVs0WujDoWyDseojUADNVsr Yyy2OZQsdpfBZmYBuEb2fZaIfEpOO8+8xLj1ICCnofmDTjzS3cqDg9XvBgTspPRcofg== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795636518; h=Received:DKIM-Signature:From:To:Cc:Subject:In-Reply-To:References: Date:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding; bh=VrIp4UuqLML5zpUv0LIQhFdRxW0WUPrcltu+dCKTMog=; b=QWljTnWZmzvAABewFbTfQRxKyph2OXMAgAlCjuK2kknHuNcywPS/OV1J6uWw1iOEQd5q XTGKYRE80zwVyf57r786FQc3em+u2vrH6GFxDdlOD+CocrmuAuNMQIaZ0ViWLohhv8ubt 5H65kBaE+PGm7c90+07OBre2KumFIgmnPPkVOL/bUs58EHxMuoIFeY01SNfJWL+9QDzTd Z79Y8DtIapz9H5UMOM6sgJlfsVsJzuzq5vDRP1+qVYtsbMnirdXL93ZHF35v5Kx3q62SF UdWoAZFQzAPGJitCGhM7qCBlSvsJYv+zA49yExdWynOowu74Afoclt09hWUMs+4CJuQ== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=VmiPb1GP; arc=none smtp.remote-ip=100.103.45.18 X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D51A3606A31E; Wed, 25 Nov 2026 19:55:18 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id D24701F000C0; Wed, 25 Nov 2026 19:55:17 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795636518; bh=VrIp4UuqLML5zpUv0LIQhFdRxW0WUPrcltu+dCKTMog=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=VmiPb1GPuDA6ow86f3h2bazo85jvyVYrUQV2gIgHZCgaomEbofTdGb3RMcFUtMhJO jdBW4BDreQ/vv4ARIMr8y2swl56nQUBP+UkamajNlGHoElThPcrewcLVNAYIpwXn7s Vw/UtrRoutLi9SyvavmJ3enQth1LCcIJqp5g3enbdNXFjGfBG9hScQoHnpgF09sEen 0tgPlU8F6jrXZzvSVEWrDIgvciP76cpxZIsI0cr/vCpUvsZL7gQ3O5ZL3cHExno5hO OI2dST0GFsWmYaULP+iZiuq9XkSkX174R/WmcmdU3UxWpmPf1YjtRKy0YL8zDWUdEa WEuo+1p95Sznw== X-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 X-In-Reply-To: <179561569289.3135.1423395269344157578@kernel.org> X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list X-Received-Bytes: 13460