🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.netdev
4 messages
4 total messages Started by Kyuwon Cho Wed, 25 Nov 2026 02:36
[PATCH net v4 0/1] sctp: fail the association when the INIT-ACK cannot be processed
#22261
Author: Kyuwon Cho
Date: Wed, 25 Nov 2026 02:36
39 lines
12503 bytes
From: ChoKyuWon <kyuwoncho18@gmail.com>

When processing an INIT-ACK fails, the association stays AUTH capable
with a NULL association key, and close() with SO_LINGER {1, 0} then
takes a reference on that NULL key. As Xin suggested, the patch
processes the INIT-ACK and sets up the key directly in
sctp_sf_do_5_1C_ack() and aborts the association if either step fails.

The issue was found by an LLM-guided test generator that we are
developing as a research prototype.

v4:
- Free err_chunk and abort with sctp_stop_t1_and_abort() on both
  failure paths, which also sets sk_err and counts the abort (Xin, and
  the Sashiko review).
- Say in the commit message that an INIT-ACK from a peer that is ASCONF
  capable but not AUTH capable now aborts the association at once too.
v3: https://lore.kernel.org/netdev/179539544818.3016044.13738712075053349592@gmail.com/
- Pass the error to SCTP_CMD_INIT_FAILED with SCTP_PERR(), like the
  other callers; SCTP_U16() made sparse warn about the __be16 value
  (netdev CI).
v2: https://lore.kernel.org/netdev/179514851805.604157.8527055700821138420@gmail.com/
- Process the INIT-ACK in sctp_sf_do_5_1C_ack() as Xin suggested,
  instead of skipping AUTH in sctp_auth_send_cid(), and remove
  SCTP_CMD_PEER_INIT and SCTP_CMD_ASSOC_SHKEY.
v1: https://lore.kernel.org/netdev/179505710266.3511678.14017674052424733262@gmail.com/

The patch was written with LLM assistance; we reviewed and tested it.
With it, the reproducer from v1 no longer triggers the report.

Kyuwon Cho (1):
  sctp: fail the association when the INIT-ACK cannot be processed

 net/sctp/sm_statefuns.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

-- 
2.43.0
[PATCH net v4 1/1] sctp: fail the association when the INIT-ACK cannot be processed
#22260
Author: Kyuwon Cho
Date: Wed, 25 Nov 2026 02:36
66 lines
13798 bytes
sctp_sf_do_5_1C_ack() queues SCTP_CMD_PEER_INIT and SCTP_CMD_ASSOC_SHKEY.
If either fails, sctp_cmd_interpreter() stops there, but the association
stays: with the peer marked AUTH capable and asoc->shkey still NULL, a
chunk that the peer wants authenticated, such as the ABORT built by
close() with SO_LINGER {1, 0}, takes a reference on the NULL key:

  BUG: KASAN: null-ptr-deref in sctp_auth_shkey_hold (net/sctp/auth.c:113)
  Write of size 4 at addr 0000000000000018
  Call Trace:
   sctp_auth_shkey_hold (net/sctp/auth.c:113)
   sctp_control_set_owner_w (net/sctp/sm_make_chunk.c:112)
   sctp_make_abort_user (net/sctp/sm_make_chunk.c:1016)
   sctp_close (net/sctp/socket.c:1564)

Process the INIT-ACK and set up the association key directly in
sctp_sf_do_5_1C_ack(), and abort the association with
sctp_stop_t1_and_abort() if either step fails, as is done when the
INIT-ACK fails verification. This also aborts when sctp_process_init()
rejects a peer that is ASCONF capable but not AUTH capable, which used
to drop the INIT-ACK and leave T1-init to expire. SCTP_CMD_PEER_INIT
and SCTP_CMD_ASSOC_SHKEY have no other users, so remove them.

Fixes: 1b1e0bc99474 ("sctp: add refcnt support for sh_key")
Suggested-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: Kyuwon Cho <kyuwoncho18@gmail.com>
---
 net/sctp/sm_statefuns.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c
index fd9f94c12d42..206fa0b6cd4b 100644
--- a/net/sctp/sm_statefuns.c
+++ b/net/sctp/sm_statefuns.c
@@ -605,9 +605,11 @@ enum sctp_disposition sctp_sf_do_5_1C_ack(struct net *net,
 
 	if (!sctp_process_init((struct sctp_association *)asoc, chunk,
 			       sctp_source(chunk), initchunk, GFP_ATOMIC)) {
-		sctp_add_cmd_sf(commands, SCTP_CMD_INIT_FAILED,
-				SCTP_PERR(SCTP_ERROR_NO_RESOURCE));
-		return SCTP_DISPOSITION_CONSUME;
+		if (err_chunk)
+			sctp_chunk_free(err_chunk);
+		return sctp_stop_t1_and_abort(net, commands,
+					      SCTP_ERROR_NO_RESOURCE, ENOMEM,
+					      asoc, chunk->transport);
 	}
 
 	/* SCTP-AUTH: generate the association shared keys so that
@@ -615,9 +617,11 @@ enum sctp_disposition sctp_sf_do_5_1C_ack(struct net *net,
 	 */
 	if (sctp_auth_asoc_init_active_key((struct sctp_association *)asoc,
 					   GFP_ATOMIC)) {
-		sctp_add_cmd_sf(commands, SCTP_CMD_INIT_FAILED,
-				SCTP_PERR(SCTP_ERROR_NO_RESOURCE));
-		return SCTP_DISPOSITION_CONSUME;
+		if (err_chunk)
+			sctp_chunk_free(err_chunk);
+		return sctp_stop_t1_and_abort(net, commands,
+					      SCTP_ERROR_NO_RESOURCE, ENOMEM,
+					      asoc, chunk->transport);
 	}
 
 	/* Reset init error count upon receipt of INIT-ACK.  */
-- 
2.43.0
Re: [PATCH net v4 1/1] sctp: fail the association when the INIT-ACK cannot be processed
#24760
Author: Xin Long
Date: Mon, 30 Nov 2026 19:19
85 lines
15521 bytes
On Tue, Nov 24, 2026 at 9:36 PM Kyuwon Cho <kyuwoncho18@gmail.com> wrote:
>
> sctp_sf_do_5_1C_ack() queues SCTP_CMD_PEER_INIT and SCTP_CMD_ASSOC_SHKEY.
> If either fails, sctp_cmd_interpreter() stops there, but the association
> stays: with the peer marked AUTH capable and asoc->shkey still NULL, a
> chunk that the peer wants authenticated, such as the ABORT built by
> close() with SO_LINGER {1, 0}, takes a reference on the NULL key:
>
>   BUG: KASAN: null-ptr-deref in sctp_auth_shkey_hold (net/sctp/auth.c:113)
>   Write of size 4 at addr 0000000000000018
>   Call Trace:
>    sctp_auth_shkey_hold (net/sctp/auth.c:113)
>    sctp_control_set_owner_w (net/sctp/sm_make_chunk.c:112)
>    sctp_make_abort_user (net/sctp/sm_make_chunk.c:1016)
>    sctp_close (net/sctp/socket.c:1564)
>
> Process the INIT-ACK and set up the association key directly in
> sctp_sf_do_5_1C_ack(), and abort the association with
> sctp_stop_t1_and_abort() if either step fails, as is done when the
> INIT-ACK fails verification. This also aborts when sctp_process_init()
> rejects a peer that is ASCONF capable but not AUTH capable, which used
> to drop the INIT-ACK and leave T1-init to expire. SCTP_CMD_PEER_INIT
> and SCTP_CMD_ASSOC_SHKEY have no other users, so remove them.
>
> Fixes: 1b1e0bc99474 ("sctp: add refcnt support for sh_key")
> Suggested-by: Xin Long <lucien.xin@gmail.com>
> Signed-off-by: Kyuwon Cho <kyuwoncho18@gmail.com>
> ---
>  net/sctp/sm_statefuns.c | 16 ++++++++++------
>  1 file changed, 10 insertions(+), 6 deletions(-)
>
> diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c
> index fd9f94c12d42..206fa0b6cd4b 100644
> --- a/net/sctp/sm_statefuns.c
> +++ b/net/sctp/sm_statefuns.c
> @@ -605,9 +605,11 @@ enum sctp_disposition sctp_sf_do_5_1C_ack(struct net *net,
>
>         if (!sctp_process_init((struct sctp_association *)asoc, chunk,
>                                sctp_source(chunk), initchunk, GFP_ATOMIC)) {
> -               sctp_add_cmd_sf(commands, SCTP_CMD_INIT_FAILED,
> -                               SCTP_PERR(SCTP_ERROR_NO_RESOURCE));
> -               return SCTP_DISPOSITION_CONSUME;
> +               if (err_chunk)
> +                       sctp_chunk_free(err_chunk);
> +               return sctp_stop_t1_and_abort(net, commands,
> +                                             SCTP_ERROR_NO_RESOURCE, ENOMEM,
> +                                             asoc, chunk->transport);
>         }
>
>         /* SCTP-AUTH: generate the association shared keys so that
> @@ -615,9 +617,11 @@ enum sctp_disposition sctp_sf_do_5_1C_ack(struct net *net,
>          */
>         if (sctp_auth_asoc_init_active_key((struct sctp_association *)asoc,
>                                            GFP_ATOMIC)) {
> -               sctp_add_cmd_sf(commands, SCTP_CMD_INIT_FAILED,
> -                               SCTP_PERR(SCTP_ERROR_NO_RESOURCE));
> -               return SCTP_DISPOSITION_CONSUME;
> +               if (err_chunk)
> +                       sctp_chunk_free(err_chunk);
> +               return sctp_stop_t1_and_abort(net, commands,
> +                                             SCTP_ERROR_NO_RESOURCE, ENOMEM,
> +                                             asoc, chunk->transport);
>         }
>
>         /* Reset init error count upon receipt of INIT-ACK.  */
> --
> 2.43.0
>

Interesting, I don't see this patch show up in the Clashiko review:

https://netdev-ai.bots.linux.dev/sashiko/

Maybe you should review the 0/1 cover and repost?

Thanks.
Re: [PATCH net v4 1/1] sctp: fail the association when the INIT-ACK cannot be processed
#24762
Author: Xin Long
Date: Mon, 30 Nov 2026 19:20
90 lines
16233 bytes
On Mon, Nov 30, 2026 at 2:19 PM Xin Long <lucien.xin@gmail.com> wrote:
>
> On Tue, Nov 24, 2026 at 9:36 PM Kyuwon Cho <kyuwoncho18@gmail.com> wrote:
> >
> > sctp_sf_do_5_1C_ack() queues SCTP_CMD_PEER_INIT and SCTP_CMD_ASSOC_SHKEY.
> > If either fails, sctp_cmd_interpreter() stops there, but the association
> > stays: with the peer marked AUTH capable and asoc->shkey still NULL, a
> > chunk that the peer wants authenticated, such as the ABORT built by
> > close() with SO_LINGER {1, 0}, takes a reference on the NULL key:
> >
> >   BUG: KASAN: null-ptr-deref in sctp_auth_shkey_hold (net/sctp/auth.c:113)
> >   Write of size 4 at addr 0000000000000018
> >   Call Trace:
> >    sctp_auth_shkey_hold (net/sctp/auth.c:113)
> >    sctp_control_set_owner_w (net/sctp/sm_make_chunk.c:112)
> >    sctp_make_abort_user (net/sctp/sm_make_chunk.c:1016)
> >    sctp_close (net/sctp/socket.c:1564)
> >
> > Process the INIT-ACK and set up the association key directly in
> > sctp_sf_do_5_1C_ack(), and abort the association with
> > sctp_stop_t1_and_abort() if either step fails, as is done when the
> > INIT-ACK fails verification. This also aborts when sctp_process_init()
> > rejects a peer that is ASCONF capable but not AUTH capable, which used
> > to drop the INIT-ACK and leave T1-init to expire. SCTP_CMD_PEER_INIT
> > and SCTP_CMD_ASSOC_SHKEY have no other users, so remove them.
> >
> > Fixes: 1b1e0bc99474 ("sctp: add refcnt support for sh_key")
> > Suggested-by: Xin Long <lucien.xin@gmail.com>
> > Signed-off-by: Kyuwon Cho <kyuwoncho18@gmail.com>
> > ---
> >  net/sctp/sm_statefuns.c | 16 ++++++++++------
> >  1 file changed, 10 insertions(+), 6 deletions(-)
> >
> > diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c
> > index fd9f94c12d42..206fa0b6cd4b 100644
> > --- a/net/sctp/sm_statefuns.c
> > +++ b/net/sctp/sm_statefuns.c
> > @@ -605,9 +605,11 @@ enum sctp_disposition sctp_sf_do_5_1C_ack(struct net *net,
> >
> >         if (!sctp_process_init((struct sctp_association *)asoc, chunk,
> >                                sctp_source(chunk), initchunk, GFP_ATOMIC)) {
> > -               sctp_add_cmd_sf(commands, SCTP_CMD_INIT_FAILED,
> > -                               SCTP_PERR(SCTP_ERROR_NO_RESOURCE));
> > -               return SCTP_DISPOSITION_CONSUME;
> > +               if (err_chunk)
> > +                       sctp_chunk_free(err_chunk);
> > +               return sctp_stop_t1_and_abort(net, commands,
> > +                                             SCTP_ERROR_NO_RESOURCE, ENOMEM,
> > +                                             asoc, chunk->transport);
> >         }
> >
> >         /* SCTP-AUTH: generate the association shared keys so that
> > @@ -615,9 +617,11 @@ enum sctp_disposition sctp_sf_do_5_1C_ack(struct net *net,
> >          */
> >         if (sctp_auth_asoc_init_active_key((struct sctp_association *)asoc,
> >                                            GFP_ATOMIC)) {
> > -               sctp_add_cmd_sf(commands, SCTP_CMD_INIT_FAILED,
> > -                               SCTP_PERR(SCTP_ERROR_NO_RESOURCE));
> > -               return SCTP_DISPOSITION_CONSUME;
> > +               if (err_chunk)
> > +                       sctp_chunk_free(err_chunk);
> > +               return sctp_stop_t1_and_abort(net, commands,
> > +                                             SCTP_ERROR_NO_RESOURCE, ENOMEM,
> > +                                             asoc, chunk->transport);
> >         }
> >
> >         /* Reset init error count upon receipt of INIT-ACK.  */
> > --
> > 2.43.0
> >
>
> Interesting, I don't see this patch show up in the Clashiko review:
>
> https://netdev-ai.bots.linux.dev/sashiko/
>
> Maybe you should review the 0/1 cover and repost?

Sorry, s/review/remove.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads