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=1796384513; b=DLh6Jvel0jQiLlE8L4MrDtWdEm8gnwKjS1Sdpkw1wXOBYDB7WO8xaBQLinNp/NLNEImQ CahNbpmVkafSfmRapE/5ezFOETrXgOKzR4SiQcGuF6WnQNs9fIUvOBQBcD6xmIMyCIxll ch68ds6ntFSzKy5627kQ/LpKPMFQm5lh+0nBbTdptANOBw6iya3u2JbL85kEhIo7m95Xd 2q5GmI1NYWK7JSJFvR4bnCz9ffz9/8H1hBb0kaEDTQHquNXmaR/zfOdbbTpwuxbs6npT3 NxNfta3cW8TWZP7pjlvoWq5C1dr2NP5eXJzOq+nCRJgAimJGmRDgCvFeWb5g/cAQZ2Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796384513; 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=IEEsp4qC9i4tO9PZQzkr9w3QZuX31zTtukLTrevBK70=; b=hz/SQoWYvCvfV/ajk+xm+xJATLgABwt3K1ozY3EhCXT0ye3MxNE2DcuKhvrBlUggpIYp xXfSpYmuhwZ8bAh3hALcCyL7yXWnoMWIKgpvoc7c3gyHfvz3e9mTSLb2BzKSD/GvWOm0+ wvSd1LN6b1o34u/3FgcZ1upi438tECxuZg8O8SuU0qUjf+DC+td6dNOogBw7Y3FvENXRQ vZKc323B+Oj6lX7zJ9Qxsx82xnaNjWpwyphvbxn6Jt1jfAlLzDdwnHvigtsccyhGhCsap /lcbbsr2Ei3+Hs7YLdB8ZXZzsgFHuECFvGdEV5EEtxZBCaEn9TjUR8oetwAq2oESCzQ== 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="JK/8QHfX"; 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 E36B6606A332; Fri, 4 Dec 2026 11:41:52 +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=JK/8QHfX Received: by smtp.kernel.org (Postfix) with ESMTPSA id 609241F000CE; Fri, 4 Dec 2026 11:41:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796384512; bh=IEEsp4qC9i4tO9PZQzkr9w3QZuX31zTtukLTrevBK70=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=JK/8QHfXWFokLgeA5DG99DFU+q041wGS3N2/5x7I2ZWPUQmAuSguWNvsYYtwLu22N Ldejj22vN+QajX7mEAx+ZY87SPw3JrbC3kfjLGc/0xR+fmQwSH5LDq5wcS63G75Mw7 y5kriTg2F62xaSDKdiWboOYBaJ3VkbCBLKjiaGRI= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Sashiko , Eric Dumazet , Hangbin Liu , Jiayuan Chen , Kuniyuki Iwashima , Linkui Xiao , Paolo Abeni , Sasha Levin Subject: [PATCH 6.6 0181/1167] tcp: ipv6: free ireq->ipv6_opt after an RCU grace period Date: Fri, 4 Dec 2026 18:53:28 +0900 Message-ID: <20261204100706.782403456@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100702.047403948@linuxfoundation.org> References: <20261204100702.047403948@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.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Eric Dumazet [ Upstream commit fafbc4051123d5459ea6950899cec08ed946e278 ] ireq->ipv6_opt is only set by calipso_req_setattr(), when a CALIPSO NetLabel mapping is configured. Request socket migration (net.ipv4.tcp_migrate_req=1, or a BPF_SK_REUSEPORT_SELECT_OR_MIGRATE program) clones the request socket with inet_reqsk_clone(), so that the old request socket and its clone share the same ipv6_opt, then reqsk_migrate_reset() clears the pointer in the old one. Another cpu holding a reference on the old request socket can still be using these options, sending a SYNACK from tcp_v6_send_synack() or creating a child in tcp_v6_syn_recv_sock(), when the clone is freed. tcp_v6_reqsk_destructor() frees ipv6_opt with a plain kfree(), leading to a use-after-free. Both readers already run under RCU, like their IPv4 counterparts. Use kfree_rcu() in tcp_v6_reqsk_destructor(), as commit e3f33b0a1d89 ("ipv4: free inet_opt and ireq_opt after an RCU grace period") did for ireq_opt. Fixes: c905dee62232 ("tcp: Migrate TCP_NEW_SYN_RECV requests at retransmitting SYN+ACKs.") Reported-by: Sashiko Closes: https://lore.kernel.org/netdev/179369559062.488856.15441115725436277776@kernel.org/ Signed-off-by: Eric Dumazet Reviewed-by: Hangbin Liu Reviewed-by: Jiayuan Chen Reviewed-by: Kuniyuki Iwashima Tested-by: Linkui Xiao Link: https://patch.msgid.link/20261103090011.4128420-1-edumazet@kernel.org Signed-off-by: Paolo Abeni Signed-off-by: Sasha Levin --- net/ipv6/tcp_ipv6.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index 7adeb623cfb2b..6c5d0d8c65f9e 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c @@ -570,7 +570,7 @@ static int tcp_v6_send_synack(const struct sock *sk, struct dst_entry *dst, static void tcp_v6_reqsk_destructor(struct request_sock *req) { - kfree(inet_rsk(req)->ipv6_opt); + kfree_rcu(inet_rsk(req)->ipv6_opt, rcu); consume_skb(inet_rsk(req)->pktopts); } -- 2.53.0