> xfrm: iptfs: force a dst reference before queueing an skb
TL;DR: Commit message only: the claim that iptfs_output_collect() always runs under the caller's RCU read lock may be inaccurate, since the udp_sendmsg() path has no RCU lock. The code change itself looks fine.
> 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.
This isn't a bug, but is "runs under the caller's RCU read lock" accurate for every caller? The udp_sendmsg() -> udp_send_skb() -> ip_send_skb() -> ip_local_out() -> dst_output() path reaches iptfs_output_collect() in process context without rcu_read_lock(), although the dst there is already refcounted so skb_dst_force() does nothing. Would it be more precise to say that callers that attach a noref dst hold an RCU read lock?
> diff --git a/net/xfrm/xfrm_iptfs.c b/net/xfrm/xfrm_iptfs.c > --- 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)
--- AI reviewed your patch. Please fix the bug or email reply why it's not a bug. See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md CI run summary: https://github.com/kernel-patches/bpf/actions/runs/46652847109