From: Xin Long <lucien.xin@gmail.com>
To: Kyuwon Cho <kyuwoncho18@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>,
Jun Yang <junvyyang@tencent.com>,
linux-sctp@vger.kernel.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [BUG] sctp: auth: NULL asoc->shkey after a failed SCTP_CMD_ASSOC_SHKEY makes close() oops
Date: Thu, 19 Nov 2026 15:01:57 -0500 [thread overview]
Message-ID: <CADvbK_citvtZ4eumLcx_szUvth7sQMP1oKu0mLbo0a3bD-eSxQ@mail.gmail.com> (raw)
In-Reply-To: <179505710266.3511678.14017674052424733262@gmail.com>
On Wed, Nov 18, 2026 at 10:04 PM Kyuwon Cho <kyuwoncho18@gmail.com> wrote:
>
> Hi Marcelo, Xin,
>
> While testing v7.4-rc3 with an LLM-guided test generator that we are
> developing as a research prototype, we found that an SCTP association
> whose shared key could not be set up still builds authenticated chunks,
> with a NULL key. Closing such a socket with SO_LINGER {1, 0} then
> oopses in sctp_auth_shkey_hold(); here as an unprivileged user:
>
> BUG: KASAN: null-ptr-deref in sctp_auth_shkey_hold (include/linux/refcount.h:366 net/sctp/auth.c:113)
> Write of size 4 at addr 0000000000000018 by task test/115
> CPU: 1 UID: 65534 PID: 115 Comm: test Not tainted 7.4.0-rc3 #1 PREEMPT(lazy)
> Call Trace:
> <TASK>
> sctp_auth_shkey_hold (include/linux/refcount.h:366 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:1492 net/sctp/sm_make_chunk.c:953 net/sctp/sm_make_chunk.c:1016)
> sctp_close (net/sctp/socket.c:1564)
> inet_release (net/ipv4/af_inet.c:443)
> __sock_release (net/socket.c:735)
> sock_close (net/socket.c:1529)
> __fput (fs/file_table.c:512)
> fput_close_sync (fs/file_table.c:618)
> __x64_sys_close (fs/open.c:1574 fs/open.c:1597 fs/open.c:1584)
> do_syscall_64 (arch/x86/entry/syscall_64.c:61 arch/x86/entry/syscall_64.c:89)
> entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:121)
> </TASK>
>
> When the INIT-ACK arrives, sctp_sf_do_5_1C_ack() queues
> SCTP_CMD_PEER_INIT, which records that the peer supports AUTH and which
> chunks it wants authenticated, and then SCTP_CMD_ASSOC_SHKEY:
>
> case SCTP_CMD_ASSOC_SHKEY:
> error = sctp_auth_asoc_init_active_key(asoc,
> GFP_ATOMIC);
> break;
>
> sctp_auth_asoc_init_active_key() returns -ENOMEM before it sets
> asoc->shkey when the secret cannot be allocated:
>
> secret = sctp_auth_asoc_create_secret(asoc, ep_key, gfp);
> if (!secret)
> return -ENOMEM;
> ...
> asoc->shkey = ep_key;
>
> sctp_cmd_interpreter() then drops the remaining commands, but the
> association stays, with peer.auth_capable set and asoc->shkey NULL. If
The association should NOT stay with a broken state, but be deleted in such
cases. But it seems we can't do it in the loop of sctp_cmd_interpreter().
Can you please try fixing it by directly calling sctp_process_init() and
sctp_auth_asoc_init_active_key() in sctp_sf_do_5_1C_ack()? like:
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_U16(SCTP_ERROR_NO_RESOURCE));
return SCTP_DISPOSITION_CONSUME;
}
/* SCTP-AUTH: generate the association shared keys so that
* we can potentially sign the COOKIE-ECHO.
*/
if (sctp_auth_asoc_init_active_key((struct sctp_association *)asoc,
GFP_ATOMIC)) {
sctp_add_cmd_sf(commands, SCTP_CMD_INIT_FAILED,
SCTP_U16(SCTP_ERROR_NO_RESOURCE));
return SCTP_DISPOSITION_CONSUME;
}
instead of using SCTP_CMD_PEER_INIT and SCTP_CMD_ASSOC_SHKEY.
Then you can delete SCTP_CMD_PEER_INIT and SCTP_CMD_ASSOC_SHKEY commands
from sctp code, as they're no longer used.
Also, please use git-send-email to send your patch, not send it as an
attachment.
Thanks.
prev parent reply other threads:[~2026-11-19 20:02 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-19 3:04 Kyuwon Cho
2026-11-19 20:01 ` Xin Long [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=CADvbK_citvtZ4eumLcx_szUvth7sQMP1oKu0mLbo0a3bD-eSxQ@mail.gmail.com \
--to=lucien.xin@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=junvyyang@tencent.com \
--cc=kuba@kernel.org \
--cc=kyuwoncho18@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sctp@vger.kernel.org \
--cc=marcelo.leitner@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.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®