From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796154390; b=tSJiJRtjHMH36qJIhxpQkM/FZIYvawxyI/n5dwHRRouA+MxkeIlDOpb6+TncKHdk9NH+ iwwAqRt57zU0JchJaH1eIOt2Uyr1y5HxQeqb0DzInn7WYRQ5s6IWKH4Bb+jWgg30CAX2f HGuzDSAMkuKQ0vuMVrLWPfdkWkXP+08D3uJZJyEfZoBda4+FEQL1QwvrIBAPudP3SXA3M WnMcCG1iaywnsULaLljuoZsvDexcb2cCvYd7sDAf5Ska9UKaBQrOI9yZc32wzq+qXpz0F WGRC5KhO3q4OCoKFqQNkknZCJHhLF7UVlBWfKTj27eLMBbKe1DlaBl/NAaj0AbMRzGQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796154390; 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=4xF1Xw64oHf18m3R5j1PLivnCt5WngOk09NsE9tXPlM=; b=Ccw37ZlYdnjPlv4kEMDbk+esS6DQMMKI5SaQOEXgUSPNHwYG+OGVLHMJllef7gaWtf9+ nyarCw0bHSBgU2PXTHLF00pCFvlTDwEk03UvFT8BAEoGAD+v18NPETUD5Exi1cd2Q6Zw6 7mROvs8lzajrSCAHz5H7+gfnjYVpGlQyLes9XhY1LdqZe1cTSccuNgBSXigo3l7RJuy5I hV7mraLo877a1G25Gm33b/jJL1fQBhINF+aXaRf3XXMEs3OIxhxa2pmKSOTZN7ntayIT8 3r2xubpw12Kkzy7JWsiEP0BinuzCgYgY0cLnYd04Lv2sA18smua/dmU6qd9XVRXBq3A== 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=kKWXsNGv; arc=none smtp.remote-ip=100.103.45.18 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 6DC0F606A68B; Tue, 1 Dec 2026 19:46:30 +0000 (UTC) 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=kKWXsNGv Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7F3381F00897; Tue, 1 Dec 2026 19:46:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796154390; bh=4xF1Xw64oHf18m3R5j1PLivnCt5WngOk09NsE9tXPlM=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=kKWXsNGvybJ3FT1G+X3FjnjJOnHf1iq5R2w9VcT1lT03K1eij9sh3zKvU3ByNAg/+ NldI+5vYS7XYj8OnUlxqTWhLxdrmgCkptnAWbU2gUHHXFCYw8YBJ/cZB2ieVCTiGxN oFYkpH+oKiAkt4qhuyUqsVjm0rvg16FvPJqS74VufNo/WPtyzZ+FYtF722de/ImL6c bsUwQHMfPwX/phMmNm/HBxPg5mt/XxcqqQBqxwbjBRvDEuqyvrjtn8/tPseCiL5nLq 9yjtbiT0koaKQwYJkEBnhlo6AmeahV7HPXsyWh0KzUD3jvve0uMU57+B4z/NYqVSko BosuwYfrNscCA== Subject: Re: [PATCH net v5] sctp: fail the association when the INIT-ACK cannot be processed From: netdev-bot+sashiko@kernel.org To: kyuwoncho18@gmail.com Cc: lucien.xin@gmail.com, marcelo.leitner@gmail.com, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, willemb@google.com, junvyyang@tencent.com, linux-sctp@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Date: Tue, 01 Dec 2026 19:46:29 +0000 Message-ID: <179615438903.3146.1656176944205841909@kernel.org> In-Reply-To: <179606760834.392646.8338794156534192538@gmail.com> References: <179606760834.392646.8338794156534192538@gmail.com> X-sashiko-severity: High Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider. Critical: 0 · High: 1 · Medium: 1 · Low: 0 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. - [Medium] Every sctp_process_init() failure in sctp_sf_do_5_1C_ack() (net/sctp/sm_statefuns.c, around lines 606-613) is now reported as an… -- sctp: fail the association when the INIT-ACK cannot be processed This patch calls sctp_process_init() and sctp_auth_asoc_init_active_key() directly from sctp_sf_do_5_1C_ack() instead of queueing them as side-effect commands. If either step fails, the association is aborted with sctp_stop_t1_and_abort(). The now unused SCTP_CMD_PEER_INIT and SCTP_CMD_ASSOC_SHKEY commands are removed. > diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c > index 6a4205de0aa69..206fa0b6cd4b8 100644 > --- a/net/sctp/sm_statefuns.c > +++ b/net/sctp/sm_statefuns.c > @@ -603,13 +603,26 @@ enum sctp_disposition sctp_sf_do_5_1C_ack(struct net *net, > > initchunk = (struct sctp_init_chunk *)chunk->chunk_hdr; > > - sctp_add_cmd_sf(commands, SCTP_CMD_PEER_INIT, > - SCTP_PEER_INIT(initchunk)); > + if (!sctp_process_init((struct sctp_association *)asoc, chunk, > + sctp_source(chunk), initchunk, GFP_ATOMIC)) { > + if (err_chunk) > + sctp_chunk_free(err_chunk); > + return sctp_stop_t1_and_abort(net, commands, > + SCTP_ERROR_NO_RESOURCE, ENOMEM, > + asoc, chunk->transport); > + } [Severity: Medium] sctp_process_init() returns 0 for allocation failures and also for peer or policy rejections. Does this report ENOMEM for failures that have nothing to do with memory? The non-memory cases are the !src_match check, sctp_process_param() rejections, and the ASCONF-without-AUTH check. That last check is active by default because addip_noauth is 0: net/sctp/sm_make_chunk.c:sctp_process_init() { ... if (!asoc->base.net->sctp.addip_noauth && (asoc->peer.asconf_capable && !asoc->peer.auth_capable)) { ... goto clean_up; } ... } In those cases sctp_cmd_set_sk_err() sets sk->sk_err = ENOMEM on non-UDP-style sockets. That value is what SO_ERROR returns after a non-blocking connect(), and later sock_error() callers see it too. The SCTP_ASSOC_CHANGE / SCTP_CANT_STR_ASSOC notification also carries SCTP_ERROR_NO_RESOURCE. A blocking connect() still returns ECONNREFUSED or ETIMEDOUT from sctp_wait_for_connect(), because that path ignores sk_err. The verification failure path just above reports a similar peer-caused rejection as ECONNREFUSED with SCTP_ERROR_INV_PARAM. Before this patch the -ENOMEM from the interpreter was dropped, T1-init kept retransmitting, and the application eventually saw ETIMEDOUT. The commit message says the ASCONF-without-AUTH case now aborts at once, but it doesn't say that userspace will see ENOMEM / NO_RESOURCE for it. Could the non-memory rejections report a different error here? The comment in sctp_process_init() also still says: * also give us an option to silently ignore the packet, which * is what we'll do here. The INIT-ACK path is the only caller with a non-temporary association, and it now tears the association down instead. Should this comment be updated? > > /* SCTP-AUTH: generate the association shared keys so that > * we can potentially sign the COOKIE-ECHO. > */ > - sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_SHKEY, SCTP_NULL()); > + if (sctp_auth_asoc_init_active_key((struct sctp_association *)asoc, > + GFP_ATOMIC)) { > + if (err_chunk) > + sctp_chunk_free(err_chunk); > + return sctp_stop_t1_and_abort(net, commands, > + SCTP_ERROR_NO_RESOURCE, ENOMEM, > + asoc, chunk->transport); > + } [Severity: High] The commit message describes the bug as: with the peer marked AUTH capable and asoc->shkey still NULL, a chunk that the peer wants authenticated ... takes a reference on the NULL key Can the COOKIE-ECHO restart and collision handlers still reach this state? sctp_sf_do_dupcook_a() and sctp_sf_do_dupcook_b() both call sctp_sf_do_assoc_update()->sctp_assoc_update(). That function commits the peer's AUTH state before it installs the key: net/sctp/associola.c:sctp_assoc_update() { ... asoc->peer.auth_capable = new->peer.auth_capable; ... kfree(asoc->peer.peer_chunks); asoc->peer.peer_chunks = new->peer.peer_chunks; new->peer.peer_chunks = NULL; ... return sctp_auth_asoc_init_active_key(asoc, GFP_ATOMIC); } sctp_auth_asoc_init_active_key() can fail with -ENOMEM when sctp_auth_asoc_create_secret() fails, and then asoc->shkey is never set. Suppose the existing association had a non-AUTH peer, or was still in COOKIE_WAIT (the dupcook_b collision case). Then shkey stays NULL while auth_capable is now 1 and peer_chunks can list ABORT. sctp_sf_do_assoc_update() then builds an ABORT on that association right away: net/sctp/sm_statefuns.c:sctp_sf_do_assoc_update() { if (!sctp_assoc_update(asoc, new)) return 0; abort = sctp_make_abort(asoc, NULL, sizeof(struct sctp_errhdr)); ... } This looks like it ends at the same crash site as the KASAN report: sctp_make_abort() sctp_make_control() _sctp_make_chunk() sctp_auth_send_cid(SCTP_CID_ABORT, asoc) -> retval->auth = 1 sctp_control_set_owner_w() chunk->shkey = asoc->shkey; /* NULL */ sctp_auth_shkey_hold(chunk->shkey); A remote peer can trigger this if ep->auth_enable is set locally and the same GFP_ATOMIC failure that the reproducer relies on happens. The peer restarts or collides with an INIT that advertises AUTH (RANDOM, HMAC-ALGO, and CHUNKS including ABORT), then echoes the cookie. Should sctp_assoc_update() commit auth_capable and peer_chunks only after the key is installed? Alternatively, should the ABORT built in sctp_sf_do_assoc_update() not be authenticated? > > /* Reset init error count upon receipt of INIT-ACK. */ > sctp_add_cmd_sf(commands, SCTP_CMD_INIT_COUNTER_RESET, SCTP_NULL()); -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/179606760834.392646.8338794156534192538%40gmail.com