From: Kyuwon Cho <kyuwoncho18@gmail.com>
To: Xin Long <lucien.xin@gmail.com>
Cc: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>,
Willem de Bruijn <willemb@google.com>,
Jun Yang <junvyyang@tencent.com>,
linux-sctp@vger.kernel.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH net v4 1/1] sctp: fail the association when the INIT-ACK cannot be processed
Date: Wed, 25 Nov 2026 11:36:50 +0900 [thread overview]
Message-ID: <5d2a09ae8d660d10091942d426c0c8f1f82c1705.1795572890.git.kyuwoncho18@gmail.com> (raw)
In-Reply-To: <cover.1795572890.git.kyuwoncho18@gmail.com>
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
prev parent reply other threads:[~2026-11-25 2:36 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 2:36 [PATCH net v4 0/1] " Kyuwon Cho
2026-11-25 2:36 ` Kyuwon Cho [this message]
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=5d2a09ae8d660d10091942d426c0c8f1f82c1705.1795572890.git.kyuwoncho18@gmail.com \
--to=kyuwoncho18@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=junvyyang@tencent.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.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
all inboxes | Powered by JetHome®