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 8C4AA30F819; Fri, 9 Oct 2026 14:16:22 +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=1791555387; cv=none; b=k8qE5P9RFRbnRI6y/nX4OMGkuOUK+llG4aFc45in9eJ56RTX6HrR7IN3GqZ76flCPVNyuBEAws+2j7oqNRRWDxvexNGj66FsPVGK580RHHUuO8X6C6QclKRPCA50cZJMSoWbojFkD5W6c6MO+P2QJ9+7gH6acylriu+O4i7XxXs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791555387; c=relaxed/simple; bh=SYEGKmD1Pfm8uiDaw1l5cMjPU+SFTc7lEmvRHlJfMiA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pNaZ0jNfoPwxUHScCjg5zm+H+jQ6rosSgJnuMY/B9ydBFvDy0tW+GB7nNWnQLgT/v2ZvZCHvnXXVVZcpxgNUMxAS0D3CHigl/nZ2E9SWpDIH1IXlR/5SMHZXeIqkJz0fB/0Qxwo/9309rVRYlYqg4/xzajRABOEqFLuVly6HZPU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=2Q9nKVhv; 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="2Q9nKVhv" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 67AE51F00898; Fri, 9 Oct 2026 14:16:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1791555381; bh=O8i69GWhhc5OKjIqOCauw1DU477FhtJ8LDiWMN1T5FM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=2Q9nKVhv4W5f5R7STv1XrmfL8hayS3M2QmOYy44imrRq5rnkdAs3ovXMXOucajWNH dx87V01UG5QdX/ECTr0uwxTdtrWsonMmOCQ2z+25YT5TmHBhOVCBYd31rRyeZf16rf K7j0fkms5CywcnMy1GDMdxBZCyw17RbwjmGtqtKY= 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.18 039/403] sctp: check RCV_SHUTDOWN after the sendmsg connect wait Date: Fri, 9 Oct 2026 16:06:40 +0200 Message-ID: <20261009140953.022194704@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261009140952.119038291@linuxfoundation.org> References: <20261009140952.119038291@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.18-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; }