From: Qihang <q.h.hack.winter@gmail.com>
To: netdev@vger.kernel.org
Cc: steffen.klassert@secunet.com, herbert@gondor.apana.org.au
Subject: [PATCH net 1/2] vti: fix tunnel device use-after-free across async crypto resumption
Date: Wed, 30 Sep 2026 17:08:11 +0800 [thread overview]
Message-ID: <20260930090813.73901-2-q.h.hack.winter@gmail.com> (raw)
In-Reply-To: <20260930090813.73901-1-q.h.hack.winter@gmail.com>
vti_input() caches the tunnel pointer in the skb control buffer
without taking a device reference. With async crypto, vti_rcv_cb()
runs from the crypto completion, after a possible device teardown, and
dereferences the freed tunnel device. The rcu_read_lock() around the
callback cannot protect it, as the pointer was cached before the
deletion grace period.
Take a device reference while the pointer is cached and drop it in
vti_rcv_cb() after the last use. An RTM_DELLINK on a VTI device with
pending async crypto now waits for the completion.
Fixes: df3893c176e9 ("vti: Update the ipv4 side to use it's own receive hook.")
Cc: stable@vger.kernel.org
Signed-off-by: Qihang <q.h.hack.winter@gmail.com>
---
net/ipv4/ip_vti.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/net/ipv4/ip_vti.c b/net/ipv4/ip_vti.c
index 3b80929994a0..9f44666139f8 100644
--- a/net/ipv4/ip_vti.c
+++ b/net/ipv4/ip_vti.c
@@ -63,6 +63,8 @@ static int vti_input(struct sk_buff *skb, int nexthdr, __be32 spi,
XFRM_TUNNEL_SKB_CB(skb)->tunnel.ip4 = tunnel;
+ dev_hold(tunnel->dev);
+
if (update_skb_dev)
skb->dev = tunnel->dev;
@@ -109,10 +111,14 @@ static int vti_rcv_cb(struct sk_buff *skb, int err)
dev = tunnel->dev;
+ /* Drop the reference taken in vti_input(). -EINVAL/-EPERM make
+ * xfrm_input() re-invoke us with err = -1 and drop it then.
+ */
if (err) {
DEV_STATS_INC(dev, rx_errors);
DEV_STATS_INC(dev, rx_dropped);
+ dev_put(dev);
return 0;
}
@@ -141,6 +147,7 @@ static int vti_rcv_cb(struct sk_buff *skb, int err)
skb_scrub_packet(skb, !net_eq(tunnel->net, dev_net(skb->dev)));
skb->dev = dev;
dev_sw_netstats_rx_add(dev, skb->len);
+ dev_put(dev);
return 0;
}
--
2.54.0 (Apple Git-157)
next prev parent reply other threads:[~2026-09-30 9:08 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-30 9:08 [PATCH net 0/2] vti: fix tunnel device use-after-free across async crypto resumption Qihang
2026-09-30 9:08 ` Qihang [this message]
2026-10-04 10:08 ` [PATCH net 1/2] " netdev-bot+sashiko
2026-10-08 1:49 ` Qihang
2026-09-30 9:08 ` [PATCH net 2/2] vti6: " Qihang
2026-10-04 10:08 ` netdev-bot+sashiko
2026-09-30 9:13 ` [PATCH net 0/2] vti: " netdev-bot+sinfo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260930090813.73901-2-q.h.hack.winter@gmail.com \
--to=q.h.hack.winter@gmail.com \
--cc=herbert@gondor.apana.org.au \
--cc=netdev@vger.kernel.org \
--cc=steffen.klassert@secunet.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox