Article View: linux.kernel.netdev
Article #23790Re: [PATCH net] sctp: validate Cookie Preservative in the first pass
From: netdev-bot+sashiko
Date: Sat, 28 Nov 2026 03:37
Date: Sat, 28 Nov 2026 03:37
126 lines
12290 bytes
12290 bytes
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 fix is incomplete.
- [Low] The lines added to sctp_verify_init() are badly indented.
--
sctp: validate Cookie Preservative in the first pass
This commit adds a length check for the Cookie Preservative parameter to
the first parameter walk in sctp_verify_init(). A mismatched length is
reported through sctp_process_inv_paramlength(). The goal is to stop
sctp_process_param() from reading past a short parameter, even when the
second verification pass returns early.
Link: https://lists.openwall.net/netdev/2026/07/29/316
> diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c
> index ba0474c2a0bc8..01b1eea0222c4 100644
> --- a/net/sctp/sm_make_chunk.c
> +++ b/net/sctp/sm_make_chunk.c
> @@ -2317,6 +2317,12 @@ int sctp_verify_init(struct net *net, const struct sctp_endpoint *ep,
> return sctp_process_inv_mandatory(asoc, chunk, errp);
>
> sctp_walk_params(param, peer_init) {
> + /* Validate the length even if the second pass stops early. */
> + if (param.p->type == SCTP_PARAM_COOKIE_PRESERVATIVE &&
> + ntohs(param.p->length) != sizeof(*param.life))
[Severity: High]
Other fixed-length parameters have the same problem. Does this patch
cover them?
This check only handles SCTP_PARAM_COOKIE_PRESERVATIVE. The length checks
for SCTP_PARAM_ADAPTATION_LAYER_IND and SCTP_PARAM_SET_PRIMARY are still
only in sctp_verify_param(), which runs in the second pass.
As the commit message says, the second pass can stop early. An
unrecognized parameter with action bits 00 or 01 makes
sctp_process_unk_param() return SCTP_IERROR_ERROR:
net/sctp/sm_make_chunk.c:sctp_process_unk_param() {
...
case SCTP_PARAM_ACTION_DISCARD:
retval = SCTP_IERROR_ERROR;
break;
...
}
sctp_verify_init() then returns 1 before it checks any of the later
parameters:
case SCTP_IERROR_ERROR:
return 1;
Say a peer sends an INIT that has an unknown parameter (action 00 or 01)
followed by a 4-byte ADAPTATION_LAYER_IND. This check in
sctp_verify_param() is never reached:
case SCTP_PARAM_ADAPTATION_LAYER_IND:
if (ntohs(param.p->length) != sizeof(*param.aind)) {
The path then continues:
sctp_sf_do_5_1B_init()
sctp_verify_init() returns 1 at the unknown parameter
sctp_process_init() walks every parameter
sctp_process_param()
asoc->peer.adaptation_ind = ntohl(param.aind->adaptation_ind);
This reads 4 bytes past the end of the parameter. sctp_pack_cookie() then
copies the value into the State Cookie:
cookie->c.adaptation_ind = asoc->peer.adaptation_ind;
The cookie is sent back to the peer in the INIT-ACK. Isn't that the same
disclosure to the peer that the commit message describes?
SET_PRIMARY (with asconf_enable set) seems to get past the checks the
same way. For a parameter length of 4 to 7, this check in
sctp_process_param() is computed in size_t and wraps:
addr_param = param.v + sizeof(struct sctp_addip_param);
if (ntohs(addr_param->p.length) >
ntohs(param.p->length) - sizeof(struct sctp_addip_param))
break;
The out-of-bounds addr_param is then read through addr_param->p and
af->from_addr_param().
Would one of these options work instead?
- validate every fixed-length parameter in the first pass
- have sctp_process_init() and sctp_process_param() check bounds
themselves
- have sctp_process_init() stop where the second verify pass stopped
> + return sctp_process_inv_paramlength(asoc, param.p,
> + chunk, errp);
[Severity: Low]
This isn't a bug, but the indentation of the added lines doesn't follow
kernel coding style or match the rest of sctp_verify_init(). The condition
continuation and the return are indented too far. Also, "chunk, errp);"
doesn't line up with the open parenthesis. checkpatch will probably warn
about this.
> +
> if (param.p->type == SCTP_PARAM_STATE_COOKIE)
> has_cookie = true;
> }
--
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261127033534.175-1-sunyiqi2%40huawei.com
Technical Details
Message-ID:
<179583702392.3135.14690679679244034273@kernel.org>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-373023-linux-kernel-netdev=dewy.ruReferences:
<20261127033534.175-1-sunyiqi2@huawei.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-373023-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net] sctp: validate Cookie Preservative in the first pass Date: Sat, 28 Nov 2026 03:37:03 +0000 Organization: Usenet Network Message-ID: <179583702392.3135.14690679679244034273@kernel.org> References: <20261127033534.175-1-sunyiqi2@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="872499"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:2cSLWCeg2ek7OnxX74MlAofNnW0= sha256:5+du8mr8zwLKTB0J1xletiwOWAZ2Q7vC5bXpZYZJVCw= sha1:iX7IEv367s8n5h99csWQGelx1G8= sha256:jxeMRs4motTr5otaSUEtimQMhM5bKRlsePW4jVhc/aM= 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 62A31125F6F; Sat, 28 Nov 2026 06:37:29 +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 mla7Zv_EP3hs; Sat, 28 Nov 2026 06:37:25 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-373023-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 CC6B9125F6B; Sat, 28 Nov 2026 06:37:14 +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 3BA9C2BADF; Sat, 28 Nov 2026 03:37:07 +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=1795837026; b=fH+SKOmuVbZC3jDpLxpHWf9xZaagcZ4LU0yBlQC7131dj5KvDWsFTRrexTV4jHklO/Uk DzEnHZ5mdcKbv8UKucCThnsQE/hrIwq93SMHN2u1jck70gKNDxXgPCcYZSrCMS97PMHrN a/EojH4nqR/mxee+7O8+pfCeVCnfcthlVHQElIhMp+uF8lYqKxAQUT0OQ3gTi6yugm+1Y xCfD5qYWpZ66IX2XZUBhgEmBJnYd16z4bxp03EBIS6XuDNBjflBZz95sILQQ+jRuxObne QxapF9ECduQngme/8yjzmzlKSqCoUktA+GLVFlC6Q8LCz/kgg+/GWhc9RYaLc6ThFbQ== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795837026; 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=umri0wGVOp6EjZGjfBMAhWDZPVdQFdgQPgw3pddiSsg=; b=2TqZl3cx7VZj3osBYYCmIRnFxUxW57UDVabZa7/cbVlHOF1hcV8XhvRKkZAdX+ihSdZm LA5ztjzERese36uIX3RaasztWn7AGdZVBYaSDBGNhb0LpbjrV4BN8tq7/xtQDBzRDrmM+ zbSPAbDpYqA+cqc5Wa3tNf45uj6RUiZujqltpOuzm6d0o3DQfKpGCdKfsXQYkkknrpvZW ZP+D25pJcUHJhBmi/5aBv1MQIiWPQndKHQwC+vk3D1/hWHyDByAsJFrPGnRwESmka0SRG AW6P9ZhWhlGTu3R8wOMtMAd5NCylhNGiKRMBfm/jiMmuCrnoBUyZ/v9eIl2cA9nD/fw== 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=f2hgCn4h; 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 31852606A329; Sat, 28 Nov 2026 03:37:06 +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=f2hgCn4h 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=1795837025; b=SmvmJTEDpWDIRiEW4M64yK9SlduY4zGcER4ifqunny1CeKFJrlrUSan16bCEl8CCneHo QSnFVTLsjCADgQbYD54L+doXD2VPXUHbKFSmJDVN3+WLBZdr5iPK1rI47Iwl5mwPa49Tj /tZVMNC6sZ0H+o5ANsX9n4gWooYRIIs48cR6oeDA+LfaeU2Wsd7Ap71p9HGFCnBcsBN3h oAx6jdY9j4kWckSOVNnEAs/OIfs/5vMQiIdAHoN93DRpK6RJhXevbp4SBzGnPnC+1z2Sh SpE3kPqA/7E8R5+aUgwsKHg+2QNxsxA3wbhYmuHzSCL0EY2rr74dzlq/QZ6DmyfOGrw== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795837025; 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=umri0wGVOp6EjZGjfBMAhWDZPVdQFdgQPgw3pddiSsg=; b=SyuYV3+ppZLcQmfOg4oKLirxTNrvQcbFakg3oZ2AT2EHNxvj9AXXo/xfClBbnmp+44Z5 A70rb8KKqEWF2qwwANlZdnBnGKmVcWGS8zYm2Ml8x5dAglPIYz75dstK7HWh3RzsE9mRm SuD0GHQm7Ms8HYU8cnpp30p5CsUegzzO2Xz8AFNCgQPn16xPI/moSf+opZ4FpYb3d+LB/ 3EhVBhccXiQ8oZH6Ena6YkuIHtVhc+5jtf8E7pfTjg1JTsHkKQEGSuZLE66kobRA27sRN rRaR/Fecdny2C5rUPpeUFQTil/gZf7oz0J33eBuuCPo6zlz4d/s6pSW1pnHakzBnFyw== 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=f2hgCn4h; 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 4E21B606A31C; Sat, 28 Nov 2026 03:37:05 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 661621F00893; Sat, 28 Nov 2026 03:37:04 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795837025; bh=umri0wGVOp6EjZGjfBMAhWDZPVdQFdgQPgw3pddiSsg=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=f2hgCn4hwFktXSy/kAg24lEmmtOfuvFZbDuL1jDjSVEcGNeIT3HJAcq7S4s4qBcWi 35cQtOZTFYkUckXY8vDo/2r/fSJzASWVDxqDKDwAg73r+h8NdDpMdXisoIuOh23pAy h1O5cTMQ5bgloI1sUMQbcvY85/J8HRVBfPZ0Uw8cZLeR3HnYMdu5GNJHdWRv7Glebs qa7LnnNwao9jfwb6yEjyZoXHrPP9RId/XzBK1AlZlmRjvEPTgtIOFmk9Kat+SkD+iy s64++sSf7uewEsuUWdp/6uLvBNWv8IuKkrUGKtETkz24j84g6ZLcbcHXwduEu1bbbO 2phwpkPdaSvMw== X-Cc: netdev@vger.kernel.org, linux-sctp@vger.kernel.org, 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, trilobyte777@gmail.com, luoxiaoxing@huawei.com X-In-Reply-To: <20261127033534.175-1-sunyiqi2@huawei.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