Article View: linux.kernel.netdev
Article #8581Re: [PATCH net v7 2/3] xfrm: set the address family before the early invalid-state drop
From: netdev-bot+sashiko
Date: Thu, 29 Oct 2026 14:09
Date: Thu, 29 Oct 2026 14:09
100 lines
11700 bytes
11700 bytes
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · 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).
- [Medium] This commit taken by itself: moving `family = x->props.family`
above the `x->km.state != XFRM_STATE_VALID` check in xfrm_input()…
--
xfrm: set the address family before the early invalid-state drop
This patch moves the family assignment in xfrm_input() above the check
for a state that is no longer valid. As a result, the early drop path
calls xfrm_rcv_cb() with a real address family instead of AF_UNSPEC. The
commit message describes this as a prerequisite for releasing the tunnel
device reference on that drop path in the next patch.
> diff --git a/net/xfrm/xfrm_input.c b/net/xfrm/xfrm_input.c
> index cfd5cea033127..ab391258a5028 100644
> --- a/net/xfrm/xfrm_input.c
> +++ b/net/xfrm/xfrm_input.c
> @@ -487,6 +487,7 @@ int xfrm_input(struct sk_buff *skb, int nexthdr, __be32 spi, int encap_type)
> encap_type == UDP_ENCAP_ESPINUDP))) {
> x = xfrm_input_state(skb);
> xfrm_proto = x->type ? x->type->proto : nexthdr;
> + family = x->props.family;
>
> if (unlikely(x->km.state != XFRM_STATE_VALID)) {
> if (x->km.state == XFRM_STATE_ACQ)
[Severity: Medium]
On its own, can this commit expose a use-after-free on the vti and vti6
tunnel devices?
When an async-resumed skb (encap_type == -1) fails this check, it jumps
to the drop label in xfrm_input():
drop:
xfrm_rcv_cb(skb, family, xfrm_proto, -1);
if (async)
dev_put(dev);
kfree_skb(skb);
Before this patch, family was still AF_UNSPEC at this point. That made
xfrm_input_get_afinfo() return NULL, so no callback ran. Now
xfrm4_rcv_cb() or xfrm6_rcv_cb() runs, and that reaches vti_rcv_cb() or
vti6_rcv_cb() with err == -1:
net/ipv4/ip_vti.c:vti_rcv_cb() {
struct ip_tunnel *tunnel = XFRM_TUNNEL_SKB_CB(skb)->tunnel.ip4;
...
dev = tunnel->dev;
if (err) {
DEV_STATS_INC(dev, rx_errors);
DEV_STATS_INC(dev, rx_dropped);
...
}
vti_input() stores the tunnel pointer in skb->cb without taking a
reference. vti6_input_proto() does the same for IPv6, after
rcu_read_unlock().
During async crypto, xfrm_input() calls dev_hold() only on skb->dev. On
the vti proto path that is the underlay device, not the vti net_device.
A state that becomes invalid while crypto is pending is the teardown
case: an SA delete or flush, often together with tunnel deletion or
netns teardown. If the vti device has already been unregistered and
freed by then (vti6_dev_uninit() unlinks the tunnel and drops its
reference without waiting for in-flight crypto), then the
DEV_STATS_INC() calls would write into freed memory.
The same unreferenced dereference already exists on the async success
and drop_unlock paths. So this patch widens an existing problem rather
than creating a new one.
The last patch of this series, "xfrm: hold the tunnel device reference
across the input path", adds dev_hold() on the tunnel device in
vti_input(), vti6_input_proto() and xfrm6_rcv_spi(). It then releases
that reference after xfrm_rcv_cb() on the drop path, which appears to
fix this.
Both patches are Cc: stable. Would it make sense to reorder the series,
or fold the two patches together? That would avoid an intermediate
state that bisect could land on, or that a stable backport taking only
this patch would pick up.
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261027105031.19928-1-q.h.hack.winter%40gmail.com
Technical Details
Message-ID:
<179328294937.3134.2288184405522355478@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-353315-linux-kernel-netdev=dewy.ruReferences:
<20261027105031.19928-3-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-353315-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net v7 2/3] xfrm: set the address family before the early invalid-state drop Date: Thu, 29 Oct 2026 14:09:09 +0000 Organization: Usenet Network Message-ID: <179328294937.3134.2288184405522355478@kernel.org> References: <20261027105031.19928-3-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="2022825"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:kA6wiT9z23/7ma5RUeB8pZzsafY= sha256:RZmp/l33GMtjklJGOwypcRt6RxNc0qaCD9+hyla9wLk= sha1:8flcU58Jx8rdQggDvffLbJS7sVU= sha256:wYIcX3ouzU2bIva1t9YEhCvq7cN+o05EXC3H/zlmrgU= 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 66EAD125C65; Thu, 29 Oct 2026 17:09:44 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.5 X-Spam-Status: No, score=-3.5 tagged_above=-9999 required=6.31 tests=[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 8Nh-5YqyRgVU; Thu, 29 Oct 2026 17:09:41 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-353315-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 sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74]) by mail.dewy.ru (Postfix) with ESMTPS id 614D9125C68; Thu, 29 Oct 2026 17:09:32 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sto.lore.kernel.org (Postfix) with ESMTP id 875906018F2; Thu, 29 Oct 2026 14:09:18 +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=1793282957; b=NA61wQs0NZWm1cdI63Ew708qhDBikudQcERnZNXFd/JiFTNJ4Gr31zVrxVVzq1qnTdNz KYS0FEzdWFVVNSrx0WyrNdyhTHppkLjscpsCXnM39GuJcYR2eZPADRMFe8LXBbAIquMt6 4OSEhl7eqX0sNwlKLMNSaE+yZ4UpHHUYuxEpCJ1BT7by9t4CXH7W9QByd83XyQuj9HZbJ cJDzfnwACHTiGvPoWxRzWyYA3F4F/Y9aXvDrqICKt2xZPQ/91SfJ366Ru2YtdejEt5GRL 1ojuCUrtd+8NVjEQ3R36dHTwjW4eioRWXWR0j7YI3oy/H4eUG3ftyVG560v5CaKy9gQ== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793282957; 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=Ubd3Ga831NUXqcpt+jZKp5rTrR12SuA0oDofbMeQqiE=; b=Pa56A2U1W+5Da3ny4w4fsCaxOhRN52EL/Pt9GsvuBM93qlh5Mcjx3U3jtU1P/qYzuhQZ sTKbJN/b7MMFGVB5XVT6OoT1TErrqAPZlzJw5Pf17WD0dldAgynNXZWzC/T+j3u7dxt0a +UU8aMlo1ZdsLJvuK9yvCOxM/12UQgQ4bELc9WxxdHs3ECisZsLGIYyhBkhnMKo0kZQO1 ZpxI5b5ZZV5GzHhWBJvMotEatRTbEYN7l3jIcxJwmfeV8DyZDTR8WsqbWxWUSTUw1kty0 GXdBAkk99a6OSjigx5HiwQEK+aLl4s9ooUkj4ZoGyO3Dwjf0ok3j2fPouk5Xut2lRIw== 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=kyymJSJf; 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 145EB606A332; Thu, 29 Oct 2026 14:09:17 +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=kyymJSJf 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=1793282951; b=FglTfyDbIxLmb71wSfa02zcYmt3TUXtplzzJnO8EaAOQyc9QE3pMoe1BIASvKgCRBtXa o++c26le0ewX/v0NkXZ9MqIP2M4JwS1eJYkqqrrOTTAbkLzglxw8jleCilThDkuL7i2fx EcORkmdyvwXjvORelcnQIoy7kZkX14pO5CTQJkFCYdZsvJD2LtYmx42xm7X5s3TLeVj6W hx9JWE7OJEqioHybdXiWlCMmTc0Rrioj6wktxgrif27Q0qFrAELaRu5x86xwfo+Wc399I svakcjtx3tfhvSi7guh0uDbCbgCmPw2cHZuPHtMkNRQoXLsCzhlgG4xclFCaC/7pQ/g== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793282951; 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=Ubd3Ga831NUXqcpt+jZKp5rTrR12SuA0oDofbMeQqiE=; b=tsbQm0gydVmb62E6zrHMHe9jXsJVmJZrmuPq/ZLm9tayBctHE26HAWhl4f9mWWziC3YO kzFWXBMupmXpnS7hf/uAVJKaqCgOwwK48+oSXPqlyNmRRLF+yw3MOxaAfnLE3tjj/9jdK YSFDHKrbbgEmE+ndi8XwYbNZ0EGPQiuQgy30oqC1/BTCmheD66GbLO1RKSbkc2qh8aPAo cwk+LabypWO9ge0vZmu2lzXJC76egnGdDHfOEbrVNnjyrox1zy37/L32TXhhv3DDx3RqW hzu+F5gV4uwNeXpzNyW32TYfg44UI6obnt15Peo12Yx/PhkbvrISvtivatuJFaVA2nQ== 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=kyymJSJf; 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 D29E5606A321; Thu, 29 Oct 2026 14:09:10 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id CBF5F1F01828; Thu, 29 Oct 2026 14:09:09 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1793282950; bh=Ubd3Ga831NUXqcpt+jZKp5rTrR12SuA0oDofbMeQqiE=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=kyymJSJfMEaIE0i1S2EHZCMBOFhBL9nfBTTLlhXCfM6Ltw8hLPzEIpukjwexVw9Ik 10fPc+qsVFt0eVndbxaAiz86KAtYcfaTh5/wbwp/OxA4eB8fbpxUmMFkzb4v2ouP18 8Er+8LbTUL8QiRq9V3M9ZGlYMamTGLS8l4L7HIqlChh4LxBosI7jKvH4inbJezMIBa AWWw09F4Pm6wlbA8MSYAdCo3qYYJzjJzStTNpVC6l5BqZJUVovL5ecOSOqdAkA9x7J lDdljxgV8eSyCgEkWdr/Pdnbyg9DxPDWEUUcByn8MCIRBqZhebcb683Y/nq2NUn6aZ 8pEasA9TI9QMA== 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: <20261027105031.19928-3-q.h.hack.winter@gmail.com> X-sashiko-severity: Medium 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