🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #10775

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

#10775
From: Jiayuan Chen
Date: Wed, 04 Nov 2026 03:39
51 lines
10225 bytes
On 11/3/26 5:00 PM, 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>


Reviewed-by: Jiayuan Chen <jiayuan.chen@linux.dev>


> ---
> 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);
>  }
>  
Technical Details
Message-ID: <6087bc31-42d7-4881-bbcd-b4fcd2497047@linux.dev>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-356169-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-356169-linux-kernel-netdev=dewy.ru
From: jiayuan.chen@linux.dev (Jiayuan Chen)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net] tcp: ipv6: free ireq->ipv6_opt after an RCU grace
 period
Date: Wed, 4 Nov 2026 11:39:58 +0800
Organization: Usenet Network
Message-ID: <6087bc31-42d7-4881-bbcd-b4fcd2497047@linux.dev>
References: <20261103090011.4128420-1-edumazet@kernel.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Injection-Info: usenet.network;
	logging-data="3318152"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:rwRh2VzOhXhi7GfrHKM/XTClneg= sha256:M3iGmeaYlCWYggQzPy2Wv/pHIeKjUg6kG/g+wWOyKWQ=
	sha1:k9wnuM3swoPiFyXVbYa4q++DM3g= sha256:Cyyc2aq6QjT0AHzdYGAkhEl/WYgK6Ohou1iYsdnQv2g=
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 D1C31112ACE; Wed,  4 Nov 2026 06:41:31 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -2.05
X-Spam-Status: No, score=-2.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,
	HK_RANDOM_FROM=1, 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 N0JfEpI08cbY;
	Wed,  4 Nov 2026 06:41:28 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-356169-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 sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 02CD4112ACA; Wed,  4 Nov 2026 06:41:18 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id 256D027A39; Wed,  4 Nov 2026 03:40:14 +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=1793763614;
	b=bjWWvJPqJXnPTiTiriN5zuRaGUba9vJvO1CKvReafueVKhK5egvmdWt7FnQpNULLso6X
	 X0Aw/XEgTzWvvrFxm3Ri2lYG3sYaB3WA1aUJPc5UpA2Ny82H4leCrruX+BAHCptzRB7rf
	 EDNrpCskV2thF3OzBMHHa5RbPM7q2AW3qgIEjoMKskoHrEAT9y0sk3mzls+gabWSAcqpM
	 F8+eGb4OuZdyI9/R/PvNRebwsiQP6BPYEftyLNideVNrxDZDllJxiVvpSGBVeIr84lP+n
	 DPydw2bPmhiI3mm16HtwuLAFPXhePI5Iydt6uwc6Ze7n6mjGbJkuD34Tf5KGnw7RtZg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793763614;
	h=X-Original-To:Received:DMARC-Filter:X-Envelope-To:DKIM-Signature:
	 X-Envelope-To:Received:X-Mizu-Trace-ID:X-Migadu-Flow:Message-ID:Date:
	 X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
	 List-Unsubscribe:List-Owner:Precedence:MIME-Version:User-Agent:
	 Subject:To:Cc:References:From:In-Reply-To:Content-Type:
	 Content-Transfer-Encoding;
	bh=fojwHZCtzaJopBfl5aK3uO3xYsshCiuhr2uf/3RjkX8=;
	b=dYm8iyS9x6RT/mC7nv5hStzFhLys9KA1/kjdgJ3TyiQxDmFT8DoLK1AvIYbuc6VbgNSb
	 xXhczCRy87Caf3k9SHtiNCL4gFY2jT5iJPXfbG9bUCXCoTfQxiHBvyDThWt72ctg6sG1g
	 QG9/Rk8xQcWJYkrtdduylSqEgDGWLws/CCfB09sRelDkps+RE49IACoicwZtf4BmcH547
	 FNNsJmhATiWPP7D5luG29JmGc0cDEyBrg2vjoC1egro6DZD2u9hvzDZFteX7FmXtG2/aX
	 xcamxS2DMlxncuDH8mV83Dq86dOrECa+FUQNoDZ4W0gIGbNKr3IkKXmQS5FERpxGgDg==
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=if6ffYGr;
	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 F11D5606A32F;
	Wed,  4 Nov 2026 03:40:13 +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=if6ffYGr
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.215.58.210
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1793763613;
	b=NS2zbk+oylQJ/FU3LiYI5ZpmJOwxth6UMeuWZPJYcS06tcs9sZzLPxOoPOCCFEdrUrx4
	 BlNjF3SQXLVGKE/N2jkn7hCrxqS3cSTDksMWJISeMQtE8W7IMpNkRsBrFPTDx4OnAzQHU
	 6zsIYjRE1eewlJkyebwHyQXJmapzpoHeshv0CmqDBRc6+Jp+d0QpMFlsi5cYc4wLQCjw1
	 O30S0bbirHPhJvm7GkYmXxHBWcyZoyGw5SUHpi+oP4BtAnRB3Y4f9dthNZMLUUbsWcjid
	 GJZfScLJtLdn0jbiTKDjhuaH08N5Zi0RZJHkYhmoQQJIVaberlq4QptP7U5oYxlKLbw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793763613;
	h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received:
	 X-Mizu-Trace-ID:X-Migadu-Flow:Message-ID:Date:MIME-Version:User-Agent:
	 Subject:To:Cc:References:From:In-Reply-To:Content-Type:
	 Content-Transfer-Encoding;
	bh=fojwHZCtzaJopBfl5aK3uO3xYsshCiuhr2uf/3RjkX8=;
	b=tCNmIK3xFRtzoC5qI3CIu1TcBbDFpTflyyKvhajAX4pYX2a5L3iQFOYpc0X6HqvH1nJj
	 cXjR/nphcrbi9AK/T7ZjO9UdGpXMUE7vJAZv1ft94HU6i8JNVY+tFaHrktr/bcqYYnFXv
	 r8q8Dhkd8qdSlxp5/0mqnOjEJrUdCte3Txe9PVcI2cWBpcxj2+7b6WuF3QhTRP3j2dttO
	 SS2tBtjwiOv3/s+JtyUUWuZqdbuxf5D4JdNAi7zcMpL4Au9/Jxvyt4fhkYPMWrDqjGchT
	 54kYQLTe4144M4Eayp0+wZJPqO3sSTGaxK67TjaVvli43Bt3ybyOTFnZEUYI28pTpkw==
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=if6ffYGr;
	arc=none smtp.remote-ip=95.215.58.210
X-Received: from mta1.migadu.com (out-210.mta1.migadu.com [95.215.58.210])
	(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 31489606A326
	for <netdev@vger.kernel.org>; Wed,  4 Nov 2026 03:40:11 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 31489606A326
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=Oa9E8MFe8RaHihHbshmtOsQO/uONzrNu9w1E2MrkL9I=;
 c=simple/simple; d=linux.dev;
 h=from:to:subject:date:message-id:mime-version:content-type; s=key1;
 t=1793763609; v=1; x=1794368409;
 b=if6ffYGrfXjVCtj4sJCzfLzWgJEmqMeARxDu5TW1Bt/rI1memd839tbrAn/JOfaL8ecg0TEl
 WpaJ1HTlnueuMaA5HLfL6CFuVHN8ozRq3CK/UtFsNWfuc9hl5Oeac76oshRG2DK9DS5tGXFUdF2
 43Y3BAW3oh946Ogadqmp5y+Q=
X-Envelope-To: netdev@vger.kernel.org
X-Received: by smtp.migadu.com with ESMTPS id 83ee575f8c893e61;
	Wed, 04 Nov 2026 03:40:07 +0000
X-Mizu-Trace-ID: 83ee575f8c893e61
X-Migadu-Flow: FLOW_OUT
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-User-Agent: Mozilla Thunderbird
X-Cc: Kuniyuki Iwashima <kuniyu@google.com>, Simon Horman <horms@kernel.org>,
 netdev@vger.kernel.org, Sashiko <sashiko-bot@kernel.org>
X-In-Reply-To: <20261103090011.4128420-1-edumazet@kernel.org>