Article View: linux.kernel.netdev
Article #9493Re: [PATCH net] tcp: ipv6: keep request pktopts alive until request destruction
From: Eric Dumazet
Date: Mon, 02 Nov 2026 07:28
Date: Mon, 02 Nov 2026 07:28
111 lines
13705 bytes
13705 bytes
Le lun. 2 nov. 2026 ร 08:03, Kuniyuki Iwashima <kuniyu@google.com> a รฉcrit :
>
> On Mon, 02 Nov 2026 06:12:18 +0000, Yingjie Wang wrote:
> > When IPv6 flow label reflection is enabled, tcp_v6_send_synack() reads
> > ireq->pktopts to copy the flow label from the initial SYN.
> >
> > Request sockets can be processed without the listener lock. A
> > retransmitted SYN can therefore run tcp_v6_send_synack() while a
> > concurrent final ACK creates the child in tcp_v6_syn_recv_sock(). The
> > latter clones ireq->pktopts for the child and immediately consumes the
> > request's reference. This can free the skb while the retransmit path is
> > still reading its IPv6 header, causing a use-after-free.
> >
> > Request migration has the same ownership problem. inet_reqsk_clone()
> > copies pktopts without taking an skb reference, and reqsk_migrate_reset()
> > then clears the old request's pointer. A CPU holding the old request can
> > still be sending a SYNACK when the cloned request releases the only skb
> > reference.
> >
> > Do not consume pktopts while creating the child. Give each cloned request
> > its own skb reference and let every request release its reference from
> > tcp_v6_reqsk_destructor().
> >
> > I found this while testing IPv6 TCP request-socket lifetime handling. The
> > reproducer required no source changes, artificial delay, or fault
> > injection beyond enabling KASAN. It triggered the use-after-free before
> > this change. With this change, a 2000-round run completed without a KASAN
> > report. A separate 10-round test recorded four successful request
> > migrations and no KASAN report. Networking selftests were not run because
> > none directly exercises this race.
> >
> > Fixes: e994b2f0fb92 ("tcp: do not lock listener to process SYN packets")
> > Fixes: 079096f103fa ("tcp/dccp: install syn_recv requests into ehash table")
> > Fixes: c905dee62232 ("tcp: Migrate TCP_NEW_SYN_RECV requests at retransmitting SYN+ACKs.")
> > Cc: stable@vger.kernel.org
> > Signed-off-by: Yingjie Wang <x-professor@outlook.com>
> > ---
> > net/ipv4/inet_connection_sock.c | 6 +++++-
> > net/ipv6/tcp_ipv6.c | 7 ++++---
> > 2 files changed, 9 insertions(+), 4 deletions(-)
> >
> > diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
> > index 93b306d91b6d..66f8ce25aa38 100644
> > --- a/net/ipv4/inet_connection_sock.c
> > +++ b/net/ipv4/inet_connection_sock.c
> > @@ -936,6 +936,11 @@ static struct request_sock *inet_reqsk_clone(struct request_sock *req,
> > req->rsk_ops->obj_size - offsetof(struct sock, sk_dontcopy_end),
> > /* alloc is larger than struct, see above */);
> >
> > +#if IS_ENABLED(CONFIG_IPV6)
> > + if (inet_rsk(nreq)->pktopts)
> > + skb_get(inet_rsk(nreq)->pktopts);
> > +#endif
> > +
> > sk_node_init(&nreq_sk->sk_node);
> > nreq_sk->sk_tx_queue_mapping = req_sk->sk_tx_queue_mapping;
> > #ifdef CONFIG_SOCK_RX_QUEUE_MAPPING
> > @@ -982,7 +987,6 @@ static void reqsk_migrate_reset(struct request_sock *req)
> > req->saved_syn = NULL;
> > #if IS_ENABLED(CONFIG_IPV6)
> > inet_rsk(req)->ipv6_opt = NULL;
> > - inet_rsk(req)->pktopts = NULL;
> > #else
> > inet_rsk(req)->ireq_opt = NULL;
> > #endif
> > diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
> > index e006a30360ea..0b51cb4ad960 100644
> > --- a/net/ipv6/tcp_ipv6.c
> > +++ b/net/ipv6/tcp_ipv6.c
> > @@ -1522,11 +1522,12 @@ static struct sock *tcp_v6_syn_recv_sock(const struct sock *sk, struct sk_buff *
> > if (*own_req) {
> > tcp_move_syn(newtp, req);
> >
> > - /* Clone pktoptions received with SYN, if we own the req */
> > + /* Clone pktoptions received with SYN. Keep the request's
> > + * reference until the request is destroyed, as a concurrent
> > + * SYN retransmit may still read it.
> > + */
> > if (ireq->pktopts) {
> > newnp->pktoptions = skb_clone_and_charge_r(ireq->pktopts, newsk);
> > - consume_skb(ireq->pktopts);
> > - ireq->pktopts = NULL;
>
> This is reported from another person in security@ mailing list
> yesterday and Eric has a better fix.
>
> pw-bot: rejected
Indeed, I will add another 'Reported-by: Yingjie Wang
<x-professor@outlook.com>' tag.
Thanks.
Technical Details
Message-ID:
<CAL4WiiqMbiJS07YwNCNKsY6UMLsU+XDoemJMnHvrZz_+ayiOTw@mail.gmail.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-354492-linux-kernel-netdev=dewy.ruReferences:
<82c31e4d5043f3dbd11b44177cfba779d335aae3.1793599929.git.x-professor@outlook.com> <aug0tMr2QXRxTWuE@google.com>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-354492-linux-kernel-netdev=dewy.ru
From: edumazet@kernel.org (Eric Dumazet)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net] tcp: ipv6: keep request pktopts alive until request destruction
Date: Mon, 2 Nov 2026 08:28:32 +0100
Organization: Usenet Network
Message-ID: <CAL4WiiqMbiJS07YwNCNKsY6UMLsU+XDoemJMnHvrZz_+ayiOTw@mail.gmail.com>
References: <82c31e4d5043f3dbd11b44177cfba779d335aae3.1793599929.git.x-professor@outlook.com>
<aug0tMr2QXRxTWuE@google.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Injection-Info: usenet.network;
logging-data="2871206"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:aK1+L/EmZ5d3M50AHVEjkynwe9s= sha256:9sPpr0BxHEoVJ5G54RmDU2DQe8uNFy1AAExKsMHr6vw=
sha1:Kw0F3wAPlSV9sqwlPWE40REZ2Z4= sha256:NZpAp6j99HZpT528p9a0wubevPVZQegKQCmeavD/Tog=
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 6B096125CC7; Mon, 2 Nov 2026 10:31:17 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.401
X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31
tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1,
DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
header.d=kernel.org
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 dOfy99WLhzCC;
Mon, 2 Nov 2026 10:31:09 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-354492-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
by mail.dewy.ru (Postfix) with ESMTPS id DF429125CC6; Mon, 2 Nov 2026 10:30:59 +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 5446C3617E; Mon, 2 Nov 2026 07:28:47 +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=1793604527;
b=aoIFdLC7ghe831pjnPZ8J3WivrCM1LqScuxcoLQOxh7Wl0FrgFatuKl83Wj/Rb6JRNhl
noYfM9tfacuVFG9OFOoH8pjv0nyjLP6NnMzYcQL5Mu7nzBFFH8LDsWWa7LQt9ofYacl8y
2xPQD6AMkEUC+GRmxOq18fOrXkDYv8X5tzeQOtqjc1CN9+E9mJGJeiBk0C1Nv/d/mkeYi
Ttau7/fAZbXt1JfgYJTSlJ3EwqJhtAZG0ORU7kzQG738Mwrw6RXWNR5Iv2pUziOlgrB7Y
OcGgnEf808GEcRP/MSxUft+OOZHvq3C3GUAzDTy0YaG5Fyut0ti+txOd+uSUL7Z+yKg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1793604527;
h=X-Original-To:Received:Received:DKIM-Signature:Received:
X-Forwarded-Encrypted:X-Gm-Message-State:X-Received:X-Mailing-List:
List-Id:List-Post:List-Help:List-Subscribe:List-Unsubscribe:
List-Owner:Precedence:MIME-Version:References:In-Reply-To:From:Date:
X-Gmail-Original-Message-ID:X-Gm-Features:Message-ID:Subject:To:Cc:
Content-Type:Content-Transfer-Encoding;
bh=If3fE+lQ75xX1Vq7CvfUefIfI5ALcUIEaypG/wi/3sA=;
b=EidgpxiQ8B7k8+Hnywqx1cYOrqUyDNSsfGY1YEl8jRVJPPPa8knvU2LAQIV9HJ5/GvSh
xS+K+0JDwIL6T2Al+GlXIKq5cyqB664SAgoiVfsmA8J7/L7qRreeKthY8wjRc0ap4ptXz
sOQNnttJ8vMWcLK0TDTEMkLL3nZiUy/hMRALbsD7ap1GFmTSZXiSt0o7AbqBySOCcw5y2
kuJbpmNthvUyuXqg+340C9K0mubzqNzV2cYShIlVfuSEpZN/MYg0+9Qi+rLsJTWc7bQyi
IkrmOoXEHARRYDNjUHA4yC1mH2+N5XlhPU4ldPmzIwGlL/UVTTXhDZFHpfwJywnYusw==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org;
dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=ANPfABDF;
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 25CB3606A338;
Mon, 2 Nov 2026 07:28:47 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=ANPfABDF
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1793604526;
b=sC59ovlRq493CJ8URW0Tlkf2inge/pwr69QJUnzf7hDUxSqFWqRm6yVthTZ/APixBy6P
ecSuBAIHiZ3K/QSZ1pq+6/jmvIcrepm7UG8zs1GQAHwxADzIalnUKBXg4t5nvIvtNwEYN
adIlAseoj+tVCP06n7FFdFJK8/GXCpQ6+3p+1q51sojKS3JHr8FXOzpOVmWYDg0+7+R5l
K2PM/cvt51DkEaqiAw8FlZ/yFSXiMoGN3NsrldzNZRQD4ufMijc3HCcRb1i3odTNjU1Ng
1xH/6wVBOhV6mO27Y/xbeISC4/1pvHgSGd8jd8S/txVT6fF9L1GC0/Po0fJMlCnExPA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1793604526;
h=Received:DKIM-Signature:Received:X-Forwarded-Encrypted:
X-Gm-Message-State:X-Received:MIME-Version:References:In-Reply-To:
From:Date:X-Gmail-Original-Message-ID:X-Gm-Features:Message-ID:
Subject:To:Cc:Content-Type:Content-Transfer-Encoding;
bh=If3fE+lQ75xX1Vq7CvfUefIfI5ALcUIEaypG/wi/3sA=;
b=ik3gSSsGZcu8LKXQKziqZCPFeDuM1QhKcNC9A9eSLQ/3ZKZ0MpLmLpTIB3EJUw6Ii7cX
rCPlmAaLxvId8E6Hp8bpy0M2n/j7AeidMD/R0mKmd8R4SVWULR0I1s6p8cN5AUxUd93W4
IP8fdiRM1LLk6C00uEfnv9fLdK9FIq0ZRy9D4LblVHpf+jVXT611y4IU84/DkQJVjvVwj
KxQh3fRcoeTsKm3qae9SVkiuHLdnpAag+gjC6kRQ7GBAonzXN3l0AGEJ5qh2Oe2Di9BKi
e6ElYnFI4M1aJ3c/OVrVB1UfONXpwJikeLhcRrYneLrSC5/AkHsRbpnKjkCX7AbJqhw==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org;
dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=ANPfABDF;
arc=none smtp.remote-ip=100.103.45.18
X-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 7E170606A32C
for <netdev@vger.kernel.org>; Mon, 2 Nov 2026 07:28:45 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 295C71F00A21
for <netdev@vger.kernel.org>; Mon, 2 Nov 2026 07:28:45 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
s=k20260515; t=1793604525;
bh=If3fE+lQ75xX1Vq7CvfUefIfI5ALcUIEaypG/wi/3sA=;
h=References:In-Reply-To:From:Date:Subject:To:Cc;
b=ANPfABDFS9h7v/zbtspJG+jpYTY9mf6Dam/W28kcKLm2ElLtClCumMoi7Wt2af5+/
dFHPLET3iKdbIwJzB7VPdp7ycb0T0Ajh7Gmm8+KUhbLlfjEzgNqi5eWUYtFCrAPdML
RQja44X2DHa0nNp70DsTNsvGWogE5vZKhZ2yOFWg9BI+JWay6Vi9wWh/8qado2DYaZ
AouH8S9bo95qcgiW56f8ZpuYHJTmpP3Xwj09585H2XkOi39XFH1/QxaBbJzGE540uR
hwsJx289rCqh7nRomwoAXFNMIRZglGFTSBQHqU/+oFjnvDV7mnRIJUKKzFlkR9Whpk
JNMeU/PVt2dLQ==
X-Received: by mail-oo1-f41.google.com with SMTP id 006d021491bc7-705cb6ceebaso1752392eaf.3
for <netdev@vger.kernel.org>; Sun, 01 Nov 2026 23:28:45 -0800 (PST)
X-Forwarded-Encrypted: i=1; AKwUvBzplQd2JNgAP9gc/DeQw/yZ0bt5wazrXbVAaH3GUVAQ+CJfwxZE0Jw8AThua7RYmalokh9Au/0=@vger.kernel.org
X-Gm-Message-State: AFq9FYICKem/Op3nGUE5P7GBzSiVjauSCuegzIEkeMdpXk2OIAuQYuKT
+WI+xOj/E2CAeG/Y8e7HBuOASCOrvduE0n4GWNoUyh3AZV5nrp03z7ii6F5naSNxVpBRyARvybM
ko+EQIXaunh7/0io+XIZHDqT4M4hRpjc=
X-Received: by 2002:a05:6820:5709:10b0:70a:df8e:8f64 with SMTP id
006d021491bc7-714f23f7d98mr3415125eaf.22.1793604524395; Sun, 01 Nov 2026
23:28:44 -0800 (PST)
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: <aug0tMr2QXRxTWuE@google.com>
X-Gmail-Original-Message-ID: <CAL4WiiqMbiJS07YwNCNKsY6UMLsU+XDoemJMnHvrZz_+ayiOTw@mail.gmail.com>
X-Gm-Features: AclHuK-qkDj2lomKdPUBIYW2cw33-lPnwEAvc_Rj2h8jY0csV8s3qylZZM4N8nA
X-Cc: Yingjie Wang <x-professor@outlook.com>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>, "ncardwell@google.com" <ncardwell@google.com>,
"davem@davemloft.net" <davem@davemloft.net>, "kuba@kernel.org" <kuba@kernel.org>,
"pabeni@redhat.com" <pabeni@redhat.com>, "horms@kernel.org" <horms@kernel.org>,
"daniel@iogearbox.net" <daniel@iogearbox.net>, "martin.lau@linux.dev" <martin.lau@linux.dev>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"stable@vger.kernel.org" <stable@vger.kernel.org>