Skip to contentSkip to conversation

sctp: stream: fully roll back denied add-stream state

PATCH Applied Ren Wei 3 participants 3 messages Jun 5 – Jun 10

Subsystems (3)
lore
Share & tools
lore

Ren Wei

author
#0 lore raw

PATCH v2 1/1 sctp: stream: fully roll back denied add-stream state

From: Wyatt Feng <[email protected]>

When ADD_OUT_STREAMS is denied, SCTP only shrinks the queued chunks and then lowers outcnt. That leaves removed stream metadata behind, so a later re-add can reuse a stale ext and hit a null-pointer dereference in the scheduler get path.

Fix the rollback by tearing down the removed stream state the same way other stream resizes do. Unschedule the current scheduler state, drop the removed stream ext state with sctp_stream_outq_migrate(), and then reschedule the remaining streams.

This keeps scheduler-private RR/FC/PRIO lists consistent while fully rolling back denied outgoing stream additions.

Fixes 637784ade221 ("sctp: introduce priority based stream scheduler")
Assisted-by Codex:GPT-5.4

---
Changes in v2:
- Moved the sched declaration below addstrm and dropped the
out_curr handling. The rollback fix now only unschedules the
current scheduler state, migrates/drops the removed stream ext
state, and reschedules the remaining streams.
- v1 Link: https://lore.kernel.org/all/345886be48a66f70bad26ddcea6defb38d1d0f72.1780439824.git.bronzed_45_vested@icloud.com/

 net/sctp/stream.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
net/sctp/stream.c +5 -1
index c2247793c88b..5c2fdedea088 100644
@@ -1038,6 +1038,7 @@ struct sctp_chunk *sctp_process_strreset_resp(
 			stsn, rtsn, GFP_ATOMIC);
 	} else if (req->type == SCTP_PARAM_RESET_ADD_OUT_STREAMS) {
 		struct sctp_strreset_addstrm *addstrm;
+		const struct sctp_sched_ops *sched;
 		__u16 number;
 
 		addstrm = (struct sctp_strreset_addstrm *)req;
@@ -1048,7 +1049,10 @@ struct sctp_chunk *sctp_process_strreset_resp(
 			for (i = number; i < stream->outcnt; i++)
 				SCTP_SO(stream, i)->state = SCTP_STREAM_OPEN;
 		} else {
-			sctp_stream_shrink_out(stream, number);
+			sched = sctp_sched_ops_from_stream(stream);
+			sched->unsched_all(stream);
+			sctp_stream_outq_migrate(stream, NULL, number);
+			sched->sched_all(stream);
 			stream->outcnt = number;
 		}
 
Signature · 1 line
2.43.7
maintainer Acked-by on v2 1/1
#1 lore raw
Quoted 63 lines · Ren Wei

From: Wyatt Feng <[email protected]>

When ADD_OUT_STREAMS is denied, SCTP only shrinks the queued chunks and then lowers outcnt. That leaves removed stream metadata behind, so a later re-add can reuse a stale ext and hit a null-pointer dereference in the scheduler get path.

Fix the rollback by tearing down the removed stream state the same way other stream resizes do. Unschedule the current scheduler state, drop the removed stream ext state with sctp_stream_outq_migrate(), and then reschedule the remaining streams.

This keeps scheduler-private RR/FC/PRIO lists consistent while fully rolling back denied outgoing stream additions.

Fixes 637784ade221 ("sctp: introduce priority based stream scheduler")
Assisted-by Codex:GPT-5.4

---
Changes in v2:
- Moved the sched declaration below addstrm and dropped the
out_curr handling. The rollback fix now only unschedules the
current scheduler state, migrates/drops the removed stream ext
state, and reschedules the remaining streams.
- v1 Link: https://lore.kernel.org/all/345886be48a66f70bad26ddcea6defb38d1d0f72.1780439824.git.bronzed_45_vested@icloud.com/

 net/sctp/stream.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
net/sctp/stream.c +5 -2
index c2247793c88b..5c2fdedea088 100644
@@ -1038,6 +1038,7 @@ struct sctp_chunk *sctp_process_strreset_resp(
                        stsn, rtsn, GFP_ATOMIC);
        } else if (req->type == SCTP_PARAM_RESET_ADD_OUT_STREAMS) {
                struct sctp_strreset_addstrm *addstrm;
+               const struct sctp_sched_ops *sched;
                __u16 number;
 
                addstrm = (struct sctp_strreset_addstrm *)req;
@@ -1048,7 +1049,10 @@ struct sctp_chunk *sctp_process_strreset_resp(
                        for (i = number; i < stream->outcnt; i++)
                                SCTP_SO(stream, i)->state = SCTP_STREAM_OPEN;
                } else {
-                       sctp_stream_shrink_out(stream, number);
+                       sched = sctp_sched_ops_from_stream(stream);
+                       sched->unsched_all(stream);
+                       sctp_stream_outq_migrate(stream, NULL, number);
+                       sched->sched_all(stream);
                        stream->outcnt = number;
                }
 
--
Quoted 2 lines

2.43.7

#2 lore raw
In reply to Ren Wei
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 8 lines · On Fri, 5 Jun 2026 13:53:42 +0800 you wrote:

From: Wyatt Feng <[email protected]>

When ADD_OUT_STREAMS is denied, SCTP only shrinks the queued chunks and then lowers outcnt. That leaves removed stream metadata behind, so a later re-add can reuse a stale ext and hit a null-pointer dereference in the scheduler get path.

[...]

Here is the summary with links:
- [net,v2,1/1] sctp: stream: fully roll back denied add-stream state

    https://git.kernel.org/netdev/net/c/a5f8a90ac9f7

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html