* [PATCH ipsec] xfrm: iptfs: force a dst reference before queueing an skb
@ 2026-11-15 13:26 Nguyen Ngoc Thang
2026-11-23 11:23 ` Steffen Klassert
0 siblings, 1 reply; 2+ messages in thread
From: Nguyen Ngoc Thang @ 2026-11-15 13:26 UTC (permalink / raw)
To: Steffen Klassert, Herbert Xu
Cc: Christian Hopps, David S . Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Simon Horman, netdev, ipsec, linux-kernel,
syzbot+622de7e1f18a30fc404a
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@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=622de7e1f18a30fc404a
Signed-off-by: Nguyen Ngoc Thang <ngocthang2710.1999@gmail.com>
---
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH ipsec] xfrm: iptfs: force a dst reference before queueing an skb
2026-11-15 13:26 [PATCH ipsec] xfrm: iptfs: force a dst reference before queueing an skb Nguyen Ngoc Thang
@ 2026-11-23 11:23 ` Steffen Klassert
0 siblings, 0 replies; 2+ messages in thread
From: Steffen Klassert @ 2026-11-23 11:23 UTC (permalink / raw)
To: Nguyen Ngoc Thang
Cc: Herbert Xu, Christian Hopps, David S . Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Simon Horman, netdev, ipsec,
linux-kernel, syzbot+622de7e1f18a30fc404a
On Sun, Nov 15, 2026 at 08:26:11PM +0700, Nguyen Ngoc Thang wrote:
> 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@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=622de7e1f18a30fc404a
> Signed-off-by: Nguyen Ngoc Thang <ngocthang2710.1999@gmail.com>
Applied, thanks a lot!
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-23 11:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-15 13:26 [PATCH ipsec] xfrm: iptfs: force a dst reference before queueing an skb Nguyen Ngoc Thang
2026-11-23 11:23 ` Steffen Klassert
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®