Article View: linux.kernel.netdev
Article #12632Re: [PATCH net v8 3/3] xfrm: hold the tunnel device reference across the input path
From: netdev-bot+sashiko
Date: Sun, 08 Nov 2026 03:48
Date: Sun, 08 Nov 2026 03:48
105 lines
11413 bytes
11413 bytes
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 ยท High: 1 ยท Medium: 0 ยท Low: 0
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [High] This patch adds a reference that leaks, and the leak fires a
WARN on the error path that the async-teardown fix is meant to cover.
--
xfrm: hold the tunnel device reference across the input path
This patch makes vti_input(), vti6_input_proto() and xfrm6_rcv_spi() take
a reference on the tunnel net_device when they cache the tunnel pointer in
the skb control buffer. xfrm_input() releases the reference on delivery
and on drop, and IPTFS releases it through new helpers,
xfrm_input_drop() and xfrm_input_consume().
> diff --git a/net/xfrm/xfrm_input.c b/net/xfrm/xfrm_input.c
> index cfd5cea033127..e3b6c486f0e9c 100644
> --- a/net/xfrm/xfrm_input.c
> +++ b/net/xfrm/xfrm_input.c
[ ... ]
> @@ -781,9 +838,12 @@ int xfrm_input(struct sk_buff *skb, int nexthdr, __be32 spi, int encap_type)
> spin_unlock(&x->lock);
> drop:
> xfrm_rcv_cb(skb, family, xfrm_proto, -1);
> + tdev = xfrm_input_take_tunnel_dev(skb, family);
> + kfree_skb(skb);
> + if (tdev)
> + dev_put(tdev);
[Severity: High]
Can this leak the tunnel device reference taken by dev_hold() in
vti_input() or vti6_input_proto()?
At the top of xfrm_input(), in the resume/GRO/offload branch, the
invalid-state check jumps to drop before family is assigned:
if (unlikely(x->km.state != XFRM_STATE_VALID)) {
...
if (encap_type == -1)
async = 1;
goto drop;
}
family = x->props.family;
At that point family still has its initial value, AF_UNSPEC. The slot is
non-NULL, so xfrm_input_take_tunnel_dev() falls into its default case:
default:
WARN_ON_ONCE(1);
return NULL;
The slot is not cleared and tdev stays NULL. The skb is freed and the
dev_put() is skipped.
One way to reach this is async crypto that completes after the SA has
been deleted or has expired, for example during an IKE rekey:
vti_input()
dev_hold(tunnel->dev)
xfrm_input()
esp_input() returns -EINPROGRESS
<SA deleted, km.state no longer XFRM_STATE_VALID>
xfrm_input_resume()
xfrm_input(skb, nexthdr, 0, -1)
goto drop with family == AF_UNSPEC
Two other paths look the same. One is an offload skb that enters through
vti_input() with encap_type 0. The other is the IPTFS outer skb that is
passed to xfrm_input(skb, 0, 0, -2) after the SA has become invalid.
If the reference leaks, a later unregister of the vti/vti6 device or a
netns teardown would wait forever in netdev_wait_allrefs_any(). The
WARN_ON_ONCE() would also panic the machine with panic_on_warn set.
The commit message says:
"The early drop for a state that is no longer valid releases
the reference too, and needs the address family for that, so set the
family before the validity check."
The diff doesn't move the family = x->props.family assignment ahead of
the km.state check, though. Was that hunk left out of the patch?
> if (async)
> dev_put(dev);
> - kfree_skb(skb);
> return 0;
> }
> EXPORT_SYMBOL(xfrm_input);
--
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261107111617.21347-1-q.h.hack.winter%40gmail.com
Technical Details
Message-ID:
<179410971777.994134.15451365974741782333@kernel.org>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-358585-linux-kernel-netdev=dewy.ruReferences:
<20261107111617.21347-4-q.h.hack.winter@gmail.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-358585-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net v8 3/3] xfrm: hold the tunnel device reference across the input path Date: Sun, 08 Nov 2026 03:48:37 +0000 Organization: Usenet Network Message-ID: <179410971777.994134.15451365974741782333@kernel.org> References: <20261107111617.21347-4-q.h.hack.winter@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="56976"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:gQUpWYcAf4RPBIRPmkWJhMrh6jM= sha256:mnh62WIFnN6eaTfQltTfjDgtLbW4qYRBNBlZqf62dJ8= sha1:HfJnub889DGWENDAX/bLXFACJo0= sha256:qz0RLkd0F9TD7qd/aVXmZG+DOa3cAq1mIDYU8hkgUS8= 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 DBC3211350B; Sun, 8 Nov 2026 06:49:12 +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 5WweQfV0SVoQ; Sun, 8 Nov 2026 06:49:04 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-358585-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 tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id 4CC221134FA; Sun, 8 Nov 2026 06:48:53 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by tor.lore.kernel.org (Postfix) with ESMTP id 097363DAC3; Sun, 8 Nov 2026 03:48:44 +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=1794109720; b=zqRjqHhWoikF3pIeQh0WNF9SevakHBWzLWQGWV8yDssueF7UE9uoy4A8RUL8LZSI8JV2 SgD9DVyp1/MWWCT1cw6s+5tFKgmUOPJeec4XjWU6n8Xj3u4uK7BCkJg5baeL2y/Cd8vz3 ACRWI4+2FJoKaUcfLcXi0IQNtXGYdCSMdjFWm4XIYz8ldlPuUPhzyOkkbQPe5TXPQxvQX kCoZCpLFfJ4QWBVYsY3S2JL4akt6OpKKcn+8x0AxrLbEgx/+0uxNI+hYiAh7gCcSPdp6G BpPgAf5QrqR1sYoUeMap2FO6UsN74nJdlWcE7j84iNCD0F+WhcgcPwmfu/SIF1+Cxmg== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794109720; 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=TZiwCM2N46vTpQtDwGQiax0bnFKCo40uZq0Xn4XOGzQ=; b=ScndTT6UzuFXl2MUnK7O47j5EnK2C4gImdTZMoLTnbE7O/y1EERUX8jdJ14Pbdk2LZXG jGm9KT3QirvRdEHUZIQQxMKI0nArDT7G/qleLd44yH/MAPFi0fJL36Y9UMtPopwuOHv+c 9L1f0vNQgbAX9fsLwZem3Xm3Z7LEyiHtbT3TsQcgKouBf5LuvHE0GHly/wm5YXrFnNU70 xsgnT60BvFsI/mg9qr8RdZDVyMlKyhY6zhRQgGgaSX0SUxLpxC9QIvh3Vrfpogey8K4Uw MrfpyD02eISbPebderGYPxMmKlSLdwmuZAFIy3wPzaGkjZERUCY9qHjnGdZuVYygeEg== 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=TWpQQY3F; 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 63960606A334; Sun, 8 Nov 2026 03:48:40 +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=TWpQQY3F 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=1794109719; b=hPxQMwrYLJAdb5HjW/xI8IlaqnsMKqikAuTD3J1ABr/Rjx7KwYKPpKCe1VRsPrd7rvRF dACra5JX4LsDSInHfDK2LuNq+Dyg4wHMlP2wB+jsXcxtqnivybgN+i4ZxQ5inxqdUG8B+ maa/xDFM28d7QczgfJCQosZIk2Yy8wEBBtIzgzqpT+Nvomr5tsKsgY50I2NKCYEXSjLkH +YpWLe5SgG8SYfPwc6Rm0iefPtMDH508QSwQUrfyXN9PDeOYeeBQLotFTGgelFrE6gKcp oPsCc+WxIiwoT/BJ95WRTG2/oGw537PKBj3uSo7POY1idmiEfwhoUB1TLqfBUR/Go2w== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794109719; 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=TZiwCM2N46vTpQtDwGQiax0bnFKCo40uZq0Xn4XOGzQ=; b=YCHcV2pKBR8zQeviGoqBfg6SH8dzSBGYyH76qXdOlCiZs4J7bAo5bakp8k7dKetVJUWu ltPH4hzf614MyqDwsxPBwWhU++ZOSixZmoVzH3H/W2qS1sVghdCD6vvlM0gvfqlhUJzhi J+Z4lfl54K5edEX4cSnhIINFPczWO5m8NaT72hrU0/Fppyn10rHX04fV2B6Nr4+3Xoogf VbZjAuEn/MnnQRW/3KJnz/JwVD8+7637nNVWh10Kqo+fyf5z7dZeDQu0DriETfzws3g+f OSKg+DxbdIXptHnGaJVO4zyGSf+xApkNRD8L5Ma8o9njMu+K6+DV47IhWlrErTZ5o9g== 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=TWpQQY3F; 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 3D78E606A31F; Sun, 8 Nov 2026 03:48:38 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2FEDF1F008A1; Sun, 8 Nov 2026 03:48:38 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1794109718; bh=TZiwCM2N46vTpQtDwGQiax0bnFKCo40uZq0Xn4XOGzQ=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=TWpQQY3F3XHqMfmPt/mhf+VxDNGrw/P3UN54DWGxyqflxQsaQtr7obQOL+jomh2Vu 8T6PPgNIpnNqy+I/Ktxwpb2q0pVQZ0LAkwtiBBh5KyVHFmvmVlV2J7KlCNn7cIUSgY 6F8cjhnYqaGlqup6ZN8HtttH6P1EsTQSNN3dRSPCrXUR1pLIP6astsexhVDiKQ0YKC N4EWPEBvp451XOIcgWqdhq4LHOLAnnxA0qgzmCc1q5030y93l/DpMn8pPWGxF7FpLj iwpNcdMxuQvOXgSg7iRpRkc0v7InjZ3xEBwMnuc3s5/vM6TejZopJZ7tkV9UV90Jw4 00gdBB5CajTUQ== X-Cc: netdev@vger.kernel.org, steffen.klassert@secunet.com, chopps@labn.net, herbert@gondor.apana.org.au, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, dsahern@kernel.org, idosch@nvidia.com, linux-kernel@vger.kernel.org X-In-Reply-To: <20261107111617.21347-4-q.h.hack.winter@gmail.com> X-sashiko-severity: High 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