🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #10727

Re: [PATCH net] tcp: ipv6: free ireq->ipv6_opt after an RCU grace period

#10727
From: Hangbin Liu
Date: Wed, 04 Nov 2026 01:11
52 lines
10374 bytes
On Tue, Nov 03, 2026 at 10:00:11AM +0100, Eric Dumazet wrote:
> 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 <sashiko-bot@kernel.org>
> Closes: https://lore.kernel.org/netdev/179369559062.488856.15441115725436277776@kernel.org/
> Signed-off-by: Eric Dumazet <edumazet@kernel.org>
> ---
> Found by Sashiko while reviewing another TCP fix :/
> 
>  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 d406cd3c8ceabfdbb66f3e1b4f9e9a74754e8d0b..b1dec5d86d633db67a754c70ee1c63290a9acb5a 100644
> --- a/net/ipv6/tcp_ipv6.c
> +++ b/net/ipv6/tcp_ipv6.c
> @@ -607,7 +607,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
> 

Cc Leonardo for the fixup.

Reviewed-by: Hangbin Liu <liuhangbin@kylinos.cn>
Technical Details
Message-ID: <auqGNNsCDh-s--lq@fedora>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-356106-linux-kernel-netdev=dewy.ru
References: <20261103090011.4128420-1-edumazet@kernel.org>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-356106-linux-kernel-netdev=dewy.ru
From: hangbin.liu@linux.dev (Hangbin Liu)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net] tcp: ipv6: free ireq->ipv6_opt after an RCU grace
 period
Date: Wed, 4 Nov 2026 09:11:16 +0800
Organization: Usenet Network
Message-ID: <auqGNNsCDh-s--lq@fedora>
References: <20261103090011.4128420-1-edumazet@kernel.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: usenet.network;
	logging-data="3298867"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:dWTpwlBI+aGUWLs82DE7wDUkr8U= sha256:G5ZhwLT7illgiTAI24VX5YENF8G3SA1s1biYBI6m/L4=
	sha1:VZ2/1/7vMYUjtsmopqSNJjyl+/g= sha256:yilo5n0jYseAo+tcHkVpe25+pGL+6xsvz7CHp8+PsNc=
Content-Disposition: inline
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 05AA0112A99; Wed,  4 Nov 2026 04:13:40 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.05
X-Spam-Status: No, score=-3.05 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (1024-bit key)
	header.d=linux.dev
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id kiI_LCXNseiP;
	Wed,  4 Nov 2026 04:13:30 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-356106-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=linux.dev
X-Received: from sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4])
	by mail.dewy.ru (Postfix) with ESMTPS id 22C39112A61; Wed,  4 Nov 2026 04:13:19 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sin.lore.kernel.org (Postfix) with ESMTP id 93FD126A2B; Wed,  4 Nov 2026 01:12:10 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1793754689;
	b=ivK2GbQqLOZ749b7N2DQpmEtXFbBIWdc/h+mcVUyqPZa2lCV4DHIjLoSB6Kj6TakPa97
	 YM1vwCX3H5YZ9u5LV/BA3owpNv3zLABqFGFO+bNVA0wLnov1nEUeQgWYJnqr5cSJcuzt9
	 19QAjfXIRSu+99q7t/A1hrRejfA73mxVCmuLrbTVzZOn9G/dc+xuQkbCirresHJyOU7Sw
	 skaoOVL3TznDPH0F3a7g5tVKMhw4wHDZmCNorR6f4UII038ql7BB4dXlUjMTRQB1NrNb9
	 CsBs7ZavlEx5Gwzb955GVBcWy6IDmdX7l+dW2EAqXbIwFjy9aWxd1dm8Avv/D7pwm1w==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793754689;
	h=X-Original-To:Received:DMARC-Filter:X-Envelope-To:DKIM-Signature:
	 X-Envelope-To:Received:X-Mizu-Trace-ID:X-Migadu-Flow:Date:From:To:Cc:
	 Subject:Message-ID:References:X-Mailing-List:List-Id:List-Post:
	 List-Help:List-Subscribe:List-Unsubscribe:List-Owner:Precedence:
	 MIME-Version:Content-Type:Content-Disposition:In-Reply-To;
	bh=0XVsgUYYITlAtYJaSIrHBYVMeYH8vlOK4hQO3FcxViI=;
	b=0Y8YYQEcSLUCvNqum8V0c6LAqmyOgj95vzvrFPN5SRnrUyORhNzJ2ZpNLIZuKTn/k3Ko
	 bkfvErlJM4FUgr9UvE6dsQEBy7mMmZ1ltgMDMv5swwxes6ge/+K5V9LbvEcObgnZY3RvV
	 4UrKk2LEarusGjizOAyxvhRS6L9vRGtGvv/ehKk9+AmOjVDVk1iXcAnfCpHdH8HwgPjN1
	 GOqZwybOtILzDvxWOmMgvuD/nOEskBS5YkwVo8ss8NxxgF50Zd5Fuwme9iQL7pWBrOyhe
	 UAoLAiCzyErhkGPoX6BtS30DS4ogpSdaMplgvSCFOgJ5uXx3IXM8tTqo3PjXEAHfywg==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=u65yL+6G;
	dmarc=pass header.from=linux.dev;
	spf=pass smtp.mailfrom=linux.dev;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id E0954606EEBA;
	Wed,  4 Nov 2026 01:11:28 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=u65yL+6G
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=91.218.175.99
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1793754688;
	b=WK5JmkKAqZMtlMaiwbwaNXWOM4QGU154ryHEoQG9WLwdTBtzaF5MQfp7WQHDgzI3UtCs
	 zBZu/aAbh3618JYyz4+HAoP/aBcSkBgulBz4UQ4mebShsBmZh370I9Z5drbfI08KfoSXb
	 OCTyKX+ZqXgfu5wTiY1LpqrkKYbJcSDCCPpozN5ZA2sqqCfWkFuaQcRCKRof0zcCSa/Er
	 qlIwGkMWSmEj7HfA7T6+gedCUqH8mi4vIRhUGM2APyaod/W2HrMC6AjP7em9GFrzDGDsT
	 Zik+8wJAIi+e5HWP1dQ6ot4TMNE1daaUDXr5rAt9ZSqlNNy8wk+KkHCUW+joZ9NrB/A==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793754688;
	h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received:
	 X-Mizu-Trace-ID:X-Migadu-Flow:Date:From:To:Cc:Subject:Message-ID:
	 References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To;
	bh=0XVsgUYYITlAtYJaSIrHBYVMeYH8vlOK4hQO3FcxViI=;
	b=0evicOgIzbAtyHL035bGVPLxSMQmM8kyxZel7DS03ULiS8vJdfmv+hq8s9PPp3C8n7Vp
	 YP9umSpP0UIkmcjPCvIq4XF0DF8q5S41zulhvU2g3yCZRrL1eK+b+4VEgQ2d+guHgYIdt
	 km/dVIDje9NgT2JliNB+wPUPkcc2U/hP8ZGxV31m5aQX7ms5T4zgCvOHFiuEids5Ae7HA
	 3ZEqUTwyILXxp/M4Uc0UA1yRlobZCidvWvoZc1JdI38wMtzplF3sly62A16qflQKZEkl5
	 eJxGyRRRLHwUfqS04+OkFKaa4hdnJ3llMghKloNMCFVXPCaz02d3efWGHidwsN/M4CQ==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=linux.dev;
	spf=pass smtp.mailfrom=linux.dev;
	dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=u65yL+6G;
	arc=none smtp.remote-ip=91.218.175.99
X-Received: from mta0.migadu.com (out-99.mta0.migadu.com [91.218.175.99])
	(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id DB250606EE87
	for <netdev@vger.kernel.org>; Wed,  4 Nov 2026 01:11:26 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org DB250606EE87
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev
X-Envelope-To: netdev@vger.kernel.org
X-DKIM-Signature: a=rsa-sha256; bh=BCkOieLQhI6i5yJANtPfr6lFATiHdKgIYRQJAU8uJZA=;
 c=simple/simple; d=linux.dev;
 h=from:to:subject:date:message-id:mime-version:content-type; s=key1;
 t=1793754684; v=1; x=1794359484;
 b=u65yL+6GlXtKpuPTPKrrD5ZvABrSN9p0vnTGckpysXWc7VU553qw9APkkHQvT5mYqviwnTwP
 nRbZmkVdPSX9MtZn21JiQMkxphcFU9nz8TpYBknHKkvsLjcpb579fl4qAJUmjrT4jM2+83eOUYl
 vydNLxAkQtcF2jY5B/asMTOM=
X-Envelope-To: netdev@vger.kernel.org
X-Received: by mta11.migadu.com with ESMTPS id 10e2ba06084617f3;
	Wed, 04 Nov 2026 01:11:24 +0000
X-Mizu-Trace-ID: 10e2ba06084617f3
X-Migadu-Flow: FLOW_OUT
X-Cc: "David S . Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Neal Cardwell <ncardwell@google.com>,
	Kuniyuki Iwashima <kuniyu@google.com>,
	Simon Horman <horms@kernel.org>, netdev@vger.kernel.org,
	Sashiko <sashiko-bot@kernel.org>,
	Leonardo Souza Silva <Capleonardo12@outlook.com>
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list
X-In-Reply-To: <20261103090011.4128420-1-edumazet@kernel.org>