From nobody Tue Sep 29 11:19:51 2026 Received: from zg8tmtu5ljg5lje1ms4xmtka.icoremail.net (zg8tmtu5ljg5lje1ms4xmtka.icoremail.net [159.89.151.119]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6196D2D6E58; Sat, 8 Aug 2026 00:58:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.89.151.119 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786150706; cv=none; b=EnRYmAU2K+02JoYAWyb1N9PkU6iMe+SJBPjqJSU046I83Qk3LVssq+CGmRZlJ+1hArRtAydH6AgfhX+YTo/Ks8G2XSVmjpEfzfCIqW+0xjAYkn8yJUfARDVhqCwnZyFCNsQJl9sThowsUWYND3VJGn8UN+WjnkcBt2Q3/bedilI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786150706; c=relaxed/simple; bh=yZkREdEjHQEDUr57udPnaYwkQLcQxYJhgfKaohafuPg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=b2rfGKXXLNb+ZsfDbLEXOKo4WyUzY1ITZrqLGqyIYPUykL4dtUZvd3BkBovdLE9WgBdon8EMiA2i4FaVlfku94RqTKNcKJ12d5vOwrpUUgkYyBB04THo1tcEYjPbIa/CA0ajHqP+Pe3Rof5NlytUzpXZ3TjNWUCIFpbkg8ASDz4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mails.tsinghua.edu.cn; spf=pass smtp.mailfrom=mails.tsinghua.edu.cn; dkim=pass (1024-bit key) header.d=mails.tsinghua.edu.cn header.i=@mails.tsinghua.edu.cn header.b=QepjMXoc; arc=none smtp.client-ip=159.89.151.119 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mails.tsinghua.edu.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mails.tsinghua.edu.cn Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=mails.tsinghua.edu.cn header.i=@mails.tsinghua.edu.cn header.b="QepjMXoc" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mails.tsinghua.edu.cn; s=dkim; h=Received:From:To:Cc:Subject: Date:Message-Id:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=TNDApsOsnp2m2lDrTJuIAVtUvQ2U/qmosQ 3lDWNOF4A=; b=QepjMXocUszGkTzHW3esG5/gCgz7RAoajs/svlf+M2KcxcwnWs Tw9XF/U1iwB2SXPfdwrqjJ5eB87NWOxdorrxSAb3C33RPYEaoyiIApK8ccez4N0e tsKxgPwN1eAsWXPSGbqGpMw+JigNC9jpAzsIfRWOfuUjZrYT8ts5DW9KU= Received: from gpu-server-2.tailcd67b0.ts.net (unknown [101.52.241.91]) by web2 (Coremail) with SMTP id yQQGZQCHgrQOf3ZqgbvKAA--.21278S2; Sat, 08 Aug 2026 08:58:04 +0800 (CST) From: Yuxiang Yang To: linux-sctp@vger.kernel.org, netdev@vger.kernel.org Cc: marcelo.leitner@gmail.com, lucien.xin@gmail.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, linux-kernel@vger.kernel.org, Yuxiang Yang , stable@vger.kernel.org, Yizhou Zhao , Ao Wang , Xuewei Feng , Qi Li , Ke Xu , yyxroy22@gmail.com Subject: [PATCH net v2] sctp: fix use-after-free of cached ASCONF chunk Date: Sat, 8 Aug 2026 08:57:48 +0800 Message-Id: <20260808005748.1981039-1-yangyx22@mails.tsinghua.edu.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: yQQGZQCHgrQOf3ZqgbvKAA--.21278S2 X-Coremail-Antispam: 1UD129KBjvJXo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xwvl0wxkxdhvlgxou0/ Content-Type: text/plain; charset="utf-8" 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 Assisted-by: Claude-Code:GLM-5.2 Signed-off-by: Yuxiang Yang --- Changes in v2: - Guard sctp_sf_t4_timer_expire() against a cleared cached ASCONF pointer, as requested by Xin Long. - Explain why the T4 callback may run after the restart purge. net/sctp/associola.c | 4 +++- net/sctp/sm_statefuns.c | 6 +++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/net/sctp/associola.c b/net/sctp/associola.c index 5b0ae61..737f8ea 100644 --- a/net/sctp/associola.c +++ b/net/sctp/associola.c @@ -1713,6 +1713,8 @@ void sctp_asconf_queue_teardown(struct sctp_associati= on *asoc) sctp_assoc_free_asconf_queue(asoc); =20 /* 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 =3D NULL; + } } diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c index 708fa07..3a8e16b 100644 --- a/net/sctp/sm_statefuns.c +++ b/net/sctp/sm_statefuns.c @@ -6145,8 +6145,12 @@ enum sctp_disposition sctp_sf_t4_timer_expire( struct sctp_cmd_seq *commands) { struct sctp_chunk *chunk =3D asoc->addip_last_asconf; - struct sctp_transport *transport =3D chunk->transport; + struct sctp_transport *transport; + + if (!chunk) + return SCTP_DISPOSITION_CONSUME; =20 + transport =3D chunk->transport; SCTP_INC_STATS(net, SCTP_MIB_T4_RTO_EXPIREDS); =20 /* ADDIP 4.1 B1) Increment the error counters and perform path failure --=20 2.25.1