Article View: linux.kernel.netdev
Article #21377Re: [PATCH net] sctp: unshare GSO skb frag_list members instead of linearizing
From: netdev-bot+sashiko
Date: Mon, 23 Nov 2026 23:45
Date: Mon, 23 Nov 2026 23:45
236 lines
15842 bytes
15842 bytes
Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.
Critical: 0 · High: 1 · Medium: 1 · 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] sctp_gso_unshare() (net/sctp/input.c) does not give SCTP
exclusive ownership of frag_list members, even though its comment says…
- [Medium] sctp_rcv() now skips skb_linearize() for every GSO-SCTP skb,
including nonlinear ones that have no frag_list.
- [Low] The commit message misstates the history and the mechanism.
--
sctp: unshare GSO skb frag_list members instead of linearizing
This patch stops sctp_rcv() from linearizing cloned SCTP GSO skbs. It adds
sctp_gso_unshare() instead. That helper calls skb_unclone() on the outer
skb and replaces each shared frag_list member with a private skb_clone().
The aim is to avoid races on shared frag_list headers after a TEE
pskb_copy(), and to keep per-segment boundaries so that SCTP-AUTH works.
> The previous fix in commit fd60d8a08619 ("sctp: linearize cloned gso
> packets in sctp_rcv") checked skb_cloned() on the outer skb and
> linearized the entire GSO packet. This is insufficient for two reasons:
>
> - A partial pull into the frag_list can privatize the head while later
> members stay shared.
[Severity: Low]
Does this match the TEE case? The TEE target goes through
nf_dup_ipv4()/nf_dup_ipv6() and pskb_copy(). __pskb_copy_fclone() gives
the new skb a private head and shares the frag_list:
net/core/skbuff.c:__pskb_copy_fclone() {
...
if (skb_has_frag_list(skb)) {
skb_shinfo(n)->frag_list = skb_shinfo(skb)->frag_list;
skb_clone_fraglist(n);
}
...
}
Neither skb is marked cloned. So the skb_cloned() check added by
fd60d8a08619 never fired here, and no partial pull is involved.
If that's right, the bug goes back to commit 90017accff61 ("sctp: Add GSO
support"). Should the Fixes: tag point there instead of fd60d8a08619?
> 1. Calls skb_unclone() to unshare the outer skb header without
> flattening the frag_list.
skb_unclone() only acts when skb_cloned() is true. It then calls
pskb_expand_head(), which reallocates the data head and shared info. The
sk_buff header is already private at that point.
For the pskb_copy()/TEE skb, skb_cloned() is false, so skb_unclone() does
nothing. Could this step be described more precisely?
> diff --git a/net/sctp/input.c b/net/sctp/input.c
> index 9494cfa51106c..cd84ee44b9f24 100644
> --- a/net/sctp/input.c
> +++ b/net/sctp/input.c
> @@ -82,6 +82,38 @@ static inline int sctp_rcv_checksum(struct net *net, struct sk_buff *skb)
> return 0;
> }
>
> +/* Ensure exclusive ownership of frag_list members for GSO skbs.
> + * pskb_copy() shares them by reference; unshare by cloning in place.
> + */
> +static int sctp_gso_unshare(struct sk_buff *skb)
> +{
> + struct sk_buff **pp, *p;
> +
> + if (skb_unclone(skb, GFP_ATOMIC))
> + return -ENOMEM;
> +
> + if (!skb_has_frag_list(skb))
> + return 0;
> +
> + pp = &skb_shinfo(skb)->frag_list;
> + skb_walk_frags(skb, p) {
> + if (skb_shared(p)) {
> + struct sk_buff *clone;
> +
> + clone = skb_clone(p, GFP_ATOMIC);
[Severity: High]
Does this give SCTP exclusive ownership of the frag_list member, as the
comment above says? skb_clone() makes the sk_buff private. The data buffer
stays shared: dataref is bumped and both skbs are marked cloned.
The SCTP receive path then writes into that shared data. For a
cover-letter GSO skb, sctp_inq_pop() points chunk->skb at the frag_list
member:
net/sctp/inqueue.c:sctp_inq_pop() {
...
if (chunk->head_skb && chunk->skb->data_len == chunk->skb->len) {
...
chunk->skb = skb_shinfo(chunk->skb)->frag_list;
...
}
sctp_sf_authenticate() then changes the digest in place:
net/sctp/sm_statefuns.c:sctp_sf_authenticate() {
...
save_digest = kmemdup(digest, sig_len, GFP_ATOMIC);
...
memset(digest, 0, sig_len);
if (sctp_auth_calculate_hmac(asoc, chunk->skb,
(struct sctp_auth_chunk *)chunk->chunk_hdr,
sh_key, GFP_ATOMIC)) {
...
}
sctp_auth_calculate_hmac() writes the HMAC it computes back into the same
digest location in the packet.
In the TEE scenario from the commit message, both copies share the same
frag_list data. Can this sequence let an unauthenticated packet through
on the second copy?
receiver A (first copy, on-wire digest D does not match)
sctp_sf_authenticate()
save_digest = D
memset(digest, 0, sig_len)
sctp_auth_calculate_hmac() writes valid H into the shared bytes
compare fails -> BAD_SIG
receiver B (second copy)
sctp_sf_authenticate()
save_digest = H <- read from the shared bytes
memset, then recompute H
compare(H, H) succeeds -> chunk->auth = 1
If the two copies are processed at the same time, can valid packets also
fail verification? The HMAC input would include the other receiver's
partial writes.
The cloned-outer case looks affected too, for example an AF_PACKET tap on
lo. packet_rcv() clones the skb, and then
skb_unclone()->pskb_expand_head()->skb_clone_fraglist() leaves the members
shared. Before this patch, skb_linearize() gave SCTP a private copy of the
data.
With this patch, don't the memset() and the HMAC write land in data the
tap's queued clone still references? The packet socket reader would then
see zeroed or recomputed digest bytes instead of the bytes received on the
wire.
Would it work to make the data private for the members SCTP writes to?
That could be skb_copy() or pskb_expand_head() on shared or cloned members,
at least those carrying AUTH. Another option is to compute the HMAC into a
private buffer instead of the packet.
> + if (!clone)
> + return -ENOMEM;
> + clone->next = p->next;
> + consume_skb(p);
> + p = clone;
> + *pp = p;
> + }
> + pp = &p->next;
> + }
> +
> + return 0;
> +}
> +
[ ... ]
> @@ -117,8 +149,14 @@ int sctp_rcv(struct sk_buff *skb)
> * it's better to just linearize it otherwise crc computing
> * takes longer.
> */
> - if (((!is_gso || skb_cloned(skb)) && skb_linearize(skb)) ||
> - !pskb_may_pull(skb, sizeof(struct sctphdr)))
> + if (!is_gso) {
> + if (skb_linearize(skb))
> + goto discard_it;
> + } else if (sctp_gso_unshare(skb)) {
> + goto discard_it;
> + }
[Severity: Medium]
What happens to a nonlinear GSO-SCTP skb that has page frags but no
frag_list? sctp_gso_unshare() returns early for it:
if (!skb_has_frag_list(skb))
return 0;
So it reaches sctp_inq_pop() still nonlinear. There, head_skb is only set
when frag_list is non-NULL. Otherwise chunks are bounded by
skb_tail_pointer(), which covers only the linear area:
} else if (chunk->chunk_end > skb_tail_pointer(chunk->skb)) {
/* Discard inside state machine. */
chunk->pdiscard = 1;
Such skbs can come from generic XDP with a frags-capable program:
netif_receive_generic_xdp()
netif_skb_check_for_xdp()
skb_cow_data_for_xdp()
skb_pp_cow_data()
veth native XDP can produce them as well. skb_copy_header() keeps gso_type
as SKB_GSO_SCTP, and the payload ends up in page frags with no frag_list.
If an AF_PACKET tap then clones the skb, the old skb_cloned() condition
linearized it. With this change, are the chunks past the linear head now
pdiscarded?
The AUTH reasoning in the commit message only applies when a frag_list
exists. Could the code still linearize when !skb_has_frag_list(skb)?
> +
> + if (!pskb_may_pull(skb, sizeof(struct sctphdr)))
> goto discard_it;
>
> /* Pull up the IP header. */
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20e1d469385153bcfa766080453e8d9c1d64c339.1795388574.git.lucien.xin%40gmail.com
Technical Details
Message-ID:
<179547753202.3135.11036747479037466293@kernel.org>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-369849-linux-kernel-netdev=dewy.ruReferences:
<20e1d469385153bcfa766080453e8d9c1d64c339.1795388574.git.lucien.xin@gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-369849-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net] sctp: unshare GSO skb frag_list members instead of linearizing Date: Mon, 23 Nov 2026 23:45:32 +0000 Organization: Usenet Network Message-ID: <179547753202.3135.11036747479037466293@kernel.org> References: <20e1d469385153bcfa766080453e8d9c1d64c339.1795388574.git.lucien.xin@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="4009531"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:a6ceN6M9tt6IEo0u006NH6CGCMk= sha256:uaJYANjVsW6oCeI9np7CqKo8BdtUlt0YqRBMrKUvX1Y= sha1:RkMZo8azElO+DRXcxt6MGGf0grY= sha256:l1/CL0DHYXkfercpktjBeaVGnN9YnsczSsbtFdkewkA= 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 677FE125DC9; Tue, 24 Nov 2026 02:45:50 +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 ke1fRJVqvmka; Tue, 24 Nov 2026 02:45:46 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-369849-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 AF741125DC7; Tue, 24 Nov 2026 02:45:37 +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 AE6DF221F0; Mon, 23 Nov 2026 23:45:35 +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=1795477534; b=2TJmwD+i6YplVyl5Z0QfAUuVMmJDfxidN781jffkKWB6R5HfRrphcQmOoSdde0MWPODH RncVU7+SzWe+LAT+isCN9moNnc0ouCzkaszfDuhRkjTW0rHh63H8e/LDCphRiK/OGaKfL 2Fzg9I/gPZK60Q+U9irQJ0GxzN4FzcvI6v2uNbduB2JiLZ4HcqXJlO8syjLfPUC0dAkao JXge39xfWVj1iMVwi2vKwhqGu9DPdKRAiStVrWdgcsDjSapYNQcbaatTHfkBZsm/Dqk67 D4lTBVjejrCpM2CYIqVH4QE0UraDpdBFuM1D4sSOmF8TTSkGppe8/eEI08jW575m9+Q== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795477534; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=r5+OgPsCyjeC9MKv74G7YxKH+Z743Xl2jrS1zHnIGuU=; b=RmqrRip6BrzrXXKb+93ZsOlccf2HD0dW64lmUbCnA1DTJipif8k5A99b7HYK0yW17kOt WWR+7meVlLoMKus5shffdmPGMP0KtS0dDbKSyRvWV796fJeIhATsAglm7denGSqUpllzb WEGqnBd2poPkHf0JFxWfx5tRAdc40bMbF8W3A4gdcpihYwBWk1SVoGD6w/H4c5Bvmx4vl bfxgA3NmHaMEZd6ng+2RfnRRMk+cLnu7aoqJNOySMz2UYWxPpWWLZUXSqvbUyQAZ6d2lb xjMsRPsTOrZ85mO4qUlQQXfBaBmg7zraB9gjjlBCfVTF8+ls4JaPKMJz4nsEU+fht5Q== 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=d87XWevT; 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 A3389606A31E; Mon, 23 Nov 2026 23:45:34 +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=d87XWevT 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=1795477533; b=25TQdxLKmS2QiaRLFNYzF4q4ccW1dwt5AC+2R3e+n8FXwdCFCoxaDn5GfveRJqIvX2LJ bAca6yTjfkG8+ckRWP6GBV8mrYzRXfK6tjIVYaMmMv810yC2TPfTGEVTqCOR67td4Unzb DeYTq9giG/YIro0ccNeuTo0QXR7J9aneqqqQU5mySrh5+7SCtLEYrKV27YujHlFWQblx4 bzeN5fF9R8y5bQYFErjZd+MfXHobTGSkNQyt0M4MutBlMiGi1BNHoas5rRszvHi9BVUYh KwVq/rGzE7i7dHU3DQcntU/YFZVIM5N47R4MTq223sZfgEri7G9tTrSJHvX3IQgNQOg== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795477533; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=r5+OgPsCyjeC9MKv74G7YxKH+Z743Xl2jrS1zHnIGuU=; b=Gu/9gzle9jC2bbiAuPbDoczZbFO5S6GdFqE3Pz+AJJUX4wvCYm/FwFnEu5xuWy6l9G2E mAuQTuMqqH78EOjnmiOht02/4fEm1jQSiXzmCYtZVGYfXxWEcevEGkZ38sdFg/mnO/uOp AIM9lF1zEeeosCHMKhWSLVYZuHvElqwlU6xYqjmJqud2qM4Rc+YgoN4KQ1IYAMxnTzGxW TYnfnom+mYRV4QQM7SmXUB2Vu8vVVumzdR03p67NXo3n/vheKw9lKZp5/+pXvhVeQWJI6 8SoSTlU4ACqagiNGAIwRRF6wp8Px+/kEWxJn/RyALApJNEEIE0j9+6fYmTqLWpTa3ng== 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=d87XWevT; 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 C010D606A326; Mon, 23 Nov 2026 23:45:33 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 77ABE1F000D0; Mon, 23 Nov 2026 23:45:32 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795477532; bh=r5+OgPsCyjeC9MKv74G7YxKH+Z743Xl2jrS1zHnIGuU=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=d87XWevTeVnp1yyijNQj/o/rxb3ELz5hwQm3F4PdqWKidGP+W8YOykjpBMWgDGC44 PxOpGJU96C/zcUxmmyxFguw/3/g9ioF7r+z6zwflHvRgIUfhd8wTb/7Mf0RSVJtog2 0SUvDW2KdzWDXNiBRhwVhoCtzLcJB2H57DqTV2niAMkc1s2NJVF1qw9bbI0UWmsig2 +iZp9IhYj7VMCb1JAFN04bHOERB8Q0KzjwnA+5OfNcf0YAxZx+Zr2EPE7uWJev9BeA xN8BPmoaOpZRyf49FJ9WLIpzmSxu7vdreGJQsNt7NAkDXg6f5n7VA3Fx8woF+sLtGR f5oXsA/JJXciw== X-Cc: netdev@vger.kernel.org, linux-sctp@vger.kernel.org, davem@davemloft.net, kuba@kernel.org, edumazet@google.com, pabeni@redhat.com, horms@kernel.org, marcelo.leitner@gmail.com X-In-Reply-To: <20e1d469385153bcfa766080453e8d9c1d64c339.1795388574.git.lucien.xin@gmail.com> X-sashiko-severity: High 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