Netdev List
 help / color / mirror / Atom feed
From: Andrew Stellman <bugs@stellman-greene.com>
To: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>,
	Xin Long <lucien.xin@gmail.com>
Cc: "David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Willem de Bruijn <willemb@google.com>,
	Simon Horman <horms@kernel.org>,
	linux-sctp@vger.kernel.org, netdev@vger.kernel.org
Subject: [PATCH net] sctp: validate the Unrecognized Chunk cause length
Date: Wed,  2 Dec 2026 11:50:10 -0500	[thread overview]
Message-ID: <20261202165010.50048-1-bugs@stellman-greene.com> (raw)

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


                 reply	other threads:[~2026-12-02 16:50 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=20261202165010.50048-1-bugs@stellman-greene.com \
    --to=bugs@stellman-greene.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=marcelo.leitner@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.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