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 C4054207A07; Fri, 6 Dec 2024 15:13:13 +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=1733497993; cv=none; b=Ok6c9Mf1gB9bTPMxgfBfsoK1QDcQ9pegqysRG3hMsCc7KTyBUdH7ZOcCLyG+Gv6drdsuC0bos6m3EUPj2Xn/EtoChZ7ePSIa6ggZG9SlxzN+QsqhUWiJAftRd/CjEV2guRyEjZ2a743K3Q+3kQjb63BiX81mowDp/uxPVRYSfdw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733497993; c=relaxed/simple; bh=ju7u8C68GTgwsdZSQZCYKWqkebwHcccIKLFMtJtxdV0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QHlEdULPYR6xNpHstBK5UyMtpkYHEMFuPN2E5CGCcsUfKs7abZw/8h6cpvoW/exxihoPzvOTtRnwDYjfsxPpC4TrOC82CMwk//Kp99mpXJy+OiEStCWdJ3TIk5SAW2fXJx46m265vbCPFBTUe7nVP4JpT9jV6vwnZVg3/yRKZ2Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=LGwHrREh; 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="LGwHrREh" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4DF26C4CED1; Fri, 6 Dec 2024 15:13:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1733497993; bh=ju7u8C68GTgwsdZSQZCYKWqkebwHcccIKLFMtJtxdV0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LGwHrREhyZnSF4cTofxfreRwYPZG8s7hvaRxwquOm6G7Do7lFO4UKZKT+JFgLfsm5 KSX9STrSsxFppcuMH8aOLCvrCFaQ25/CJ/mjpdAsI5Fln2M/NG+nAyqIH/iS4/emuv sVVpGjMjuEeW28mepqVXiJkD5JFvwjYcUmyRVtV8= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Liu Jian , Kuniyuki Iwashima , Vadim Fedorenko , Eric Dumazet , Martin KaFai Lau , Paolo Abeni , Sasha Levin Subject: [PATCH 6.6 423/676] tcp: Fix use-after-free of nreq in reqsk_timer_handler(). Date: Fri, 6 Dec 2024 15:34:02 +0100 Message-ID: <20241206143709.867723894@linuxfoundation.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241206143653.344873888@linuxfoundation.org> References: <20241206143653.344873888@linuxfoundation.org> User-Agent: quilt/0.67 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 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Kuniyuki Iwashima [ Upstream commit c31e72d021db2714df03df6c42855a1db592716c ] The cited commit replaced inet_csk_reqsk_queue_drop_and_put() with __inet_csk_reqsk_queue_drop() and reqsk_put() in reqsk_timer_handler(). Then, oreq should be passed to reqsk_put() instead of req; otherwise use-after-free of nreq could happen when reqsk is migrated but the retry attempt failed (e.g. due to timeout). Let's pass oreq to reqsk_put(). Fixes: e8c526f2bdf1 ("tcp/dccp: Don't use timer_pending() in reqsk_queue_unlink().") Reported-by: Liu Jian Closes: https://lore.kernel.org/netdev/1284490f-9525-42ee-b7b8-ccadf6606f6d@huawei.com/ Signed-off-by: Kuniyuki Iwashima Reviewed-by: Vadim Fedorenko Reviewed-by: Liu Jian Reviewed-by: Eric Dumazet Reviewed-by: Martin KaFai Lau Link: https://patch.msgid.link/20241123174236.62438-1-kuniyu@amazon.com Signed-off-by: Paolo Abeni Signed-off-by: Sasha Levin --- net/ipv4/inet_connection_sock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c index ca8cc0988b618..bd032ac2376ed 100644 --- a/net/ipv4/inet_connection_sock.c +++ b/net/ipv4/inet_connection_sock.c @@ -1124,7 +1124,7 @@ static void reqsk_timer_handler(struct timer_list *t) drop: __inet_csk_reqsk_queue_drop(sk_listener, oreq, true); - reqsk_put(req); + reqsk_put(oreq); } static bool reqsk_queue_hash_req(struct request_sock *req, -- 2.43.0