From: Sun Yiqi <sunyiqi2@huawei.com>
To: <netdev@vger.kernel.org>
Cc: <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>,
Sun Yiqi <sunyiqi2@huawei.com>
Subject: [PATCH net] sctp: validate Cookie Preservative in the first pass
Date: Fri, 27 Nov 2026 11:35:34 +0800 [thread overview]
Message-ID: <20261127033534.175-1-sunyiqi2@huawei.com> (raw)
The Cookie Preservative parameter is eight bytes long, including a
32-bit lifespan increment. The generic SCTP parameter walk accepts
shorter parameters, so sctp_process_param() can read beyond the
parameter and expose data to the peer.
Validate the fixed length during the first parameter walk in
sctp_verify_init() and use the existing invalid-parameter-length
handler for mismatches. The second pass can return success before
checking all parameters, while sctp_process_init() walks the list
again. Checking the length in the first pass covers that path too.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Link: https://lists.openwall.net/netdev/2026/07/29/316
Signed-off-by: Sun Yiqi <sunyiqi2@huawei.com>
---
net/sctp/sm_make_chunk.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c
index ba0474c2a0bc..01b1eea0222c 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))
+ return sctp_process_inv_paramlength(asoc, param.p,
+ chunk, errp);
+
if (param.p->type == SCTP_PARAM_STATE_COOKIE)
has_cookie = true;
}
--
2.51.0.windows.1
reply other threads:[~2026-11-27 3:35 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261127033534.175-1-sunyiqi2@huawei.com \
--to=sunyiqi2@huawei.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-sctp@vger.kernel.org \
--cc=lucien.xin@gmail.com \
--cc=luoxiaoxing@huawei.com \
--cc=marcelo.leitner@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=trilobyte777@gmail.com \
--cc=willemb@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox