From: Jakub Kicinski <kuba@kernel.org>
To: Stanislav Fomichev <sdf@fomichev.me>
Cc: netdev@vger.kernel.org, davem@davemloft.net, edumazet@google.com,
pabeni@redhat.com, dsahern@kernel.org, andrew+netdev@lunn.ch,
horms@kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net 2/2] net: Warn when overriding referenced dst entry
Date: Tue, 22 Jul 2025 19:00:14 -0700 [thread overview]
Message-ID: <20250722190014.32f00bbb@kernel.org> (raw)
In-Reply-To: <20250722210256.143208-2-sdf@fomichev.me>
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
next prev parent reply other threads:[~2025-07-23 2:00 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-22 21:02 [PATCH net 1/2] vrf: Drop existing dst reference in vrf_ip6_input_dst Stanislav Fomichev
2025-07-22 21:02 ` [PATCH net 2/2] net: Warn when overriding referenced dst entry Stanislav Fomichev
2025-07-23 2:00 ` Jakub Kicinski [this message]
2025-07-23 15:13 ` Stanislav Fomichev
2025-07-23 15:24 ` Jakub Kicinski
2025-07-23 15:30 ` Stanislav Fomichev
2025-07-23 9:09 ` [syzbot ci] Re: vrf: Drop existing dst reference in vrf_ip6_input_dst syzbot ci
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250722190014.32f00bbb@kernel.org \
--to=kuba@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sdf@fomichev.me \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).