[PATCH ipsec] xfrm: iptfs: force a dst reference before queueing an skb
From: Nguyen Ngoc Thang
Date: Sun Nov 15 2026 - 08:26:25 EST
iptfs_output_collect() is the dst->output hook and runs under the
caller's RCU read lock. It queues the skb and sends it later from the
iptfs hrtimer. The skb may still carry a noref dst, e.g. one set by
__ip_queue_xmit() via skb_dst_set_noref(). Once the RCU section ends,
nothing keeps that dst alive.
When the timer fires, xfrm_output_one() calls skb_dst_force() outside
any RCU section:
WARNING: include/net/dst.h:326 at xfrm_output_resume+0x41d9/0x64e0
Call Trace:
xfrm_output_one net/xfrm/xfrm_output.c:549 [inline]
xfrm_output_resume+0x41d9/0x64e0 net/xfrm/xfrm_output.c:597
iptfs_output_queued net/xfrm/xfrm_iptfs.c:2325 [inline]
iptfs_delay_timer+0x3803/0x4310 net/xfrm/xfrm_iptfs.c:2362
__run_hrtimer kernel/time/hrtimer.c [inline]
__hrtimer_run_queues+0x3bc/0xa10 kernel/time/hrtimer.c
hrtimer_run_softirq+0x1e3/0x2e0 kernel/time/hrtimer.c:2153
handle_softirqs+0x265/0x8d0 kernel/softirq.c:669
The warning also means the queued skb may point to a dst that has
already been freed.
Take a reference with skb_dst_force() while still under RCU, as other
deferred xmit paths do, and drop the skb if its dst is already gone.
Fixes: 0e4fbf013fa5 ("xfrm: iptfs: add user packet (tunnel ingress) handling")
Reported-by: syzbot+622de7e1f18a30fc404a@xxxxxxxxxxxxxxxxxxxxxxxxx
Closes: https://syzkaller.appspot.com/bug?extid=622de7e1f18a30fc404a
Signed-off-by: Nguyen Ngoc Thang <ngocthang2710.1999@xxxxxxxxx>
---
Tested in QEMU with the syzbot C reproducer on origin/master (23c62304dde2),
60s per run: unpatched kernel hits 48 of these warnings; patched kernel
hits 0 in 3 runs, with no KASAN reports.
net/xfrm/xfrm_iptfs.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/net/xfrm/xfrm_iptfs.c b/net/xfrm/xfrm_iptfs.c
index 0313a43aa8a9..3fff835497b9 100644
--- a/net/xfrm/xfrm_iptfs.c
+++ b/net/xfrm/xfrm_iptfs.c
@@ -1914,6 +1914,13 @@ static int iptfs_output_collect(struct net *net, struct sock *sk, struct sk_buff
continue;
}
+ /* The queued skb outlives our RCU section, so pin its dst. */
+ if (!skb_dst_force(skb)) {
+ XFRM_INC_STATS(net, LINUX_MIB_XFRMOUTERROR);
+ kfree_skb(skb);
+ continue;
+ }
+
/* Enqueue to send in tunnel */
ok = iptfs_enqueue(xtfs, skb);
if (!ok)
--
2.43.0