[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250722190014.32f00bbb@kernel.org>
Date: Tue, 22 Jul 2025 19:00:14 -0700
From: Jakub Kicinski <kuba@...nel.org>
To: Stanislav Fomichev <sdf@...ichev.me>
Cc: netdev@...r.kernel.org, davem@...emloft.net, edumazet@...gle.com,
pabeni@...hat.com, dsahern@...nel.org, andrew+netdev@...n.ch,
horms@...nel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH net 2/2] net: Warn when overriding referenced dst entry
On Tue, 22 Jul 2025 14:02:56 -0700 Stanislav Fomichev wrote:
> Add WARN_ON_ONCE with CONFIG_NET_DEBUG to warn on overriding referenced
> dst entries. This should get a better signal than tracing leaked
> objects from kmemleak.
Looks like we're tripping the severe nastiness in icmp.c:
/* Ugh! */
orefdst = skb_in->_skb_refdst; /* save old refdst */
skb_dst_set(skb_in, NULL);
err = ip_route_input(skb_in, fl4_dec.daddr, fl4_dec.saddr,
dscp, rt2->dst.dev) ? -EINVAL : 0;
dst_release(&rt2->dst);
rt2 = skb_rtable(skb_in);
skb_in->_skb_refdst = orefdst; /* restore old refdst */
There's more of these around. I think we need a new helper for
"saving" and "restoring" the refdst? Either way, I reckon the
patch with the check belongs in net-next.
> diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
> index 5520524c93bf..c89931ac01e5 100644
> --- a/include/linux/skbuff.h
> +++ b/include/linux/skbuff.h
> @@ -1159,6 +1159,12 @@ static inline struct dst_entry *skb_dst(const struct sk_buff *skb)
> return (struct dst_entry *)(skb->_skb_refdst & SKB_DST_PTRMASK);
> }
>
> +static inline void skb_dst_check(struct sk_buff *skb)
skb_dst_check_unset() ? Right now we assume the caller will override.
Or will there be more conditions added?
> +{
> + DEBUG_NET_WARN_ON_ONCE(skb_dst(skb) &&
> + !(skb->_skb_refdst & SKB_DST_NOREF));
Why not
DEBUG_NET_WARN_ON_ONCE(skb->_skb_refdst & SKB_DST_PTRMASK);
?
--
pw-bot: cr
Powered by blists - more mailing lists