* [PATCH net] sctp: validate the Unrecognized Chunk cause length
@ 2026-12-02 16:50 Andrew Stellman
0 siblings, 0 replies; only message in thread
From: Andrew Stellman @ 2026-12-02 16:50 UTC (permalink / raw)
To: Marcelo Ricardo Leitner, Xin Long
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Willem de Bruijn, Simon Horman, linux-sctp, netdev
From: Andrew Stellman <astellman@stellman-greene.com>
sctp_cmd_process_operr() reads the chunk type inside an Unrecognized
Chunk cause without checking the cause length. A 4-byte cause passes
sctp_walk_errors(), so the type byte is read from past the cause. In
the case run, it comes from an ASCONF chunk bundled after the 8-byte
ERROR chunk, and asconf_capable is cleared.
Check that the cause holds a chunk header before reading its type. A
short cause no longer disables ASCONF.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Andrew Stellman <astellman@stellman-greene.com>
---
Tested only on net-next 19c484e12ed2 in arm64 QEMU with KASAN, with a
debug print added and an injected ERROR chunk: asconf_capable changed
from 1 to 0 without the fix and stayed 1 with it.
Found with Quality Playbook
(https://github.com/andrewstellman/quality-playbook) running Claude Opus
5; the fix was drafted with OpenAI GPT-6 (Codex).
A reproducer is available on request.
net/sctp/sm_sideeffect.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c
index 35f540fb15fc..e9c77577dc0c 100644
--- a/net/sctp/sm_sideeffect.c
+++ b/net/sctp/sm_sideeffect.c
@@ -997,6 +997,10 @@ static void sctp_cmd_process_operr(struct sctp_cmd_seq *cmds,
{
struct sctp_chunkhdr *unk_chunk_hdr;
+ if (ntohs(err_hdr->length) <
+ sizeof(*err_hdr) + sizeof(*unk_chunk_hdr))
+ break;
+
unk_chunk_hdr = (struct sctp_chunkhdr *)(err_hdr + 1);
switch (unk_chunk_hdr->type) {
/* ADDIP 4.1 A9) If the peer responds to an ASCONF with
--
2.53.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-12-02 16:50 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-02 16:50 [PATCH net] sctp: validate the Unrecognized Chunk cause length Andrew Stellman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox