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 2/2] vti6: fix tunnel device use-after-free across async crypto resumption
Date: Wed, 30 Sep 2026 17:08:12 +0800 [thread overview]
Message-ID: <20260930090813.73901-3-q.h.hack.winter@gmail.com> (raw)
In-Reply-To: <20260930090813.73901-1-q.h.hack.winter@gmail.com>
Same issue as on the IPv4 side: vti6_input_proto() caches the tunnel
pointer without taking a device reference, and vti6_rcv_cb() runs from
the async crypto completion, after a possible device teardown.
Take a device reference while the pointer is cached and drop it in
vti6_rcv_cb() after the last use, like the IPv4 side.
Fixes: fa9ad96d4905 ("vti6: Update the ipv6 side to use its own receive hook.")
Cc: stable@vger.kernel.org
Signed-off-by: Qihang <q.h.hack.winter@gmail.com>
---
net/ipv6/ip6_vti.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/net/ipv6/ip6_vti.c b/net/ipv6/ip6_vti.c
index ab94b3a4ba9c..b53830d5cf54 100644
--- a/net/ipv6/ip6_vti.c
+++ b/net/ipv6/ip6_vti.c
@@ -322,6 +322,9 @@ static int vti6_input_proto(struct sk_buff *skb, int nexthdr, __be32 spi,
rcu_read_unlock();
XFRM_TUNNEL_SKB_CB(skb)->tunnel.ip6 = t;
+
+ dev_hold(t->dev);
+
XFRM_SPI_SKB_CB(skb)->family = AF_INET6;
XFRM_SPI_SKB_CB(skb)->daddroff = offsetof(struct ipv6hdr, daddr);
return xfrm_input(skb, nexthdr, spi, encap_type);
@@ -355,10 +358,14 @@ static int vti6_rcv_cb(struct sk_buff *skb, int err)
dev = t->dev;
+ /* Drop the reference taken in vti6_input_proto(). -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;
}
@@ -387,6 +394,7 @@ static int vti6_rcv_cb(struct sk_buff *skb, int err)
skb_scrub_packet(skb, !net_eq(t->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 ` [PATCH net 1/2] " Qihang
2026-10-04 10:08 ` netdev-bot+sashiko
2026-10-08 1:49 ` Qihang
2026-09-30 9:08 ` Qihang [this message]
2026-10-04 10:08 ` [PATCH net 2/2] vti6: " 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-3-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