From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.175 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796067959; b=eZPE27m6COaotZv5hoG9/GQUB1DIwAi3ae3Nabe4U+/7VGZFDlErmUWi0kqt6QCfs9Aq 1sCxLoDnjFdYGNwR+1wPQFP8+UhQstkVaKodGeeZ5whmkobN6vTpzLnSufs+C+xUwB/lg dCTnlpMkuUItRLMlUCgHP74v07XgnWEHO6KblIorpmUfmonIzUWQn9EnPwA6P91kJMWd+ 4oa1gQ24rfOqQXMpaWZmXCwxyoXjyHz8IfPzSwWKnu5Imq4aO9Kef4wXibRvbAske/Ppu nS/C88PUYm4abZcZ+pG/8MW34FULgHh9iJQZsGSgKTTqsPzM3ZGRWztVEtA9OKZbutw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796067959; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:MIME-Version: Content-Transfer-Encoding; bh=9jhmei3ttSLOMdtjQZoc5BCerL3EA3EyJqveU7gVCUo=; b=hEuJyma9IIk3px8YnJceD5ouW8xW7GCjmwJkOXZk3ElYsAgU3dz60f5/9azrhV0821LN 85Ej0KvQGk9oOLNNbyNY+5BI0kEsvIsA7d14PXQpSvna3ekdMiiOSD68NSWrS5F1dh0OR 88xk1U7HQK+/cECRgIkLg57KN86x4nC20ulNt78tkNkyIhiNR3dUa7HgUPsmsy1llWWLu y69bRxdN/Io1IBVPUjQOMy0lO6qnYrdFGTL/RCacfKY+yO4E1+qXiKF93mCBuHhcH93Mh HhZmLBj9HabJR0iIr3mlMYZia0pcr+08vgnqEy6XCCH0GYuO6EmkYlMOg5aVZF3aWnw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=Bp7gqd4a; arc=none smtp.remote-ip=74.125.82.175 Received: from mail-dy1-f175.google.com (mail-dy1-f175.google.com [74.125.82.175]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CDACF606A320 for ; Mon, 30 Nov 2026 19:45:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org CDACF606A320 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=Bp7gqd4a Received: by mail-dy1-f175.google.com with SMTP id 5a478bee46e88-386c4d2e2ccso10310793eec.0 for ; Mon, 30 Nov 2026 11:45:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796067958; x=1796672758; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=9jhmei3ttSLOMdtjQZoc5BCerL3EA3EyJqveU7gVCUo=; b=Bp7gqd4aeldjXXpujLn648rFDvV4cqlTsouZ7gcnvAxJx93PFW7yHzQgwd8uUYddzv m6RDVs/SR8alLEEXbRrVHMS/yjUE+2paQGd4SSKdOA10iiTOP6khFypvQsNgf6aku6nP 1MSEiEtCy77htPZgvA+WMxKZokAdZcYJ23qh2B2LhZeBL7dKE/OWpwNMhOj/I2dbh+bx 4m8cBz/PKKfBmdz7ZHnvwpMyuCOPVXCTxNgu+Z5fYC51RdFCRmip5atS8gvfdCnsFX5V RA7SMzIQsRgtS2WnNbfwG/2mTkUn7RcjVE6wogw6Aw6pI38/ASlzHuVEqCfv+j8qow9K Rcog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796067958; x=1796672758; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=9jhmei3ttSLOMdtjQZoc5BCerL3EA3EyJqveU7gVCUo=; b=g2z4u8X7Kx4n4qHz9BBjX9T/xzKS78emc5tYuL14VtMBHZidsUNk8p0QDab37LU6sI VNf1BezaJ3VjamANJjxEABEDNOWrnNKj0ESvfeSwa7GkpOBJUG2HAQzgwMQ+0gCUK4Ez wsHi8D9RE/tS6MReB0i+FDSaLVCl40O8BI5JldSABSt3e13JcprYTPyC6HAE7gt4kaja IFG6/xLVdTdtvejyR6a9S0PruuAMP3HOgTzCGFRMD/sZCAaxcLYIa59n7cR9Yj/2taq6 W/KXP2Wxszmeu/cPPax1y9LFjC4h2JabNVWmvpMIShycaI8q6pX6fWAmB03doB6zEwd9 +5pw== X-Forwarded-Encrypted: i=1; AL+hErH3xxlQz5QE0rddcb6dGjM1n0sGhNtTeJJV2TmXaRajR2FOtcJB+8d7kGgH+P//6sGzNL42RDYWsCH+H+M=@vger.kernel.org X-Gm-Message-State: APuU4Z/nC+3nWL+8Wtgj7EVDp+T4kS9Sn6OjBySX+P7rrvJq6xmzeAjz Ox/S8Jt78BkMMJ4B4I8gnvEdzR/CZutOaUpwbpXI5igEqxBbgJijvjF3 X-Gm-Gg: AZFdTZc1X+zhMznOVRKiX4d1QvExwdoR5iecH1h+hvxcmGs4bWc6QWIqb2mKdRcEw+c tuXydIVEc+00WWDJ6bVw/iHb34AhsXG33JXrqduOFJpcvquT7lSargkAZRjPKGNU5As0vJz+eyG zmtsilWUrIAJ4RXK1JdrqLnLAj1Gegb1g+9XCIQyUTA03ffKQ+bc6Wlc8gxkxtUif/OmBPd1PzL n+tCdiBPU9pvtVw6414nap8A1aZNT+RsAUWkHD7F9q5tlLGUD8a3XZEGSgwJZcdu9c82C1b+EjF gN/UoVcuYiJsC27PQVuvAzWshUCejte2wnf1DzI13GxTHXcjJt2NON7t+8FnrE9AZyb10/bHS1N ol7ZayuzylD70k61j/ZiCJwbu17Pr0uhV/3QPK6MaqD+useGsrU9cVAo6oIPZWrdBXgd3vpTUfS YO27PLLwOikDHm8hcTzHiWu/Q3NcRq328qxYC0XSpDoPXKj6Np8rfKsihdPQjXg5cLsFl0QuFv7 E+PyhJ4Wlb9y27gbUDdE/RAP0kBPTc6FzkyHflpwJwDjEEM4BCuwLlXb7xTPAXLPRo8ycSk6xs2 DIBXsrqxojaolkygB6hEchVt1/2tB/0EIxQALr7GaumnsPHNxHICIQsFsVk96O5WvJzWvDtcwJK NV+/v2TKwwZyZ X-Received: by 2002:a05:7301:6e9a:b0:37e:9a3b:76a3 with SMTP id 5a478bee46e88-3856f14b9edmr33481605eec.11.1796067957872; Mon, 30 Nov 2026 11:45:57 -0800 (PST) Received: from d20be28ee783.tail196be.ts.net (vldb.skku.ac.kr. [115.145.173.180]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-385666e99fdsm118027400eec.5.2026.11.30.11.45.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2026 11:45:57 -0800 (PST) From: Kyuwon Cho To: Xin Long Cc: Marcelo Ricardo Leitner , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Willem de Bruijn , Jun Yang , linux-sctp@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net v5] sctp: fail the association when the INIT-ACK cannot be processed Date: Tue, 1 Dec 2026 04:45:52 +0900 Message-ID: <179606760834.392646.8338794156534192538@gmail.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Kyuwon Cho --- The issue was found by an LLM-guided test generator that we are developing as a research prototype. v5: - Post the patch on its own, without a cover letter (Xin). - The v4 posting was by mistake a diff on top of v3 and did not apply to net. This is the whole change, rebased on net; the code is what v4 meant to be. v4: https://lore.kernel.org/netdev/cover.1795572890.git.kyuwoncho18@gmail.com/ - 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/ With the patch, the reproducer from v1 no longer triggers the report. Tested on net 76fca30e8d34. include/net/sctp/command.h | 4 ---- net/sctp/sm_sideeffect.c | 40 -------------------------------------- net/sctp/sm_statefuns.c | 19 +++++++++++++++--- 3 files changed, 16 insertions(+), 47 deletions(-) diff --git a/include/net/sctp/command.h b/include/net/sctp/command.h index 2058fabffbf6..8596e96c321a 100644 --- a/include/net/sctp/command.h +++ b/include/net/sctp/command.h @@ -34,7 +34,6 @@ enum sctp_verb { SCTP_CMD_GEN_SACK, /* Send a Selective ACK (maybe). */ SCTP_CMD_PROCESS_SACK, /* Process an inbound SACK. */ SCTP_CMD_GEN_INIT_ACK, /* Generate an INIT ACK chunk. */ - SCTP_CMD_PEER_INIT, /* Process a INIT from the peer. */ SCTP_CMD_GEN_COOKIE_ECHO, /* Generate a COOKIE ECHO chunk. */ SCTP_CMD_CHUNK_ULP, /* Send a chunk to the sockets layer. */ SCTP_CMD_EVENT_ULP, /* Send a notification to the sockets layer. */ @@ -86,7 +85,6 @@ enum sctp_verb { SCTP_CMD_ASSOC_CHANGE, /* generate and send assoc_change event */ SCTP_CMD_ADAPTATION_IND, /* generate and send adaptation event */ SCTP_CMD_PEER_NO_AUTH, /* generate and send authentication event */ - SCTP_CMD_ASSOC_SHKEY, /* generate the association shared keys */ SCTP_CMD_T1_RETRAN, /* Mark for retransmission after T1 timeout */ SCTP_CMD_UPDATE_INITTAG, /* Update peer inittag */ SCTP_CMD_SEND_MSG, /* Send the whole use message */ @@ -117,7 +115,6 @@ union sctp_arg { struct sctp_association *asoc; struct sctp_transport *transport; struct sctp_bind_addr *bp; - struct sctp_init_chunk *init; struct sctp_ulpevent *ulpevent; struct sctp_packet *packet; struct sctp_sackhdr *sackh; @@ -158,7 +155,6 @@ SCTP_ARG_CONSTRUCTOR(CHUNK, struct sctp_chunk *, chunk) SCTP_ARG_CONSTRUCTOR(ASOC, struct sctp_association *, asoc) SCTP_ARG_CONSTRUCTOR(TRANSPORT, struct sctp_transport *, transport) SCTP_ARG_CONSTRUCTOR(BA, struct sctp_bind_addr *, bp) -SCTP_ARG_CONSTRUCTOR(PEER_INIT, struct sctp_init_chunk *, init) SCTP_ARG_CONSTRUCTOR(ULPEVENT, struct sctp_ulpevent *, ulpevent) SCTP_ARG_CONSTRUCTOR(PACKET, struct sctp_packet *, packet) SCTP_ARG_CONSTRUCTOR(SACKH, struct sctp_sackhdr *, sackh) diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c index 35f540fb15fc..a95bf10b852b 100644 --- a/net/sctp/sm_sideeffect.c +++ b/net/sctp/sm_sideeffect.c @@ -698,32 +698,6 @@ static void sctp_cmd_assoc_failed(struct sctp_cmd_seq *commands, sctp_add_cmd_sf(commands, SCTP_CMD_DELETE_TCB, SCTP_NULL()); } -/* Process an init chunk (may be real INIT/INIT-ACK or an embedded INIT - * inside the cookie. In reality, this is only used for INIT-ACK processing - * since all other cases use "temporary" associations and can do all - * their work in statefuns directly. - */ -static int sctp_cmd_process_init(struct sctp_cmd_seq *commands, - struct sctp_association *asoc, - struct sctp_chunk *chunk, - struct sctp_init_chunk *peer_init, - gfp_t gfp) -{ - int error; - - /* We only process the init as a sideeffect in a single - * case. This is when we process the INIT-ACK. If we - * fail during INIT processing (due to malloc problems), - * just return the error and stop processing the stack. - */ - if (!sctp_process_init(asoc, chunk, sctp_source(chunk), peer_init, gfp)) - error = -ENOMEM; - else - error = 0; - - return error; -} - /* Helper function to break out starting up of heartbeat timers. */ static void sctp_cmd_hb_timers_start(struct sctp_cmd_seq *cmds, struct sctp_association *asoc) @@ -1397,16 +1371,6 @@ static int sctp_cmd_interpreter(enum sctp_event_type event_type, SCTP_CHUNK(new_obj)); break; - case SCTP_CMD_PEER_INIT: - /* Process a unified INIT from the peer. - * Note: Only used during INIT-ACK processing. If - * there is an error just return to the outter - * layer which will bail. - */ - error = sctp_cmd_process_init(commands, asoc, chunk, - cmd->obj.init, gfp); - break; - case SCTP_CMD_GEN_COOKIE_ECHO: /* Generate a COOKIE ECHO chunk. */ new_obj = sctp_make_cookie_echo(asoc, chunk); @@ -1772,10 +1736,6 @@ static int sctp_cmd_interpreter(enum sctp_event_type event_type, sctp_cmd_peer_no_auth(commands, asoc); break; - case SCTP_CMD_ASSOC_SHKEY: - error = sctp_auth_asoc_init_active_key(asoc, - GFP_ATOMIC); - break; case SCTP_CMD_UPDATE_INITTAG: asoc->peer.i.init_tag = cmd->obj.u32; break; diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c index 6a4205de0aa6..206fa0b6cd4b 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); + } /* 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); + } /* Reset init error count upon receipt of INIT-ACK. */ sctp_add_cmd_sf(commands, SCTP_CMD_INIT_COUNTER_RESET, SCTP_NULL()); -- 2.43.0