All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net v2 1/1] sctp: stream: fully roll back denied add-stream state
@ 2026-06-05  5:53 Ren Wei
  2026-06-07  0:29 ` Xin Long
  2026-06-10  0:40 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Ren Wei @ 2026-06-05  5:53 UTC (permalink / raw)
  To: linux-sctp, netdev
  Cc: marcelo.leitner, lucien.xin, davem, yuantan098, yifanwucs,
	tomapufckgml, zcliangcn, bird, bronzed_45_vested, n05ec

From: Wyatt Feng <bronzed_45_vested@icloud.com>

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")
Cc: stable@kernel.org
Reported-by: Yuan Tan <yuantan098@gmail.com>
Reported-by: Yifan Wu <yifanwucs@gmail.com>
Reported-by: Juefei Pu <tomapufckgml@gmail.com>
Reported-by: Zhengchuan Liang <zcliangcn@gmail.com>
Reported-by: Xin Liu <bird@lzu.edu.cn>
Assisted-by: Codex:GPT-5.4
Signed-off-by: Wyatt Feng <bronzed_45_vested@icloud.com>
Signed-off-by: Ren Wei <n05ec@lzu.edu.cn>
---
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(-)

diff --git a/net/sctp/stream.c b/net/sctp/stream.c
index c2247793c88b..5c2fdedea088 100644
--- a/net/sctp/stream.c
+++ b/net/sctp/stream.c
@@ -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;
 		}
 
-- 
2.43.7


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net v2 1/1] sctp: stream: fully roll back denied add-stream state
  2026-06-05  5:53 [PATCH net v2 1/1] sctp: stream: fully roll back denied add-stream state Ren Wei
@ 2026-06-07  0:29 ` Xin Long
  2026-06-10  0:40 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Xin Long @ 2026-06-07  0:29 UTC (permalink / raw)
  To: Ren Wei
  Cc: linux-sctp, netdev, marcelo.leitner, davem, yuantan098, yifanwucs,
	tomapufckgml, zcliangcn, bird, bronzed_45_vested

On Fri, Jun 5, 2026 at 1:54 AM Ren Wei <n05ec@lzu.edu.cn> wrote:
>
> From: Wyatt Feng <bronzed_45_vested@icloud.com>
>
> 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")
> Cc: stable@kernel.org
> Reported-by: Yuan Tan <yuantan098@gmail.com>
> Reported-by: Yifan Wu <yifanwucs@gmail.com>
> Reported-by: Juefei Pu <tomapufckgml@gmail.com>
> Reported-by: Zhengchuan Liang <zcliangcn@gmail.com>
> Reported-by: Xin Liu <bird@lzu.edu.cn>
> Assisted-by: Codex:GPT-5.4
> Signed-off-by: Wyatt Feng <bronzed_45_vested@icloud.com>
> Signed-off-by: Ren Wei <n05ec@lzu.edu.cn>
> ---
> 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(-)
>
> diff --git a/net/sctp/stream.c b/net/sctp/stream.c
> index c2247793c88b..5c2fdedea088 100644
> --- a/net/sctp/stream.c
> +++ b/net/sctp/stream.c
> @@ -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;
>                 }
>
> --
> 2.43.7
>
Acked-by: Xin Long <lucien.xin@gmail.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net v2 1/1] sctp: stream: fully roll back denied add-stream state
  2026-06-05  5:53 [PATCH net v2 1/1] sctp: stream: fully roll back denied add-stream state Ren Wei
  2026-06-07  0:29 ` Xin Long
@ 2026-06-10  0:40 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-06-10  0:40 UTC (permalink / raw)
  To: Ren Wei
  Cc: linux-sctp, netdev, marcelo.leitner, lucien.xin, davem,
	yuantan098, yifanwucs, tomapufckgml, zcliangcn, bird,
	bronzed_45_vested

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Fri,  5 Jun 2026 13:53:42 +0800 you wrote:
> From: Wyatt Feng <bronzed_45_vested@icloud.com>
> 
> 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!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-06-10  0:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-05  5:53 [PATCH net v2 1/1] sctp: stream: fully roll back denied add-stream state Ren Wei
2026-06-07  0:29 ` Xin Long
2026-06-10  0:40 ` patchwork-bot+netdevbpf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.