Subject: Re: [PATCH net v2] net: protect egress device access in the output path with rcu_read_lock

From: Ido Schimmel <[email-masked]>
Date: Tue, 2 Jun 2026 18:45:23 +0300

On Sun, May 31, 2026 at 04:06:50PM +0900, Hyunwoo Kim wrote:
>  drivers/net/vrf.c       | 16 +++++++++++-----
>  net/ipv4/ip_output.c    | 27 +++++++++++++++++++--------
>  net/ipv4/raw.c          |  4 +++-
>  net/ipv4/xfrm4_output.c | 13 +++++++++----
>  net/xfrm/xfrm_output.c  |  4 +++-
>  5 files changed, 45 insertions(+), 19 deletions(-)
> 
> diff --git a/drivers/net/vrf.c b/drivers/net/vrf.c
> index 46209917ae4d..e9a1dd961805 100644
> --- a/drivers/net/vrf.c
> +++ b/drivers/net/vrf.c
> @@ -833,17 +833,23 @@ static int vrf_finish_output(struct net *net, struct sock *sk, struct sk_buff *s
>  
>  static int vrf_output(struct net *net, struct sock *sk, struct sk_buff *skb)
>  {
> -	struct net_device *dev = skb_dst(skb)->dev;
> +	struct net_device *dev;
> +	int ret;
> +
> +	rcu_read_lock();
> +	dev = skb_dst_dev_rcu(skb);
>  
>  	IP_UPD_PO_STATS(net, IPSTATS_MIB_OUT, skb->len);
>  
>  	skb->dev = dev;
>  	skb->protocol = htons(ETH_P_IP);
>  
> -	return NF_HOOK_COND(NFPROTO_IPV4, NF_INET_POST_ROUTING,
> -			    net, sk, skb, NULL, dev,
> -			    vrf_finish_output,
> -			    !(IPCB(skb)->flags & IPSKB_REROUTED));
> +	ret = NF_HOOK_COND(NFPROTO_IPV4, NF_INET_POST_ROUTING,
> +			   net, sk, skb, NULL, dev,
> +			   vrf_finish_output,
> +			   !(IPCB(skb)->flags & IPSKB_REROUTED));
> +	rcu_read_unlock();
> +	return ret;
>  }

Patch LGTM, thanks, but what about the IPv6 counterpart (vrf_output6())
and the other similar existing issues that Sashiko is flagging?