From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796350727; b=oA40LjvyNOSqd4Sqs1pzRvSvJHucE0BMz+MmthFHfi/WfI8fUQiQXmMl/eLEdj/1Kbgi Ghh6WfeDbHUBE4l8p4GrLV2V3NLOfbsLEAZO5hjtMX7LqgRkqFFKPykB5vKVolengjt/b MJcOQJ8U4oqZQ/cLhmUb0LNHV0SxYLC4yxy+hdzwAP3vjP8snmJK6zmKVZb/HrIQkJ9eW ZGftlCnXqQU7AXFfUUOlud3wH7RYqJseNmY1gjKrZz3MQg7xe1u3+7gDkY0tX5kvP3w9f 2P7PXZ6ItxN+kobBtdMFmpJlmLG7NshcV7rIzOaN+DPvBjY6VvBXQTkKtFV/OgntP2w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796350727; 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=VQsHSmTwo/9vPkAhyeRqnOC92c67151SFA1QOqdWXik=; b=HGk96qSeG2B2RVrTRnBsN+FtaV2mOjlxzVqAqYRddwGkY8mhj4oih4i+nCqA8at3Paey tWH0QQzrXq423EZQuVnAbfgqrOwSOW9qrPwxGkk30KxQsz/EaMcdNSmS6vMD8u1m5qEJC 167l8puz92PqWEPYxB4eMRTHOFVOh+azJnEBXVL7jZ9JBgpg3Ke3ysMEJBJalebfN4tg+ lD4V+yZTFuR8lOHJbc9s7A6Uv0y6V//WlesLxfj7J6ZQ2dvBflYtBQbmFfN7KuGPH9VLW IZhwAIkAFksFGTt2w8JPjHq/Z7kMYBFIWrowtdll96lW96PvIcTkbabegEh1J4FuXUw== 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=b0bUPeMS; arc=none smtp.remote-ip=100.103.45.18 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 A535D606A32C; Fri, 4 Dec 2026 02:18:47 +0000 (UTC) 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=b0bUPeMS Received: by smtp.kernel.org (Postfix) with ESMTPSA id A6F751F000C2; Fri, 4 Dec 2026 02:18:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796350727; bh=VQsHSmTwo/9vPkAhyeRqnOC92c67151SFA1QOqdWXik=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=b0bUPeMSTfTmIDIz9xFymbP6NtWWVvqUA2pLc83czWwq1Xw6k56+SJRuNyr41zWPo RYGTerspI65QceoxgqEIFOh+cAM61mNLexKEdQrMLWbCpKNHRJm5dUXGAYV1GXf0P5 0w8pkGdIfqCW2PUjkvwwoNSdQyWq13qXsJ5AXCq01u53lGzbY94NcKAeyF6n+/lhW0 Cw0UzxTPDst+rLjLRxelJZjZsdojrKzlQG4bPk0t6Ukse4miMYL6icW3bywYMq7tv6 j7Mx86FDS7VKsS/YORTBwLGNuVGo8VLp5a+rrEP8635OoymEhNbJAkkOzUaHkn5327 85DwHNs2UI27A== Subject: Re: [PATCH net] sctp: validate SACK gap-ack block ranges From: netdev-bot+sashiko@kernel.org To: shawnq1@163.com Cc: marcelo.leitner@gmail.com, lucien.xin@gmail.com, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, willemb@google.com, horms@kernel.org, linux-sctp@vger.kernel.org, netdev@vger.kernel.org Date: Fri, 04 Dec 2026 02:18:46 +0000 Message-ID: <179635072618.3146.12542354371056584235@kernel.org> In-Reply-To: <179613469562.187341.14965162957276514602.1796134695.3-1-shawnq1@163.com> References: <179613469562.187341.14965162957276514602.1796134695.3-1-shawnq1@163.com> X-sashiko-severity: Medium Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider. Critical: 0 · High: 0 · Medium: 1 · Low: 3 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). - [Medium] The commit message understates what the new check does, and the drop behaviour it chose has costs. - [Low] The patch fixes a bug that a remote peer can trigger. - [Low] The commit message gives 'RFC 9260, Section 12.4' as the requirement for the new abort in sctp_sf_eat_sack_6_2()… - [Low] The commit body is formatted as an email and would end up in git history that way. -- sctp: validate SACK gap-ack block ranges This patch adds a check of the Gap Ack Blocks to sctp_sf_eat_sack_6_2(), run before the SACK is queued for processing. A block with a zero start, an inverted range, or a start at or below the previous block's end causes the packet to be discarded. A block that ends past the last sent TSN aborts the association. > The patch validates Gap Ack Blocks before processing the SACK. It > discards zero, inverted, overlapping, or out-of-order ranges. If a > well-formed block acknowledges a TSN that has not been sent, the > association is aborted as required by RFC 9260, Section 12.4. [Severity: Low] Is RFC 9260, Section 12.4 the right reference for this abort? As far as I can tell, that section is "Protection of Non-SCTP-Capable Hosts" in the Security Considerations. It doesn't seem to require an abort when a Gap Ack Block acknowledges a TSN that hasn't been sent. I haven't been able to check the RFC text directly, so this needs confirming. SACKs that used to be tolerated now tear down the association with ECONNABORTED. Could the commit message cite the normative text that requires this? If that text is only a SHOULD or MAY, could the message say so? [ ... ] > Apply the supplied fix.patch and rebuild the kernel: > > git -C linux apply --check sctp.patch > git -C linux apply sctp.patch [Severity: Low] This isn't a bug, but the script downloads fix.patch and then applies sctp.patch, so it won't work as written. The commit body is also formatted as an email. It opens with "Hello," and has "Thanks, Shawn Shao" after the Signed-off-by line, and both would end up in git history. Could the greeting, the closing and the long reproduction script move below the --- line, or be trimmed? The tested version string "v7.3-23903-g7cd8495c0f162 (Linux 7.4.0-rc4)" also looks inconsistent. [ ... ] > Signed-off-by: Shawn Shao [Severity: Low] Should this have a Fixes: tag? The unchecked subtraction being guarded against dates back to the initial git import: net/sctp/outqueue.c:sctp_sack_update_unack_data() { ... for (i = 0; i < ntohs(sack->num_gap_ack_blocks); i++) { unack_data -= ((ntohs(frags[i].gab.end) - ntohs(frags[i].gab.start) + 1)); } ... } sctp_outq_sack() has long assumed that the last block holds the highest end, which the new ordering check now enforces: highest_tsn += ntohs(frags[gap_ack_blocks - 1].gab.end); Something like this would help stable backporters pick up the fix: Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") > diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c > index 6a4205de0aa69..79d297af661d4 100644 > --- a/net/sctp/sm_statefuns.c > +++ b/net/sctp/sm_statefuns.c [ ... ] > @@ -3497,6 +3501,24 @@ enum sctp_disposition sctp_sf_eat_sack_6_2(struct net *net, > return SCTP_DISPOSITION_DISCARD; > } > > + /* Gap Ack Blocks must describe sent TSNs in ascending order. */ > + frags = (union sctp_sack_variable *)(sackh + 1); > + num_blocks = ntohs(sackh->num_gap_ack_blocks); > + max_offset = asoc->next_tsn - ctsn - 1; > + for (i = 0; i < num_blocks; i++) { > + start = ntohs(frags[i].gab.start); > + end = ntohs(frags[i].gab.end); > + if (!start || start > end || (i && start <= last_end)) > + return sctp_sf_pdiscard(net, ep, asoc, type, arg, > + commands); [Severity: Medium] Should a single bad block discard the whole packet here? sctp_sf_pdiscard() queues SCTP_CMD_DISCARD_PACKET, and sctp_cmd_interpreter() handles that command by marking the entire packet: net/sctp/sm_sideeffect.c:sctp_cmd_interpreter() { ... case SCTP_CMD_DISCARD_PACKET: /* We need to discard the whole packet. * Uncork the queue since there might be * responses pending */ chunk->pdiscard = 1; ... } After that, sctp_inq_peek() and sctp_inq_pop() stop returning the remaining chunks of the packet: net/sctp/inqueue.c:sctp_inq_peek() { ... if (chunk->singleton || chunk->end_of_packet || chunk->pdiscard) return NULL; ... } So SCTP_CMD_PROCESS_SACK is never queued, and the SACK's otherwise valid Cumulative TSN Ack and a_rwnd are ignored. ctsn_ack_point doesn't advance, the peer rwnd isn't updated, and the transmitted queue isn't freed. Any DATA or control chunks bundled after the SACK in the same packet are dropped too. Suppose a peer always sends blocks in this form. Would its SACKs then always be ignored? The cumulative ack would never move, and the association would eventually fail on the T3-rtx retransmission limits. Before this patch, sctp_check_transmitted() and sctp_acked() matched each block on its own, so these SACKs were still processed. The out-of-order cumulative ack check just above returns SCTP_DISPOSITION_DISCARD, which drops only this chunk. Would that, or skipping the bad block, fit better here? The commit message says the patch "discards zero, inverted, overlapping, or out-of-order ranges". In practice the whole packet is dropped. RFC 9260 Section 3.3.4 also seems to say only that Gap Ack Blocks SHOULD be isolated. Is strict ascending, non-overlapping order actually required? > + if (end > max_offset) > + return sctp_sf_abort_violation(net, ep, asoc, chunk, > + commands, err_str, > + sizeof(err_str)); > + > + last_end = end; > + } > + > /* Return this SACK for further processing. */ > sctp_add_cmd_sf(commands, SCTP_CMD_PROCESS_SACK, SCTP_CHUNK(chunk)); > -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/179613469562.187341.14965162957276514602.1796134695.3-1-shawnq1%40163.com