🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #20683

Re: [BUG] sctp: auth: NULL asoc->shkey after a failed SCTP_CMD_ASSOC_SHKEY makes close() oops

#20683
From: netdev-bot+sashiko
Date: Mon, 23 Nov 2026 03:26
215 lines
16713 bytes
Thank you for your contribution! Sashiko AI review found 4 potential
issue(s) to consider.

Critical: 0 · High: 1 (1) · Medium: 0 · Low: 3

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [High] The fix is incomplete.
- [Low] The changelog leaves out the directly related prior fix
  a80c9d945aef55 ("sctp: move SCTP_CMD_ASSOC_SHKEY right after…
- [Low] The recorded commit message is the raw bug-report email, not the
  patch changelog.
- [Low] The comment above sctp_auth_send_cid() in net/sctp/auth.c still
  says "Check if peer requested that this chunk is authenticated".

Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but the same
  'authenticated chunk with a NULL key' crash can be reached through a…

--

sctp: auth: NULL asoc->shkey after a failed SCTP_CMD_ASSOC_SHKEY makes close() oops

This patch makes sctp_auth_send_cid() return 0 when asoc->shkey is NULL.
Chunks are then not marked for authentication after
sctp_auth_asoc_init_active_key() fails while the INIT-ACK is processed.
The target is the NULL dereference in sctp_auth_shkey_hold() reached
from sctp_close()->sctp_make_abort_user() with SO_LINGER {1, 0}.

> sctp: auth: NULL asoc->shkey after a failed SCTP_CMD_ASSOC_SHKEY makes close() oops
>
> --===============7735770531491749088==
> Content-Type: text/plain; charset="us-ascii"
> Content-Transfer-Encoding: 7bit
>
> Hi Marcelo, Xin,

[Severity: Low]
This isn't a bug, but the recorded commit message looks like the raw
bug report email rather than the patch changelog. The subject describes
the symptom, not the change.

The body contains the salutation, MIME boundary lines, Content-Type
headers, the full repro.c and a base64-encoded config.gz attachment.

The real subject ("sctp: auth: don't authenticate chunks without an
association key"), the changelog, and the Fixes: and Signed-off-by:
trailers only appear inside the embedded format-patch attachment.

Could this be resent as a proper patch that uses the attached changelog
as the commit message?

[ ... ]

> The reference on the shared key comes from 1b1e0bc99474 ("sctp: add
> refcnt support for sh_key"). ad1320865b18 ("sctp: hold shkey across
> socket migration") and 52ffeaa358d1 ("sctp: re-point retained control
> chunks on association migration"), both in v7.4-rc3, handle the
> migration paths and not this one.

[Severity: Low]
Should this also mention a80c9d945aef55 ("sctp: move
SCTP_CMD_ASSOC_SHKEY right after SCTP_CMD_PEER_INIT")? That commit
handled the same failure: SHKEY fails, shkey stays NULL, auth_capable is
set, and a chunk is sent with auth=1.

That commit also reordered the commands in sctp_sf_do_5_1C_ack() so
that this one runs before TIMER_STOP/TIMER_START/NEW_STATE:

    sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_SHKEY, SCTP_NULL());

Because of that ordering, the failed association stays in COOKIE_WAIT.
There AUTH is discarded, and T1-init retransmits INIT, so key setup is
retried. This patch appears to depend on that behaviour.

Trees without a80c9d945aef55 leave the failed association in
COOKIE_ECHOED with T1-cookie running. Backporters who follow only
"Fixes: 1b1e0bc99474" get no warning about this. Would it be worth
stating the dependency here, instead of the two migration-path commits?

> diff --git a/net/sctp/auth.c b/net/sctp/auth.c
> index cbeb8a87a17a7..5f8e110929d46 100644
> --- a/net/sctp/auth.c
> +++ b/net/sctp/auth.c
> @@ -660,7 +660,7 @@ int sctp_auth_send_cid(enum sctp_cid chunk, const struct sctp_association *asoc)
>  	if (!asoc)
>  		return 0;
>  
> -	if (!asoc->peer.auth_capable)
> +	if (!asoc->peer.auth_capable || !asoc->shkey)
>  		return 0;

[Severity: High]
Is this check enough to cover the keyless state? After
SCTP_CMD_ASSOC_SHKEY fails in sctp_sf_do_5_1C_ack(), SCTP_CMD_PEER_INIT
has already set peer.auth_capable, peer_chunks, peer_hmacs and
c.peer_vtag. Both asoc->shkey and asoc->asoc_shared_key are still NULL.
This change only affects the transmit side.

During an INIT collision, the COOKIE_WAIT association can receive the
peer's COOKIE-ECHO. sctp_sf_do_5_2_4_dupcook() then gets action 'D' from
sctp_tietags_compare(), because PEER_INIT already set a non-zero
peer_vtag:

    if ((asoc->c.my_vtag == new_asoc->c.my_vtag) &&
        (asoc->c.peer_vtag == new_asoc->c.peer_vtag))
        return 'D';

If an AUTH chunk comes before the COOKIE-ECHO, sctp_sf_do_dupcook_d()
verifies it against the existing keyless association:

    if (!sctp_auth_chunk_verify(net, chunk, asoc))
        return SCTP_DISPOSITION_DISCARD;

The call chain
sctp_auth_chunk_verify()->sctp_sf_authenticate()->sctp_auth_calculate_hmac()
then uses the NULL key:

    if (key_id == asoc->active_key_id)
        asoc_key = asoc->asoc_shared_key;
    ...
        hmac_sha1_usingrawkey(asoc_key->data, asoc_key->len,

Without that AUTH chunk, dupcook_d moves the association to ESTABLISHED
and never calls sctp_auth_asoc_init_active_key(), unlike dupcook_a and
dupcook_b. sctp_sf_eat_auth() checks only peer.auth_capable before it
calls sctp_sf_authenticate(). Any later AUTH chunk from the remote peer
then hits the same NULL asoc_shared_key dereference in the receive path.

The patch also changes behaviour in a way the changelog doesn't mention.
sctp_auth_send_cid() now returns 0 in this state. So DATA, ABORT and any
other chunk the peer listed in its CHUNKS parameter are sent without
AUTH. The peer silently drops them in sctp_assoc_bh_rcv():

    if (sctp_auth_recv_cid(subtype.chunk, asoc) && !chunk->auth)
        continue;

The association then looks established but delivers nothing.

Would it be better to stop a keyless auth-capable association from
leaving COOKIE_WAIT or processing AUTH? For example, dupcook_d could
initialise the key or fail, or AUTH could be rejected while
asoc_shared_key is NULL. That would replace the approach in
sctp_auth_send_cid() rather than add to it.

>  
>  	return __sctp_auth_cid(chunk, asoc->peer.peer_chunks);

[Severity: Low]
The comment above sctp_auth_send_cid() still says:

    /* Check if peer requested that this chunk is authenticated */

After this change, the function also returns 0 when the local
association key is not set up, even if the peer listed the chunk.
Callers rely on the documented meaning. sctp_datamsg_from_user() says
"If the peer requested that we authenticate DATA chunks", and
_sctp_make_chunk() says "Determine if the chunk needs to be
authenticated".

Should the comment be updated to mention the local key check?

[Severity: High]
This isn't a bug introduced by this patch, but the same crash (an
authenticated chunk with a NULL key) looks reachable through stream
interleaving. The new !asoc->shkey check does not cover that path.

sctp_datamsg_from_user() picks the per-chunk key by asking about DATA:

    if (sctp_auth_send_cid(SCTP_CID_DATA, asoc)) {
        ...
            shkey = asoc->shkey;

With interleaving, the chunk is built by
sctp_make_idatafrag_empty()->sctp_make_idata()->_sctp_make_chunk(asoc,
SCTP_CID_I_DATA, ...). That function sets the auth flag by asking about
I-DATA:

    if (sctp_auth_send_cid(type, asoc))
        retval->auth = 1;

If the peer lists I-DATA (0x40) but not DATA in its CHUNKS parameter,
every I-DATA chunk gets auth=1 with shkey=NULL. asoc->shkey itself is
valid in this case, so the new check does not apply. On transmit,
sctp_packet_append_chunk()->sctp_packet_bundle_auth() then dereferences
NULL:

    auth = sctp_make_auth(asoc, chunk->shkey->key_id);

In the reverse case (DATA listed, I-DATA not), shkey is set and auth is
0. No AUTH chunk is ever bundled, so sctp_packet_will_fit() returns
SCTP_XMIT_PMTU_FULL every time, even for an empty packet:

    if ((packet->auth && chunk->shkey != packet->auth->shkey) ||
        (!packet->auth && chunk->shkey &&
         chunk->chunk_hdr->type != SCTP_CID_AUTH))
        return SCTP_XMIT_PMTU_FULL;

The I-DATA chunk is then never sent.

No fault injection is needed. The local side has to enable AUTH and
interleaving (SCTP_FRAGMENT_INTERLEAVE and SCTP_INTERLEAVING_SUPPORTED,
plus the net.sctp.intl_enable sysctl, which is off by default). The
first sendmsg() then triggers the NULL dereference.

Should the key selection in sctp_datamsg_from_user() use the same chunk
type as the chunk that make_datafrag builds?

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/179505710266.3511678.14017674052424733262%40gmail.com
Technical Details
Message-ID: <179540440300.3135.8565987128928534228@kernel.org>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!3.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!peer04.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-368990-linux-kernel-netdev=dewy.ru
References: <179505710266.3511678.14017674052424733262@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!3.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!peer04.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-368990-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [BUG] sctp: auth: NULL asoc->shkey after a failed SCTP_CMD_ASSOC_SHKEY makes close() oops
Date: Mon, 23 Nov 2026 03:26:43 +0000
Organization: Usenet Network
Message-ID: <179540440300.3135.8565987128928534228@kernel.org>
References: <179505710266.3511678.14017674052424733262@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network; logging-data="3781290"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:oOaCdGQ4OEkckCadKkuX2xTgdSM= sha256:VaDEa3gehvgxdIJ1p6Ox5pZDw3pnRzrT0WCY4js9o7s= sha1:ujuGU4NK4UoJGHgqkRPV862zPro= sha256:GmpoLeUgbGS1ZZoMgAWPhNT5zFHmu3W2wKIQdSIKSMc=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id DC808125D8A; Mon, 23 Nov 2026 06:27:00 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.4
X-Spam-Status: No, score=-3.4 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id qvLuSVvGVnWT; Mon, 23 Nov 2026 06:26:57 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-368990-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id A79D5125D89; Mon, 23 Nov 2026 06:26:48 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by tor.lore.kernel.org (Postfix) with ESMTP id 3B93528C02; Mon, 23 Nov 2026 03:26:47 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1795404405; b=zuJmfBT17rDu9w1KFvHyTGhXlbBTnqUxyIKQp32wYVjPO6M3Vpdsa3t0DUsFNraSmZge xEhAy4gqv6Cb1F3321ebG33PXVT1XUpyNKf8e1a3XgSZKdZ7pBBmdFRhkKDlfoIL+cnG5 zbMFVNVgNRuBb0gNWBomydKDuQYIjX1CIOX6McpublBDNjxaYCJvxg9ZGgAuhnLxpR5m9 Mv9+Gw7SPu0dwYdqUCRFx3Yjn94T0vFttb6p+8qaLEi70ptdc+SPDGiyklmuTO1tAb0Vz 33v7/YGhjB4M2b8fD4xr6w2w32AP87DmiwOLYMGdGWacdNmDUAPKErsRfyFvBOjDh7w==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795404405; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=wc6ekr9cryGg73k6nk6oY3aWkmjnvr4TDpjauBGQjHM=; b=pxH1cVn8slkzMIfx0j935ZwHquMuSnZoN8jQI84refmkKoxqadaD/GW+Y1UM4GyH7vTH NdNUe0Ep9+d5Z8x8Rrd6eqGuw4z8UM/sfFdjnX3qHFJgR5vO1EAqdnFIPQVr1ftXXXJQX xmH0VFJr2hMYyE0NOpKd8fkv8heGhOMU343zebyKJsHklFrO923v1bqfXy70gkPZ/dNEY l16Wi6jtFhGgeRLlzeAF+IqUhsZSV0tLl9evWfzy5N+vQ7uklRRw+TqST/IE1myOzGmOJ t6FKVuLt/od7bwrl7HO36bg7I736oRDBBXK6o9DGOR0nZIc1Y6y1c4GNnejtZF/YxSg==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=N9V3oaXf; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 91976606A334; Mon, 23 Nov 2026 03:26:45 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=N9V3oaXf
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795404404; b=s1aB4nw5UV+73XnaPYl6Ox31J8j73MWu8ijzsHzwFvM8HOFjrc5t2NLa9/eeuqBS/vb+ vCzkOKMlq05py0auWlVrWCkQmKS/d/3THvcnO0F05OWkoOIiCjNpWh0Fc5Gf3GVESLhlR 31IrYRLHk5HweOK3k6NtDGqmQihU9OOv99j7DXYqeey8/opY64Vanj4z85Dq0I/u6RZ62 PmLv+ZrHrV51wtl/B1vJPBjVLI1kEpxaTj4JBXhqnaJww36WKxPwYPnUCZ/0J3bVtKqg0 h9qBa6LOMMZheNSrdkFAO884ZbR7XWZ0t4gvK0Grvdo3idEp/XHUO3FFBOoAv4QHl/g==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795404404; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=wc6ekr9cryGg73k6nk6oY3aWkmjnvr4TDpjauBGQjHM=; b=e8xgRmvRW8ybGTlB2Vzej8xLzZp4yBiGz9tKZuEMyWmv9+biFkr4nfjp/+C25o0Q0t+5 mYaifc1bBYj6Si4nh7G0C1bYmpc4AmnHZtVSC4pa8z0GgKG+cvweYRK7U3CUqIkJR1X5m nskuAVvpGWzVQ5y2fWuc6DfHRmEmudd3/PJGNVhjpwzU0JagtkBm3UiUjiF3oHVmraLqh CZi6ysfp9IPjTUt3DGrkeeH3DLVjFFafVXU1yW277u2PwvY+DfROzVGreey3IUK9UXUv8 NgwBgamCsAFKZ32nxIOAMpT9xo34mhlf4pmUgru6stUeacI6zdLuaTrYoWmPpSe51EA==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=N9V3oaXf; arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B394D606A31A; Mon, 23 Nov 2026 03:26:44 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7C4DE1F000D3; Mon, 23 Nov 2026 03:26:43 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795404404; bh=wc6ekr9cryGg73k6nk6oY3aWkmjnvr4TDpjauBGQjHM=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=N9V3oaXfJVu8TmQHR3rUC4K5ZiDXFHSNdFSVyHLXtdJlCSzqQlSCB783vk6qRg+QB YYcDkFheTwBssTfubNSjsxc4+L0HiMmXnhF/1bueAtDG3hWzuol3XWEzpWwpkCLzu1 HyKJjj6ICPWgR8HQSeyBLVBkgyUKGXyBOEEu0//yR8lQSKtiZaMWhk/dMgYIe2A1ae SD4cVlwwbMryHpMlMfLi20YInXo1r48aI6KWzr3ag0OXWLjJRtbxIHQ+tPw0ud7OsK nNCIWTz92y7PeQiCU5AUSh5kI8cR+84nwLZQSjvV6ehkulr22HUlOmjoWfZaxZT5KA i2a0/C66QPyaQ==
X-Cc: marcelo.leitner@gmail.com, lucien.xin@gmail.com, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, junvyyang@tencent.com, linux-sctp@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org
X-In-Reply-To: <179505710266.3511678.14017674052424733262@gmail.com>
X-sashiko-severity: High
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list
X-Received-Bytes: 16454