Article View: linux.kernel.netdev
Article #20910Re: [PATCH net] net: keep skbs with a prefetched socket out of gro_cells gro
From: Eric Dumazet
Date: Mon, 23 Nov 2026 10:49
Date: Mon, 23 Nov 2026 10:49
49 lines
10880 bytes
10880 bytes
Le sam. 21 nov. 2026 ร 17:04, Nikolay Aleksandrov
<razor@blackwall.org> a รฉcrit :
>
> bpf_sk_assign at tc ingress holds a reference on a socket that is not
> rcu freed, such as an established tcp socket, until the receive path
> steals it. ip_rcv_core keeps a prefetched socket so when the assigned
> packet is an ipip, gre or esp packet the socket stays attached after
> decap and their rx paths pass the skb to gro_cells_receive. GRO merges
> skbs with the same skb->sk into one flow and clears skb->sk and
> skb->destructor of each merged skb without calling the destructor so
> every merged skb leaks a socket ref.
>
> Send skbs with a prefetched socket to netif_rx instead as
> gro_cells_receive already does for cloned skbs, where each skb is
> consumed on its own and no reference is lost.
>
> skb_sk_is_prefetched tests skb->destructor which shares a cache line
> with skb->cloned that is read just before so the common case adds a single
> cheap test.
>
> Reproduced with a tcx ingress program on a veth in a receiver netns with
> an ipip tunnel which assigns an established tcp socket to ipip packets.
> The sender sends 32 tcp segments of one flow inside ipip through a netem
> slot qdisc so they are decapsulated in one batch and merged by gro.
> Then the socket is closed and the receiver netns is deleted. The leaked
> socket holds a ref on the netns so it is never torn down and its devices
> are never unregistered:
>
> Before:
> bpf_sk_assign() calls 32, sk_refcnt 32 after the burst
> receiver netns deleted, 30s later its veth peer still exists
>
> After:
> bpf_sk_assign() calls 32, sk_refcnt 1 after the burst
> receiver netns deleted, its veth peer is gone
>
> The problem was found during reviews of patches that add bpf_sk_assign
> egress support.
>
> Fixes: cf7fbe660f2d ("bpf: Add socket assign support")
> Signed-off-by: Nikolay Aleksandrov <razor@blackwall.org>
Right, GRO callers are supposed to only feed skbs with no socket, or
sock_wfree() ones (see skb_prepare_for_gro() used by veth), and
gro_cells never enforced this.
Reviewed-by: Eric Dumazet <edumazet@kernel.org>
Technical Details
Message-ID:
<CAL4WiireDJ9=d1QQS+kSJtBJDmzMbgM+tb7zNk1WunqCLKNMOQ@mail.gmail.com>Path:
mbox-mo1.pugleaf.net!news-can.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-369265-linux-kernel-netdev=dewy.ruReferences:
<20261121160204.4024204-1-razor@blackwall.org>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-can.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-369265-linux-kernel-netdev=dewy.ru
From: edumazet@kernel.org (Eric Dumazet)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net] net: keep skbs with a prefetched socket out of
gro_cells gro
Date: Mon, 23 Nov 2026 11:49:29 +0100
Organization: Usenet Network
Message-ID: <CAL4WiireDJ9=d1QQS+kSJtBJDmzMbgM+tb7zNk1WunqCLKNMOQ@mail.gmail.com>
References: <20261121160204.4024204-1-razor@blackwall.org>
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Injection-Info: usenet.network;
logging-data="3855586"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:Oy+zdU38HDvuz+2TbBWQod+mp8A= sha256:Y7xiJUdmS0c/oucrH0mfcPxwSOjiVSAXYKCVnW0++3w=
sha1:G0p4sGTLOkVe5KFBPPcU5yZpR6w= sha256:AeEuLPPY0Sh6OvmpmxO7/b+zn/BHGKRpxDzwysbcbX8=
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 6B896125D9E; Mon, 23 Nov 2026 13:50:02 +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 EvYjhkK9DH1V;
Mon, 23 Nov 2026 13:49:59 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-369265-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 sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4])
by mail.dewy.ru (Postfix) with ESMTPS id B8ABD125D99; Mon, 23 Nov 2026 13:49:49 +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 4836425728; Mon, 23 Nov 2026 10:49:45 +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=1795430982;
b=Itcs+/ebiu5oWpw0/qhu516BODw+rPMRAJXXVArtnp9wXKbAGn8PinE3I/2UP8x1uhSn
+PDwAJxvMZK3wlh0w+3ypcOhQ/vCvaWwJrfIJ19735Khh+jXkk/cEcNCP9GMh0ALt6OVI
wt9YXTzpKjnzunyYs/+82GKkUNbWNwkEsf1OmGbcNt6xq31lpfK7qMrzlVJ/k+zinuJ7g
NZ0gZYzPqcPdng4p6S1X1d6d6uEhyMkpVGKz36r9l4CrgVEKg5aEQjC+WIpeLNwlKwyAT
6i7tJVj3EN3R0rnu7UjOyq4ZiAI+ssDr22XgnSenRBET2YXjK+yW3zuDYMF+E4wxxSA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1795430982;
h=X-Original-To:Received:Received:DKIM-Signature:Received:
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=uuiRLHk3N+E1oMrfv2VmXcFop83iL6iVXO7sXhu2XFk=;
b=eiFJGDDggMKhYr2FxbItvQDylhLf+esUwG/qveqxBn3n1DgfAT2NeJQLDRp7CVKoE4oe
2LMgN+28u/L9OpHVJAhEHaXDOZRhr1KCqDKlJTTpUqNOq8igUYzIbL3xrkn3D/1PxM0ZA
Yg1uqsWr/jhXDCNTmOUcQYCmGK7RGUzSW6ECFv2Bj0KptxHgH0veWRaeWG7oX807KKPkb
/RfzKVB+KJIEHwQRc1yuJPad50Ry5gakeBzBA0FsIuPI2J4Ven8zZGXRkrvU8bVzCVd0S
+UEznK2aPikDIkfTSrp3Crpd7cFO1WMhRDl6YVMKBY8pp2YcbLgtj/KAyk80bdibMTQ==
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=SywKQylB;
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 BD193606A333;
Mon, 23 Nov 2026 10:49:42 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=SywKQylB
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=1795430981;
b=bvz5ue6+rKGEk6ktAfdQKrmfbqqb1rCHeni3soOeZZBRbb/WeTlVZLuSwJG6NuuTBLLC
PWpQbEUN5omEXOpWCNsc2jvuUlG6HbtbNWBYSaIH+UxI8VpUD+Urp3CBILb5q6ME3tff+
rXrkyxsYfOGVkiVZvCKqbJJ3pJnbXDQOdj3Puvz9vWBCqg9cdLz6iGarmnF7iLA0Xh76N
wRVShbdDG8l3ql6Ay0J5qgcnMrPdMUVNWz48Ama2YHuoWJHduTyDrP/qUWAvGH/MzT16c
kxogN53IhSl5rApbgkgsrJJvEnfaMKYq8ZaIy/IS25xb3WwdcTDy8O+ffdO6Djyc1bw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1795430981;
h=Received:DKIM-Signature:Received: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=uuiRLHk3N+E1oMrfv2VmXcFop83iL6iVXO7sXhu2XFk=;
b=l3qSedyzCTuI/QGJfLI41UjdST1wh4cHz4gkQAKPjqOoP5qWjs76ZEFspAc4uy2UQBqy
eDbYLaim3cHRNNSjNZNTVAntLMmq/s56/Rmvp/Tb09zo2Ge2pisWzJURGKQGvvhTTCh7p
ivErZmv5060i0vFLO9R4kyizixqFqRmBSyCgWegG7s2+h7oP+xUEicISzhoT2+Mf1Tysr
ma+PHvJgr76X2xn4slP/GDsMRJWOgo9XXi8vlnUd0wBBiJzF0Q85LzpDwWgO9BV0Zkc45
SdOgia1zFbFgaMsu3OKdEACioqnZ8eHg9VvW/G2rWGJ6VPZv6G1b68lNrQZJ3KzJSMA==
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=SywKQylB;
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 D990E606A31A
for <netdev@vger.kernel.org>; Mon, 23 Nov 2026 10:49:41 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3949F1F000CF
for <netdev@vger.kernel.org>; Mon, 23 Nov 2026 10:49:41 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
s=k20260515; t=1795430981;
bh=uuiRLHk3N+E1oMrfv2VmXcFop83iL6iVXO7sXhu2XFk=;
h=References:In-Reply-To:From:Date:Subject:To:Cc;
b=SywKQylBl15vaQ2TR8/YwlAerzTW9Z/hriV5iTYVrPGsrBpT5/BpymJGSDyzRfRcA
afP6Veqc/qzG/dzFdd+c3MnMbcbkYY+O99HsMZ3IEMhP6VMkw1VdF7hMDpAMlP6eWF
DqK7jIV8HzgzvbZsz6SPuk0+6j1aeBVyaBcarinzGlqQSIm0KNM9hPMxfZ0rkzJgZ+
LzMmhg+vob9QZUizpAwu+xQzL9UkV5bLCt/V7u8UU1bukNmoRmpGN9A04ZZ9LvF68a
11TUz3NR5ndHlmmHdkYoKRlevi4DetxogRs+W5dqFGnwes2ocTqadojkXYnhtpGDry
XHh6aJqebkNAg==
X-Received: by mail-ot1-f47.google.com with SMTP id 46e09a7af769-833e671ee9fso3005724a34.0
for <netdev@vger.kernel.org>; Mon, 23 Nov 2026 02:49:41 -0800 (PST)
X-Gm-Message-State: APuU4Z8oZAhW8N2TJWCHeExuSfBgcn0jQPp3qXrHyviqhqrimBz+rFoI
9VOovx+Qj4sgpOTxnoWmZe+PhSnLfhghk8KCq5PotR1IIIuNB4Kad3e+Ev5PmnJcN4Y2JlnhtAY
H/TFPYZOTeaskcBqopUNlFgFjgxpDdE0=
X-Received: by 2002:a05:6830:2692:b0:862:c6cb:2e25 with SMTP id
46e09a7af769-863152f8ef7mr11716687a34.2.1795430980592; Mon, 23 Nov 2026
02:49:40 -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: <20261121160204.4024204-1-razor@blackwall.org>
X-Gmail-Original-Message-ID: <CAL4WiireDJ9=d1QQS+kSJtBJDmzMbgM+tb7zNk1WunqCLKNMOQ@mail.gmail.com>
X-Gm-Features: Aa3M54qCBv2IH6BzoDtiob3Sz3xbIJRxyZ9--0FGnQoJNgurECB5N83TdB_5iZI
X-Cc: netdev@vger.kernel.org, "David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>,
Alexei Starovoitov <ast@kernel.org>, Martin KaFai Lau <kafai@fb.com>, Joe Stringer <joe@wand.net.nz>,
Daniel Borkmann <daniel@iogearbox.net>, bpf@vger.kernel.org