From mboxrd@z Thu Jan 1 00:00:00 1970 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 5C0EA394785; Sat, 17 Oct 2026 16:57:30 +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=1792256251; cv=none; b=jQ9eamrTTAXxZbLaK3dRzdHtfG0VI6/8wpYzS/X3+fiHCfqYTs/2wmBkDXOz87AOGaXrY1FJnhq7EfPn0WqZmLOoGJnsPY1xT90SW+yzgVE2z4c/P2NXwVP2oAqgleDnegsNjvGEUdYozYBPVCfLmiVbWW+YkqGA56IS6EXPXQg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1792256251; c=relaxed/simple; bh=ohpcEZJZDoq1JcR5xdP0E6oJsFRn/JOhXuLdshXfLBY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kacsXU7QZU9lzNm2DeV3hbH6yawnXz3mLSuIvZsCkJkaiI1CBQR9OQi02yG9SyFgLoysLCGKXTkpW8DNt1z16ZVgQ1gq4do/MxTfZsdf766u2OCDVrnTp1OLtsXoIrN9V1NoYA7QS4SroljW8EGJZLRFKwXiG21WtRBlxzO1mdE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=hjOTauto; 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="hjOTauto" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A78461F000C4; Sat, 17 Oct 2026 16:57:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1792256250; bh=J1OB1+ExSQKcRyFD5zlujOhTMoAkXQiMJwCybaLe0Og=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=hjOTautodclUgaMahOeKEf7vomUpihON7XrhuZnIw2WztsAZg57lv/qrs/Tbt+VvR XoVEKbDjbM3hwQPaR82BBHAyY2qo4zRm/Ix5Ktt6Rmf8M7Yxy+Ob9BwkSizAANlX74 nM1E9x8uFwhOY8sxw5vTZkq/qQZhnMY+le0XCWIw= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, TencentOS Corvus AI , Jun Yang , Xin Long , Jakub Kicinski Subject: [PATCH 6.6 0175/1674] sctp: check RCV_SHUTDOWN after the sendmsg connect wait Date: Sat, 17 Oct 2026 17:40:47 +0200 Message-ID: <20261017160435.648122604@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261017160431.119607952@linuxfoundation.org> References: <20261017160431.119607952@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 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jun Yang commit 4f1da630d13de0370e2f6361f961f1c8b384af1c upstream. sctp_wait_for_connect() drops the socket lock while it sleeps. An out-of-the-blue ABORT can then be processed from the socket backlog and unlink the association. If a concurrent shutdown(fd, SHUT_RD) sets RCV_SHUTDOWN, the waiter breaks with err == 0 before checking asoc->base.dead. Its final sctp_association_put() can then free the association, leaving sctp_sendmsg_to_asoc() to continue with a dangling pointer. Check RCV_SHUTDOWN along with the wait error in sctp_sendmsg_to_asoc() before using the association again. The check only accesses the socket, so it needs no additional association reference. Return the existing -ESRCH so that sctp_sendmsg() skips freeing a new association that may already have been destroyed. Keep sctp_wait_for_connect() unchanged to preserve its behavior for the connect() caller. Fixes: 668c9beb9020 ("sctp: implement assign_number for sctp_stream_interleave") Cc: stable@vger.kernel.org Reported-by: TencentOS Corvus AI Signed-off-by: Jun Yang Acked-by: Xin Long Link: https://patch.msgid.link/20260926095606.68601-1-juny24602@gmail.com Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- net/sctp/socket.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/net/sctp/socket.c +++ b/net/sctp/socket.c @@ -1843,7 +1843,7 @@ static int sctp_sendmsg_to_asoc(struct s if (asoc->ep->intl_enable) { timeo = sock_sndtimeo(sk, 0); err = sctp_wait_for_connect(asoc, &timeo); - if (err) { + if (err || sk->sk_shutdown & RCV_SHUTDOWN) { err = -ESRCH; goto err; }