Article View: linux.kernel.netdev
Article #12841Re: [PATCH net] sctp: linearize GSO skb when frag_list skbs are shared
From: netdev-bot+sashiko
Date: Sun, 08 Nov 2026 21:01
Date: Sun, 08 Nov 2026 21:01
197 lines
15106 bytes
15106 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] The fix is incomplete because sctp_rcv() only tests the first
frag_list member for sharing.
- [Medium] sctp: skb_linearize() on GSO skb in sctp_rcv() breaks SCTP-
AUTH verification
- [Low] The comment above the changed condition in sctp_rcv()
(net/sctp/input.c:116-119, from 4c2f24549644) gives CRC cost as the…
--
sctp: linearize GSO skb when frag_list skbs are shared
This patch widens the linearization condition in sctp_rcv(). GSO packets
whose frag_list head skb is shared are now linearized as well. The aim is
to stop SCTP from working in place on frag_list skbs shared through
pskb_copy() (for example by the TEE target), which can end in a BUG_ON in
__pskb_pull_tail().
> diff --git a/net/sctp/input.c b/net/sctp/input.c
> index 9494cfa51106c..db3c7818724b8 100644
> --- a/net/sctp/input.c
> +++ b/net/sctp/input.c
> @@ -117,8 +117,13 @@ int sctp_rcv(struct sk_buff *skb)
> * it's better to just linearize it otherwise crc computing
> * takes longer.
> */
[Severity: Low]
This isn't a bug, but the comment above this block still gives CRC cost
as the only reason to linearize:
/* If the packet is fragmented and we need to do crc checking,
* it's better to just linearize it otherwise crc computing
* takes longer.
*/
The new frag_list clause only matters when is_gso is true. In that case
sctp_rcv_checksum() is skipped anyway. The clause is there for
correctness, not for CRC speed.
Could the comment be updated to say that GSO packets with shared frag_list
skbs must be linearized?
> - if (((!is_gso || skb_cloned(skb)) && skb_linearize(skb)) ||
> - !pskb_may_pull(skb, sizeof(struct sctphdr)))
> + if (!is_gso || skb_cloned(skb) ||
> + (skb_has_frag_list(skb) && skb_shared(skb_shinfo(skb)->frag_list))) {
[Severity: High]
Is it enough to check only the first frag_list member here?
pskb_copy() goes through __pskb_copy_fclone()->skb_clone_fraglist(),
which takes a reference on every member of the chain:
net/core/skbuff.c:skb_clone_fraglist() {
skb_walk_frags(skb, list)
skb_get(list);
}
So after nf_dup_ipv4()->pskb_copy() in the TEE target, every frag_list
member is shared, not only the head.
Something may pull into the frag_list before sctp_rcv() runs. Examples
are nft_payload_set_eval() or tcf_pedit_act() through
skb_ensure_writable(), and bpf_skb_pull_data(). In that case
__pskb_pull_tail() forks a partially eaten shared head:
net/core/skbuff.c:__pskb_pull_tail() {
...
if (skb_shared(list)) {
/* Sucks! We need to fork list. :-( */
clone = skb_clone(list, GFP_ATOMIC);
...
insp = list->next;
list = clone;
}
...
/* Free pulled out fragments. */
while ((list = skb_shinfo(skb)->frag_list) != insp) {
skb_shinfo(skb)->frag_list = list->next;
consume_skb(list);
}
/* And insert new clone at head. */
if (clone) {
clone->next = list;
skb_shinfo(skb)->frag_list = clone;
}
...
}
The pulled copy then has a private clone at the head of its frag_list,
while the later members still have users == 2. Because consume_skb() drops
a reference on the old head, the twin skb's head also goes back to
users == 1. An eat that consumes whole leading members ends in the same
state.
Both outer skbs stay uncloned with is_gso true. The new check therefore
returns false in both of them and skb_linearize() is skipped.
sctp_inq_pop() then walks the chain and calls skb_pull() on each member:
net/sctp/inqueue.c:sctp_inq_pop() {
...
if (chunk->skb->next) {
chunk->skb = chunk->skb->next;
goto new_skb;
}
...
skb_pull(chunk->skb, chunk->chunk_end - chunk->skb->data);
...
skb_pull(chunk->skb, sizeof(*ch));
...
}
It also writes SCTP_INPUT_CB() into those members. Can the two SCTP
receive paths, possibly on different CPUs, end up changing data, len and
cb of the same shared sk_buff structs?
Suppose either copy is linearized later, for example because a tap made
it skb_cloned(), or because of another pull into the frag_list. Then
__pskb_pull_tail()->skb_copy_bits() walks members whose len has already
been reduced. Would that still return -EFAULT and hit
BUG_ON(skb_copy_bits(...)), the same panic this patch is meant to fix?
The commit message talks about sharing of "the frag_list skbs" in general,
but the check only looks at the head. Should this walk every member with
skb_walk_frags() and linearize if any of them is skb_shared()?
> + if (skb_linearize(skb))
> + goto discard_it;
> + }
> +
> + if (!pskb_may_pull(skb, sizeof(struct sctphdr)))
> goto discard_it;
>
> /* Pull up the IP header. */
[Severity: Medium]
Does linearizing an SCTP GSO skb here lose the per-segment boundaries
that the SCTP-AUTH check depends on?
On transmit, sctp_packet_pack() builds each GSO segment in its own nskb
and appends it to skb_shinfo(head)->frag_list. When the association
uses AUTH, the HMAC is computed over that single nskb only:
net/sctp/output.c:sctp_packet_pack() {
...
if (auth) {
if (sctp_auth_calculate_hmac(tp->asoc, nskb, auth,
packet->auth->shkey, gfp)) {
...
}
After skb_linearize() the frag_list is gone. sctp_inq_pop() then no
longer sets chunk->head_skb, and it treats all the concatenated
segments as one SCTP packet. When sctp_sf_authenticate() checks the
first AUTH chunk, it passes chunk->skb to sctp_auth_calculate_hmac(),
which hashes up to the tail of the whole linear buffer:
net/sctp/auth.c:sctp_auth_calculate_hmac() {
...
data_len = skb_tail_pointer(skb) - (unsigned char *)auth;
...
}
That range now covers every following segment as well, so the digest
cannot match. sctp_sf_authenticate() returns SCTP_IERROR_BAD_SIG, and
sctp_sf_pdiscard() discards the remaining chunks, which now means all
segments of the GSO packet.
The existing skb_cloned() leg already behaves this way. The new clause
extends it to every GSO packet whose frag_list was shared by
pskb_copy(). If I read nf_dup_ipv4() right, with the TEE target that
includes the original skb that keeps going to the local socket, not
only the duplicate. skb_clone_fraglist() takes a reference on members
that both skbs point to, so both see a shared frag_list head. On
loopback or veth with AUTH enabled, a TEE rule would then turn the
BUG_ON into silent drops of authenticated traffic.
Would it be better to unshare the frag_list members instead, for
example by replacing each shared member with a private copy, so the
segments stay separate? Or is there another way to get an exclusive
copy without merging the segments into one SCTP packet?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/9997493edadfe9faa713c73de9c70e36cee9ffea.1793902911.git.lucien.xin%40gmail.com
Technical Details
Message-ID:
<179417171282.994134.16986580743973805142@kernel.org>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-358853-linux-kernel-netdev=dewy.ruReferences:
<9997493edadfe9faa713c73de9c70e36cee9ffea.1793902911.git.lucien.xin@gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-358853-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net] sctp: linearize GSO skb when frag_list skbs are shared Date: Sun, 08 Nov 2026 21:01:52 +0000 Organization: Usenet Network Message-ID: <179417171282.994134.16986580743973805142@kernel.org> References: <9997493edadfe9faa713c73de9c70e36cee9ffea.1793902911.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="202845"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:gyVoktEmW6IC1KbX9Zo1kKOwWZw= sha256:+LCOwgKR7WoBOMa/f1lbPfFZREzGKM3aZICFV73qs0s= sha1:d/aQmHQf05YFOx9lOLpW13pff48= sha256:czmkJTyPISb0Eh4PnVMrhUTBBYGz80TVvcgph/eG3Vw= 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 EDDC21135FA; Mon, 9 Nov 2026 00:03:24 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.5 X-Spam-Status: No, score=-3.5 tagged_above=-9999 required=6.31 tests=[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, URIBL_BLOCKED=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 gvZacCyFqKgC; Mon, 9 Nov 2026 00:03:13 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-358853-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 tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id AA1211135F6; Mon, 9 Nov 2026 00:03:03 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by tor.lore.kernel.org (Postfix) with ESMTP id 019FC32FF2; Sun, 8 Nov 2026 21:01:59 +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=1794171715; b=czcChF5E6H0915O8qFGJb/Z3e88V3DstIdOqFWNXuhVQZOten555rdYXGFp4/Kt9GC9T LPk9Rc6tdlndxeEAXOpZYfs3Q6B+i8qeYy+rAt8nSqJUI9j2RmUsvpVjqHrFNwzSRE3mg AJvBzc43CYfqXjVTsmCvSJriTjQdzQ/0+Qr/Og+yKcPdVtls6zPQ/e3ZVeYpdesCDX+0d rGfon41H0G1ijBnJNg3boz5O8NMFS9TaduV+HBVrilIdxbtBwUcwBwZLO3qeNXquku9s5 uzINzE9s0bjcCRoh7ANslvTxNdhytpazckNEHSnZDjIB83InhsPDAEtnfgudif5UVsg== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794171715; 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=61lcyeN+fR5ohV0iDvNp+XpkFOW3xkBVHyTuHv2TNXA=; b=hIG3WS92t5cjomll0G1aLCSFN/fw8ZeU9SzbKHpl3lLfkYd9IlTMWHILflCI2JmTl3Tg JsHCF9TQ13xnoTC8uTLsYvz4Mlu86M674Kqnm52S49gZoxZg8klaX507WhPSxBhh7XihH 58c9jE3mzN/E0gx6onJ/S1mT34jFy0E6dciNAbXXWJ7Fh6k/daYfaswoYETfgVb9gJnd+ t3i/m7eKI0RzFlRTxnFvVxFzUIotvXFdDYYV2AwxGk0Amk56ecNzRRWveG3K2kRRuCcSQ gY6IF2snrhl+jCtMavpRAi291XVwuUcIRk8PbnKrfsd+e2JhSDp0JicYhTJ7Dw+NuqQ== 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=DV88OfcA; 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 8DFCD606D804; Sun, 8 Nov 2026 21:01:55 +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=DV88OfcA 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=1794171714; b=1UImwF6dMGmRl+BrT/PJkCfNp4pYYxyC5ydshbB+3iVM/cWulaIfBb/wqSxQFQXS3NP1 YE7+Uh1j2U9mjvpAgdzQywxPaO69gtt/PHdTXOiI88UWc7rZwaSpbS8cN60F5NPzzbynO ecBOeU7iFBqPF+Vu/RXhHIlA6x49EleTFdGdDlC2sl/loezy09jR+dZZ0VNb/kKltOb0X rq3CZJ6haIfq7W5WW36vVQVqj42Pe+GiERqRwSz4BdGU1Y0YchcSRNzoko1wk6kgKdq+x Es3SWGHZ/pxKH1odIoVRP4ijFu0n7x1UCXM31LwHO6zzrFrsBUevN6VbYcbfERe6+Hg== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794171714; 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=61lcyeN+fR5ohV0iDvNp+XpkFOW3xkBVHyTuHv2TNXA=; b=xEP93417m1uKWCGCr3maTwQy8tQF3oJ7U0ppAxwKPav0OIeMFswxQuPZb5LQmhdul/N4 LVSdzxY/b2reSjXCRKU0vwKBZ1fJ5TTzL4tkxnPel7abV4sh0EU5ib1ejMI4PFg42IjlN RtaiS5SkRuKkAMZFORLGxOvebNzD/7F+LCFTAEV+fIwEv9m3ZuTvglhGTPqBgKJaLmjvo gmmi8omJPm6hse7ttb8C4MSy9u4R0uMMFctzvrNvdCzPDvcBCXziU8RPNd37X0UxhDgPc 6Xx1s5WMSbJ0/nsTgLwbocfrAdk+SIo0Q5pf/59qmo+t73oMhlaIsi4rq78pENmZBAw== 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=DV88OfcA; 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 5457A606A333; Sun, 8 Nov 2026 21:01:53 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 508BF1F0089F; Sun, 8 Nov 2026 21:01:53 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1794171713; bh=61lcyeN+fR5ohV0iDvNp+XpkFOW3xkBVHyTuHv2TNXA=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=DV88OfcA7SzB4bNhTuotM542YZ0UVrXMI6p/ykJIbO+vE49JAGvjFTutrEDSF3j39 Z1EqOjNkxopKYrB8xOpBKjFFVr5wNVHMiRbWB7VwoVWzB9HfW14+yzsEJJKmdZUgeY mHAbUaYISZ5z5+Fw6h2ta9L7YAcq2tbE+/t8Isac2QkSCxYT0+9jXdIEL7EU+jKdQq tRx431gN1AtbQqJraPtf3qsHLrUEk+EENHN60W+47BDBDVAsdieFtCz09GOMElQLWf DJiQS8EN5ruTjdZlTb0xIjRm9+x2g4YmWGAGO9fmedz7O32WB0mH8CUOSVhxLkAYVZ r4b/zC2pDtixA== 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: <9997493edadfe9faa713c73de9c70e36cee9ffea.1793902911.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