Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3DE99280CE5; Mon, 17 Aug 2026 14:21:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786976472; cv=none; b=d30Z4w2fbLvT1ru2IQyfdO0t8F3tw/5OTzktAWs1pZ5ItzKBCJSNvVT37/uFcWoNSRUnX4tDC6yJk5OpfG4ojC28oHn3VXv752ABwBk/kBPqvJ3y9UizTvHsC8kzTu6PRuYd18Dod9SP6TutPShRYW6JbsXmS0B0sP3ZJKSWTN0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786976472; c=relaxed/simple; bh=ihlTuKQyk7YIuwx8MyECk4c4yKl0ZDod1DFz/rOa9o8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KZ4vnPrEKe2CPqOZO9G4bcO0T7GcijLZhZTt5eSqFXXamfmZx6AfUGltvRZ5Wz1wo4/Nkm53RGsfsDzTrYhUTcDodr84Qt1JszLs22MmUGpK7pPYHpCsj7XxqtkOFiSmkB4Jo4vKU7/TYvdvis3oNhaSILwtAZ61nDb8u/W9T8I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=tPQCFLAp; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="tPQCFLAp" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4B4BD1F00A3A; Mon, 17 Aug 2026 14:21:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1786976470; bh=c5pbPLeF2pexxmhl4i6mMSrybRRoJ1z+hbNnCOqTVkE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=tPQCFLApffNpy7YVP1LKTWwgY84ze3yNJcYB0ZvleV+Mhb03TXvV3SppCuGeUDuSt 2vHJMNLAfN8B1dsOFsN/RWmb5hAuWtrKSxhcYgzmdYv/s0UBnFpmHmlBDHLqcmmbVK y5A4LIrSnjamUIlgGRzKa82BXdMl2DriwTQ8vYMk= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Xin Long , Yuxiang Yang , Jakub Kicinski Subject: [PATCH 5.10 384/389] sctp: fix use-after-free of cached ASCONF chunk Date: Mon, 17 Aug 2026 15:33:43 +0200 Message-ID: <20260817132553.641426846@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260817132538.796021292@linuxfoundation.org> References: <20260817132538.796021292@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Yuxiang Yang commit 8c283e7b56adce00193837f3311b06662466fb21 upstream. addip_last_asconf caches the outstanding outbound ASCONF chunk. The normal ASCONF-ACK completion path releases the chunk and clears the pointer. However, sctp_asconf_queue_teardown() releases the cached chunk without clearing addip_last_asconf. During peer restart handling, sctp_sf_do_dupcook_a() queues SCTP_CMD_PURGE_ASCONF_QUEUE, which invokes sctp_asconf_queue_teardown() while the association remains alive and leaves the pointer dangling. A delayed authenticated ASCONF-ACK can then reach sctp_sf_do_asconf_ack(), which accesses the stale chunk and passes it to sctp_process_asconf_ack(), causing a use-after-free and a second release. Clearing the pointer exposes a race with T4 expiry. Peer restart handling queues the timer stop before the purge, but SCTP_CMD_TIMER_STOP uses timer_delete(), which does not wait for a callback already running on another CPU. Such a callback can reach sctp_sf_t4_timer_expire() after the purge and dereference NULL. Clear addip_last_asconf after releasing the cached chunk, and make sctp_sf_t4_timer_expire() consume a stale T4 expiry if no outstanding ASCONF remains. Fixes: a000c01e60e4 ("sctp: stop pending timers and purge queues when peer restart asoc") Cc: stable@vger.kernel.org Suggested-by: Xin Long Signed-off-by: Yuxiang Yang Acked-by: Xin Long Link: https://patch.msgid.link/20260809043806.2768302-1-yangyx22@mails.tsinghua.edu.cn Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- net/sctp/associola.c | 4 +++- net/sctp/sm_statefuns.c | 6 +++++- 2 files changed, 8 insertions(+), 2 deletions(-) --- a/net/sctp/associola.c +++ b/net/sctp/associola.c @@ -1722,6 +1722,8 @@ void sctp_asconf_queue_teardown(struct s sctp_assoc_free_asconf_queue(asoc); /* Free any cached ASCONF chunk. */ - if (asoc->addip_last_asconf) + if (asoc->addip_last_asconf) { sctp_chunk_free(asoc->addip_last_asconf); + asoc->addip_last_asconf = NULL; + } } --- a/net/sctp/sm_statefuns.c +++ b/net/sctp/sm_statefuns.c @@ -5999,8 +5999,12 @@ enum sctp_disposition sctp_sf_t4_timer_e struct sctp_cmd_seq *commands) { struct sctp_chunk *chunk = asoc->addip_last_asconf; - struct sctp_transport *transport = chunk->transport; + struct sctp_transport *transport; + if (!chunk) + return SCTP_DISPOSITION_CONSUME; + + transport = chunk->transport; SCTP_INC_STATS(net, SCTP_MIB_T4_RTO_EXPIREDS); /* ADDIP 4.1 B1) Increment the error counters and perform path failure