From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 7459C2D541B; Thu, 15 Jan 2026 17:16:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768497370; cv=none; b=ZIfuklKScf8UBSQrhA/Ql45zKjpVNw0Fxp1YvDGD6W+kKtxdA5b1JPrLDOzK4T2jwfMuvyd38c8MpuaYOPDibNuufjVCQe8ICHV9UFFkkDddzS3K4gpz7NfxEj7JJfIuAZ/bnpucDGOjKjLPV6Jiwa2udw3UnRJgsJSzLM7KfQk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768497370; c=relaxed/simple; bh=ydwaucHDpENCsVsD+MZq2MxoZ4wHCwtYTNHBi0yUnwo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DuZ/v4sdw/FppPenFEgtsYHrZgOKgLvSRn+lEukPP39u7eKQEWyR6yUiPDfhgoZqbRyFOp+GuiVz2IhJGcpnD8RNU1bIGdZRY7H5bBecAGWzbuJQETCR2YyiuMjeHBXSLyjBBAXxXziFehl8rtEtHvmjR5O3kbbWu8DB+XwJfzU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=NQ3J0Cto; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="NQ3J0Cto" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F0DB3C116D0; Thu, 15 Jan 2026 17:16:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1768497370; bh=ydwaucHDpENCsVsD+MZq2MxoZ4wHCwtYTNHBi0yUnwo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NQ3J0Cto4sLXxI1kuf1SVcGqn2jVfdWS3dcno/KSvt+bIJWRM+TbZ2XtCZ87jIMTl c7m2DCo2tvP+5MWwBcEWJGWlEuOI88uYCVGQfhEKtncHw2MwtYguA/Tz8k7q63yNNu /FzoObywu5JvLIwikm9BdVX8fWgEYnn39apCkvkE= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Kuniyuki Iwashima , Xin Long , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.15 056/554] sctp: Defer SCTP_DBG_OBJCNT_DEC() to sctp_destroy_sock(). Date: Thu, 15 Jan 2026 17:42:02 +0100 Message-ID: <20260115164248.273180215@linuxfoundation.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260115164246.225995385@linuxfoundation.org> References: <20260115164246.225995385@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Kuniyuki Iwashima [ Upstream commit 622e8838a29845316668ec2e7648428878df7f9a ] SCTP_DBG_OBJCNT_INC() is called only when sctp_init_sock() returns 0 after successfully allocating sctp_sk(sk)->ep. OTOH, SCTP_DBG_OBJCNT_DEC() is called in sctp_close(). The code seems to expect that the socket is always exposed to userspace once SCTP_DBG_OBJCNT_INC() is incremented, but there is a path where the assumption is not true. In sctp_accept(), sctp_sock_migrate() could fail after sctp_init_sock(). Then, sk_common_release() does not call inet_release() nor sctp_close(). Instead, it calls sk->sk_prot->destroy(). Let's move SCTP_DBG_OBJCNT_DEC() from sctp_close() to sctp_destroy_sock(). Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Kuniyuki Iwashima Acked-by: Xin Long Link: https://patch.msgid.link/20251023231751.4168390-2-kuniyu@google.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- net/sctp/socket.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/net/sctp/socket.c b/net/sctp/socket.c index 0aaea911b21ef..424af9d0434db 100644 --- a/net/sctp/socket.c +++ b/net/sctp/socket.c @@ -1551,8 +1551,6 @@ static void sctp_close(struct sock *sk, long timeout) spin_unlock_bh(&net->sctp.addr_wq_lock); sock_put(sk); - - SCTP_DBG_OBJCNT_DEC(sock); } /* Handle EPIPE error. */ @@ -5101,9 +5099,12 @@ static void sctp_destroy_sock(struct sock *sk) sp->do_auto_asconf = 0; list_del(&sp->auto_asconf_list); } + sctp_endpoint_free(sp->ep); + sk_sockets_allocated_dec(sk); sock_prot_inuse_add(sock_net(sk), sk->sk_prot, -1); + SCTP_DBG_OBJCNT_DEC(sock); } /* Triggered when there are no references on the socket anymore */ -- 2.51.0