sctp: validate chunk length in the inqueue parser
Subsystems (3)
PATCH v2 1/1 sctp: validate chunk length in the inqueue parser
SCTP chunks always include a four-byte generic header, but sctp_inq_pop() currently accepts shorter declared lengths. A zero-length chunk leaves chunk_end at the current header.
When ASCONF is covered by the association's SCTP-AUTH policy, sctp_assoc_bh_rcv() can continue before the state machine performs its normal chunk-length check. sctp_inq_pop() then returns the same malformed chunk repeatedly and the receive softirq can lock up.
A remote SCTP peer can trigger this after establishing an association on a kernel built with CONFIG_IP_SCTP and configured with net.sctp.addip_enable=1 and net.sctp.auth_enable=1. The reproducer did not require application credentials, a shared SCTP AUTH key, or net.sctp.addip_noauth_enable=1.
On commit f967455fb2a5 ("seg6: reset IP6CB after IPv6 decapsulation"), one zero-length ASCONF caused repeated
watchdog soft-lockup reports in a two-vCPU KVM guest. All 3 pre-trigger health probes succeeded, while 36 of 37 post-trigger probes failed. With this change, all 37 post-trigger probes succeeded and no equivalent soft-lockup signature appeared.
Reject chunks shorter than the generic SCTP header at the shared inqueue parser boundary. Mark the packet for discard before either caller can continue processing it, while preserving the four-byte generic minimum. Declared-length 1 through 4 controls and kernel-generated ASCONF traffic remained healthy. The patched sctp_hello selftest passed for IPv4 and IPv6.
The complete private reproducer and validation evidence are available directly to maintainers on request.
---
Changes in v2:
- Fold the minimum-header check into the existing chunk classifier.
- Keep pr_debug() on the malformed path and leave chunk_end unchanged.
- Retest lengths 0--4, legitimate ASCONF, and IPv4/IPv6 SCTP traffic.
- Link to v1: https://patch.msgid.link/[email protected]
To: Marcelo Ricardo Leitner <[email protected]>
To: Xin Long <[email protected]>
To: "David S. Miller" <[email protected]>
To: Eric Dumazet <[email protected]>
To: Jakub Kicinski <[email protected]>
To: Paolo Abeni <[email protected]>
To: Simon Horman <[email protected]>
To: Vlad Yasevich <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
--- net/sctp/inqueue.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
net/sctp/inqueue.c +4 -2
@@ -212,8 +212,10 @@ struct sctp_chunk *sctp_inq_pop(struct sctp_inq *queue) chunk->chunk_end = ((__u8 *)ch) +SCTP_PAD4 (ntohs (ch->length));skb_pull (chunk->skb,sizeof (*ch)); chunk->subh.v =NULL ;/* Subheader is no longer valid. */ - -if (chunk->chunk_end +sizeof (*ch) <=skb_tail_pointer (chunk->skb)) { +if (unlikely (ntohs (ch->length) <sizeof (*ch))) { + chunk->pdiscard =1 ; + }else if (chunk->chunk_end +sizeof (*ch) <= +skb_tail_pointer (chunk->skb)) {/* This is not a singleton */ chunk->singleton =0 ; }else if (chunk->chunk_end >skb_tail_pointer (chunk->skb)) {
---
base-commit: f967455fb2a5a2079b9eb5823e9ccf359174bf9f
change-id: 20260826-sctp-zero-chunk-inqueue-b478dca552c6
Best regards,
Signature · 1 line
Charles Vosburgh <[email protected]>
Quoted 85 lines · On Thu, Aug 27, 2026 at 5:33 PM Charles Vosburgh via B4 Relay…
From: Charles Vosburgh <[email protected]>
SCTP chunks always include a four-byte generic header, but
sctp_inq_pop()currently accepts shorter declared lengths. A zero-length chunk leaveschunk_endat the current header.When ASCONF is covered by the association's SCTP-AUTH policy,
sctp_assoc_bh_rcv()can continue before the state machine performs its normal chunk-length check.sctp_inq_pop()then returns the same malformed chunk repeatedly and the receive softirq can lock up.A remote SCTP peer can trigger this after establishing an association on a kernel built with
CONFIG_IP_SCTPand configured with net.sctp.addip_enable=1 and net.sctp.auth_enable=1. The reproducer did not require application credentials, a shared SCTP AUTH key, or net.sctp.addip_noauth_enable=1.On commit
f967455fb2a5("seg6: reset IP6CB after IPv6 decapsulation"), one zero-length ASCONF caused repeated
watchdog soft-lockup reports in a two-vCPU KVM guest. All 3 pre-trigger health probes succeeded, while 36 of 37 post-trigger probes failed. With this change, all 37 post-trigger probes succeeded and no equivalent soft-lockup signature appeared.Reject chunks shorter than the generic SCTP header at the shared inqueue parser boundary. Mark the packet for discard before either caller can continue processing it, while preserving the four-byte generic minimum. Declared-length 1 through 4 controls and kernel-generated ASCONF traffic remained healthy. The patched
sctp_helloselftest passed for IPv4 and IPv6.The complete private reproducer and validation evidence are available directly to maintainers on request.
Fixes bbd0d59809f9 ("[SCTP]: Implement the receive and verification of AUTH chunk")Assisted-by ChatGPT:GPT-5.6-SolAssisted-by Vantix:claude-opus-5Assisted-by Codex:GPT-5Signed-off-by Charles Vosburgh <[email protected]>---
Changes in v2:
- Fold the minimum-header check into the existing chunk classifier.
- Keeppr_debug()on the malformed path and leavechunk_endunchanged.
- Retest lengths 0--4, legitimate ASCONF, and IPv4/IPv6 SCTP traffic.
- Link to v1: https://patch.msgid.link/[email protected]To: Marcelo Ricardo Leitner <[email protected]>
To: Xin Long <[email protected]>
To: "David S. Miller" <[email protected]>
To: Eric Dumazet <[email protected]>
To: Jakub Kicinski <[email protected]>
To: Paolo Abeni <[email protected]>
To: Simon Horman <[email protected]>
To: Vlad Yasevich <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]--- net/sctp/inqueue.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)net/sctp/inqueue.c +4
-3@@ -212,8 +212,10 @@ struct sctp_chunk *sctp_inq_pop(struct sctp_inq *queue) chunk->chunk_end = ((__u8 *)ch) +SCTP_PAD4 (ntohs (ch->length));skb_pull (chunk->skb,sizeof (*ch)); chunk->subh.v =NULL ;/* Subheader is no longer valid. */ - -if (chunk->chunk_end +sizeof (*ch) <=skb_tail_pointer (chunk->skb)) { +if (unlikely (ntohs (ch->length) <sizeof (*ch))) { + chunk->pdiscard =1 ; + }else if (chunk->chunk_end +sizeof (*ch) <= +skb_tail_pointer (chunk->skb)) {/* This is not a singleton */ chunk->singleton =0 ; }else if (chunk->chunk_end >skb_tail_pointer (chunk->skb)) { ---base-commit:
f967455fb2a5a2079b9eb5823e9ccf359174bf9f
change-id: 20260826-sctp-zero-chunk-inqueue-b478dca552c6
Quoted 5 lines
Best regards,
--
Charles Vosburgh <[email protected]>
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 6 lines · On Thu, 27 Aug 2026 17:32:53 -0400 you wrote:
From: Charles Vosburgh <[email protected]>
SCTP chunks always include a four-byte generic header, but
sctp_inq_pop()currently accepts shorter declared lengths. A zero-length chunk leaveschunk_endat the current header.
Quoted 6 lines
When ASCONF is covered by the association's SCTP-AUTH policy,
sctp_assoc_bh_rcv()can continue before the state machine performs its normal chunk-length check.sctp_inq_pop()then returns the same malformed chunk repeatedly and the receive softirq can lock up.[...]
Here is the summary with links:
- [net,v2] sctp: validate chunk length in the inqueue parser
https://git.kernel.org/netdev/net/c/6cfc1b90cb86
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html