Netdev List
 help / color / mirror / Atom feed
* [PATCH net] sctp: validate Cookie Preservative in the first pass
@ 2026-11-27  3:35 Sun Yiqi
  2026-11-27  3:39 ` netdev-bot+sinfo
  0 siblings, 1 reply; 2+ messages in thread
From: Sun Yiqi @ 2026-11-27  3:35 UTC (permalink / raw)
  To: netdev
  Cc: linux-sctp, marcelo.leitner, lucien.xin, davem, edumazet, kuba,
	pabeni, willemb, horms, trilobyte777, luoxiaoxing, Sun Yiqi

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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-27  3:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-27  3:35 [PATCH net] sctp: validate Cookie Preservative in the first pass Sun Yiqi
2026-11-27  3:39 ` netdev-bot+sinfo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox