linux/include/net/sctp
Xin Long e0b5252a59 sctp: fix auth_hmacs array size in struct sctp_cookie
The auth_hmacs array in struct sctp_cookie is supposed to store a complete
SCTP_AUTH_HMAC_ALGO parameter, which consists of a struct sctp_paramhdr
followed by N HMAC identifiers.

However, the array size was calculated using an extra 2 bytes instead of
sizeof(struct sctp_paramhdr), which is 4 bytes. When four HMAC identifiers
are configured, the HMAC-ALGO parameter stored in the endpoint is larger
than the auth_hmacs buffer in the cookie.

As a result, sctp_association_init() copies beyond the end of auth_hmacs
when initializing the association, corrupting the adjacent auth_chunks
field. This can lead to an invalid HMAC identifier being accepted and later
cause an out-of-bounds read in sctp_auth_get_hmac().

Fix the array size calculation by including the full SCTP parameter header
size.

Fixes: 1f485649f5 ("[SCTP]: Implement SCTP-AUTH internals")
Reported-by: Yuan Tan <yuantan098@gmail.com>
Reported-by: Xin Liu <dstsmallbird@foxmail.com>
Reported-by: Zihan Xi <xizh2024@lzu.edu.cn>
Reported-by: Ren Wei <enjou1224z@gmail.com>
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Link: https://patch.msgid.link/634a0de0d5de29532915e6d47c92a0cbc206e03f.1783707155.git.lucien.xin@gmail.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2026-07-17 12:27:53 +02:00
..
auth.h sctp: Remove unused declaration sctp_auth_init_hmacs() 2025-11-14 18:00:34 -08:00
checksum.h sctp: use skb_crc32c() instead of __skb_checksum() 2025-05-21 15:40:16 -07:00
command.h sctp: add the probe timer in transport for PLPMTUD 2021-06-22 11:28:52 -07:00
constants.h sctp: Convert cookie authentication to use HMAC-SHA256 2025-08-19 19:36:26 -07:00
sctp.h sctp: hold socket lock when dumping endpoints in sctp_diag 2026-06-17 16:41:34 -07:00
sm.h sctp: Remove unused sctp_assoc_del_peer and sctp_chunk_iif 2025-05-05 16:51:12 -07:00
stream_interleave.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 104 2019-05-24 17:39:00 +02:00
stream_sched.h sctp: Constify struct sctp_sched_ops 2025-10-28 17:50:55 -07:00
structs.h sctp: fix auth_hmacs array size in struct sctp_cookie 2026-07-17 12:27:53 +02:00
tsnmap.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 104 2019-05-24 17:39:00 +02:00
ulpevent.h sctp: fix typo sctp_ulpevent_nofity_peer_addr_change 2020-05-27 15:08:02 -07:00
ulpqueue.h sctp: remove unnecessary NULL check in sctp_association_init() 2022-10-20 21:43:10 -07:00