From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796388607; b=Pg3iUKAVpNw5cEr1uf8kkMaMHNSraGW3EgbV170c58B96g1UcG/Yi/+On0OCc9nFrA3x fosGjurfa1H00j4LetZOWLun4bZ5FgTPl38PlwB4Iy/e9xz0g8DNjT0OUHF/rHSlDPIMr 5M7AvS++EJjfEjKXRnBI2fqRdUBqUXkBq3HYuaaaZnYgiJ9xJHOTfedktmLM+oZmBK0RH l6IUsN8sN1jNqYLRiSIxo/8ryGex2C1IiHxvQqTPUoRtt/HyhTf3Mtmmu6nOTxC2dFpb9 GgS7BOnfxHzRHqET6AWFtgtpRtYJPqSS9SB+V7kNWf/VzuMK8PiNUxoTo6xJlK5FHUQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796388607; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=R0+GVpceQja0MC4ZFoEj7TReylzgJE2sbUjnF23urS4=; b=ZGeTC4ro3I/XtcLWL+DXnaCZsJF17SKKUXHTTj6ljEOpcmxdgpx445gqeLcbNo7ARNaE cipgFZGy22W8sBoqWQIYBHEx2kRNNdAApwTDOGlIZ2njLxlw4oRJbDdzO27scO3e+CW1h YoO0XGGqB+jBlu1KjYlNfhjxtInVytoIkqfEyxJr0iufG9eqYUiwzfDC9TzQUZ928O7ng 3BInrFAulodZZxhhwFcb8ug4l7OZoJQA87upl7HQoN7qPoPBG7Ckjt2gCfVqMEvrxhc6q 20/3LfP6lJNAiYnTtFzGD2gAWfr2xu9fX4Wrnnm3rQxaRM2bkZkSiWt2ECLIvpZYLxw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=0U617YDH; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 74E59606A32C; Fri, 4 Dec 2026 12:50:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=0U617YDH Received: by smtp.kernel.org (Postfix) with ESMTPSA id E48F41F00897; Fri, 4 Dec 2026 12:50:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796388607; bh=R0+GVpceQja0MC4ZFoEj7TReylzgJE2sbUjnF23urS4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=0U617YDHLvJwGOByLWqavrMXqLE4Dc6Oaz0q9V4CWOO+mI1qKwVL/L0XJCSCNAAGa gwxNSIxFeoVILm+QVVGfEZteg0E88kREqc2eY2ibukOBanW9hei0uEepUGrxH1BLLS /baXWExMRAKHxNyddYBX0j5SxJw1QrX9xqcLdEk4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Daniel Zahka , Kuniyuki Iwashima , "Matthieu Baerts (NGI0)" , Jakub Kicinski , Sasha Levin Subject: [PATCH 6.1 0686/1059] tcp: Set unhashed_state in inet_twsk_hashdance_schedule(). Date: Fri, 4 Dec 2026 19:03:37 +0900 Message-ID: <20261204100701.768499349@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Kuniyuki Iwashima [ Upstream commit 404381b4f1053a271a85679cc76a543b10ae043e ] inet_unhash() sets inet_csk(sk)->unhashed_state only when the socket is hashed because tcp_set_state(sk, TCP_CLOSE) could be called multiple times, e.g. tcp_abort() calls it directly and tcp_done_with_error(). However, inet_twsk_hashdance_schedule() also unhashes a socket when replacing it with twsk, allowing the socket to bypass checks for inet_csk(sk)->unhashed_state. Let's update inet_csk(sk)->unhashed_state there as well. Fixes: 8cc3aef0cb19 ("tcp: Do not allow buggy transitions between ehash and lhash2.") Reported-by: Daniel Zahka Closes: https://lore.kernel.org/netdev/DLHLRA8GVI5B.2Q1IRQG5BVJNZ@gmail.com/ Signed-off-by: Kuniyuki Iwashima Reviewed-by: Daniel Zahka Reviewed-by: Matthieu Baerts (NGI0) Link: https://patch.msgid.link/20260917191554.1600494-1-kuniyu@google.com Signed-off-by: Jakub Kicinski [ sashal: Kept the ehead declaration and the old inet_twsk_hashdance() name, applying the unhashed_state assignment and the icsk const change around that context. ] Signed-off-by: Sasha Levin --- net/ipv4/inet_timewait_sock.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/net/ipv4/inet_timewait_sock.c b/net/ipv4/inet_timewait_sock.c index 6356a8a47b345..3621cdb9e431c 100644 --- a/net/ipv4/inet_timewait_sock.c +++ b/net/ipv4/inet_timewait_sock.c @@ -117,11 +117,13 @@ static void inet_twsk_add_bind2_node(struct inet_timewait_sock *tw, void inet_twsk_hashdance(struct inet_timewait_sock *tw, struct sock *sk, struct inet_hashinfo *hashinfo) { - const struct inet_sock *inet = inet_sk(sk); - const struct inet_connection_sock *icsk = inet_csk(sk); struct inet_ehash_bucket *ehead = inet_ehash_bucket(hashinfo, sk->sk_hash); spinlock_t *lock = inet_ehash_lockp(hashinfo, sk->sk_hash); + struct inet_connection_sock *icsk = inet_csk(sk); struct inet_bind_hashbucket *bhead, *bhead2; + const struct inet_sock *inet = inet_sk(sk); + + icsk->unhashed_state = sk->sk_state; /* Step 1: Put TW into bind hash. Original socket stays there too. Note, that any socket with inet->num != 0 MUST be bound in -- 2.53.0