Article View: linux.kernel.netdev
Article #19350Re: [PATCH net-next v4 1/4] net: xfrm: interface: restore dst_orig on every xfrm interface
From: netdev-bot+sashiko
Date: Thu, 19 Nov 2026 20:02
Date: Thu, 19 Nov 2026 20:02
105 lines
12223 bytes
12223 bytes
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] This commit fixes real, user-visible bugs but carries no Fixes:
tag.
- [Low] The commit message does not mention that the old per-cpu design
leaked a route reference, and that this patch fixes the leak.
--
net: xfrm: interface: restore dst_orig on every xfrm interface
This commit makes xfrmi_xmit2() restore dst_orig from the xfrm metadata
in both the collect_md arm and the configured if_id arm. It takes its own
reference with dst_clone() and drops the metadata dst from the slot
first. It also switches bpf_skb_set_xfrm_info() from a shared per-cpu
metadata dst to a per-skb one and removes xfrm_bpf_md_dst.
> net: xfrm: interface: restore dst_orig on every xfrm interface
[ ... ]
> The same slot overwrite is in the unstable helper a tc-bpf program uses to
> attach that metadata: bpf_skb_set_xfrm_info() records the route as dst_orig
> and installs a per-cpu metadata dst over it. The per-cpu dst is shared by
> every invocation of the program, so the restore cannot keep anything in it.
>
> The Fix:
> Restore dst_orig in both arms of xfrmi_xmit2(), taking a reference with
> dst_clone() so the metadata dst keeps its own, and empty the counted slot
> with skb_dst_drop() before the route is installed. The helper allocates a
> metadata dst per skb instead of a per-cpu one, so the route it records
> belongs to that skb and is released with it; the per-cpu allocation is no
> longer used and goes away.
[Severity: Low]
Should the commit message also say that the per-cpu design leaked the
route reference, and that this change fixes the leak?
Before this patch, bpf_skb_set_xfrm_info() moved the skb's reference on
the route into the shared per-cpu xfrm_md_info:
skb_dst_force(skb);
info->dst_orig = skb_dst(skb);
dst_hold((struct dst_entry *)md_dst);
skb_dst_set(skb, (struct dst_entry *)md_dst);
Only the collect_md arm of xfrmi_xmit2() returned that reference, by
clearing md_info->dst_orig. Some packets never reach that arm:
TC_ACT_SHOT, a redirect to a non-xfrm device, an xfrm interface with a
configured if_id, or any drop before xmit. For those packets, the next
helper call on the same CPU overwrote info->dst_orig without calling
dst_release().
xfrm_bpf_md_dst is never freed, so metadata_dst_free_percpu() never runs
for it. The route therefore leaks, along with the net_device reference it
holds. That can leave the device stuck in "unregister_netdevice: waiting
for <dev> to become free".
With the per-skb metadata dst, the route is released when the metadata
dst is destroyed:
dst_destroy()
metadata_dst_free()
dst_release(md_dst->u.xfrm_info.dst_orig);
At the moment the message only says the per-cpu allocation goes away.
Could it mention the leak as well?
[ ... ]
> Reviewed-by: Victor Nogueira <victor@mojatatu.com>
> Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com>
[Severity: Low]
Should this patch have a Fixes: tag?
These three pieces all appear to come from the same commit:
- the per-cpu metadata dst in bpf_skb_set_xfrm_info()
- the xfrm_bpf_md_dst pointer in net/core/filter.c
- the collect_md-only dst_orig restore in xfrmi_xmit2()
That commit is:
Fixes: 94151f5aa966 ("xfrm: interface: Add unstable helpers for setting/getting XFRM metadata from TC-BPF")
The configured if_id drop and the clone sharing problem date back to
that commit as well. The slot overwrite started to warn, or panic with
panic_on_warn, only after a890348adcc9 ("net: Add skb_dst_check_unset")
added this check:
DEBUG_NET_WARN_ON_ONCE((skb->_skb_refdst & SKB_DST_PTRMASK) &&
!(skb->_skb_refdst & SKB_DST_NOREF));
The message says the tc-bpf case needs no other patch from the series.
Without the tag, stable tooling can't tell how far back the fix applies.
--
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/CORE-9NOG.v4.r0.20261116135311%40mojatatu.com
Technical Details
Message-ID:
<179511856062.3136.18243971639206515341@kernel.org>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-367298-linux-kernel-netdev=dewy.ruReferences:
<CORE-9NOG.v4.r0.20261116135311-1@mojatatu.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-367298-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net-next v4 1/4] net: xfrm: interface: restore dst_orig on every xfrm interface Date: Thu, 19 Nov 2026 20:02:40 +0000 Organization: Usenet Network Message-ID: <179511856062.3136.18243971639206515341@kernel.org> References: <CORE-9NOG.v4.r0.20261116135311-1@mojatatu.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="2968212"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:D5Jw/oF6A0ZncXflxUMge2G597E= sha256:or16HxkIeFN5lD8PmGtNR557HEb0U/hsps/FvI+tko8= sha1:eikPmQA5U8k3Tp0yvOw5g5krDak= sha256:baLxSJC4eCCXeg7Vl3+jFd0wggjb4aykvge5v9YAi2w= 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 16B8C115760; Thu, 19 Nov 2026 23:03:06 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.4 X-Spam-Status: No, score=-3.4 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, URIBL_BLOCKED=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 h5aAiq30m02I; Thu, 19 Nov 2026 23:03:02 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-367298-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 1C6DA11575D; Thu, 19 Nov 2026 23:02:53 +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 5DF0A1C8944; Thu, 19 Nov 2026 20:02:49 +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=1795118568; b=YeZe6ozQRkhEquZX4pnSe+R631/3nG+ukGQrYGP05jEsOQp0j5TAG91RQRIIIg/DLjGX 4ZXHnWQSlLrM80ZF5QlX4l7p4AhOxekLN3rxK2GgCyAz43Od1OTEZn//+nP34rqd6+X9g 7Xd4dZHpfPgH+gq9Qrah9ClgaPN5ccXBzy17RMRQqDzUPplJaQXdU1qbUEelYnnb3+n7+ 3W9x+Sm6TaSpbWtoajt7MMHU77ONYiCvZ9XE3O997/3mDXjOiI3P3n9O5aK1UCRcg7FY4 mNefk6FlaqybCJLRDo9yDIjXkUc9AtO+nj352vpkDn3qCKVUqWt6qmf960EFT7LawYQ== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795118568; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=yS5HZGb4ZYV7fzhYyCITQ/ILCiUQlwy/aDQIF+31MW8=; b=TeCUtSz81Lg/ntL30vxZ6gJ0VaG+e0tJTz58WAnUDMj77+u+J+umSAT6nzSbw2q2kvf3 sBPN8Bz57fjC1waFfqu5eX3P+veSKfLYczWfnvKVRTh8cauDeL01ZUn/Y57lM9PkvXhVm B7y/Kt5dCm8WTGxFqJe0K6f3ObLSeyonfjDy/hbg956fc+ikUJ20UGQCKD7keEOpQP+Ho cBCsl4g3MBqdcCp6OSL58DbRghUxEX+bfssvZKqgbfSz8i2MM4HKoN0eFfwLMCW8jzkyD Ekr720Id7t3t5ZJUMu63fokLFt6HlYVRA9/ows971klop5Hvn7P4/Ux74IKYdp7rABQ== 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="fxU/TGcC"; 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 84A3560A2600; Thu, 19 Nov 2026 20:02:48 +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=fxU/TGcC 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=1795118562; b=cNZ3jwKiorpxrGfbp8CaHbChEcjtXWPU/Uzs1pZJ472zrKdpzlKp5PiQ+3AGymucPcVa QefD3kzudvHIbHVqDAHQTdc1fyKuY3zbVDgBTVL2PS3xivXjBv0m+cjTPq4MZrVDfSN6c MtabZbIVeExDNpJja8rcCE5OKpuTqjaYGDPo8apzoF5eXfPLT/DqkybbZA0btLtXjdq98 J352fTbxUCE6MS9rM+DP0DnXPDDkTtJmKHa/vCPOdWwBL6AM8F/iMg7Q2zjLWpB+hWlYm mH1hKRQQZ4FoXjhGcsmGKeNHFEHuTA8ZpyDN9Oit5FDqekvzuZ++NivLOES4RWFec2w== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795118562; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=yS5HZGb4ZYV7fzhYyCITQ/ILCiUQlwy/aDQIF+31MW8=; b=i31hE0NfRR69/uxeX3XCN8+shdE+Dl8XUq6mPeVaNesWw6frPljEJi2HLK3pTLwR58Yt II261cAk5mhI6dh2qRdy1nATmUyHBAQHn0hTDIxIrbTnanJAsaGCT29pKFeQ5wA+SCeTu Y33QtVWt/bK01BJd1l0/71ii8eQ6iZtLXd1+uQHAaYjlSP4Yiixor4OswshooVXDIIzjN fLghMB0pMx3FquCdQwJEnRjDnNAAvV0hyXv5uZb9OjbKJHVcfo36KZu8mXob2GscXMK6L ckJ/+CdCl2AqWUVMJmJuyWQGQif7Vu3UUYk/tR4S2s4lqBGdzGsWvEzPTU4NzC4IUgg== 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="fxU/TGcC"; 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) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9B884606A324; Thu, 19 Nov 2026 20:02:42 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 13BDA1F000C6; Thu, 19 Nov 2026 20:02:41 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795118562; bh=yS5HZGb4ZYV7fzhYyCITQ/ILCiUQlwy/aDQIF+31MW8=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=fxU/TGcCrY5xlJwFFLlAn1jTWV0E5hTnmdN+IJB9RNcS+a2vw+7uiwuntML6Sw1d3 Z7fp5QL6FsWvBNluBljxGexs56t7UNh4LZfNHad68IONQMoMsPncnV2376zbbxFwtS ndGZvc7ZBTPtk5bzUBInv4x19bp1Ach9QXK45SPmNauF4/Y2wGjzEv60klCxoKaoxN bHT9/bxJEmnW749qgs71MIZE/s+/X2dwZaStZ89ZFDxc/6dMlAd1gR6Nhoh226pkH7 BqmxZxQ7/qDudV1kXRaHI8J4C1bwmMWuAwPSSF0VjaJXN5pO/c2SNOi3b6VhkxcseC 7IVbvd9N+EwPg== X-Cc: netdev@vger.kernel.org, daniel@iogearbox.net, john.fastabend@gmail.com, sdf@fomichev.me, martin.lau@linux.dev, ast@kernel.org, andrii@kernel.org, eddyz87@gmail.com, memxor@gmail.com, song@kernel.org, yonghong.song@linux.dev, jolsa@kernel.org, emil@etsalapatis.com, ihor.solodrai@linux.dev, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, bpf@vger.kernel.org, jiri@resnulli.us, victor@mojatatu.com, sashiko-bot@kernel.org X-In-Reply-To: <CORE-9NOG.v4.r0.20261116135311-1@mojatatu.com> X-sashiko-severity: Low 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