From: Jakub Kicinski <kuba@kernel.org>
To: andrea.mayer@uniroma2.it
Cc: Jakub Kicinski <kuba@kernel.org>,
netdev@vger.kernel.org, davem@davemloft.net, edumazet@google.com,
pabeni@redhat.com, horms@kernel.org, dsahern@kernel.org,
david.lebrun@uclouvain.be, stefano.salsano@uniroma2.it,
paolo.lungaroni@uniroma2.it, nicolas.dichtel@6wind.com,
justin.iurman@gmail.com, linux-kernel@vger.kernel.org,
shuah@kernel.org, linux-kselftest@vger.kernel.org
Subject: Re: [PATCH net v3 1/2] seg6: separate dst_cache for input and output paths in seg6 lwtunnel
Date: Tue, 7 Apr 2026 20:20:38 -0700 [thread overview]
Message-ID: <20260408032039.314762-1-kuba@kernel.org> (raw)
In-Reply-To: <20260404004405.4057-2-andrea.mayer@uniroma2.it>
This is an AI-generated review of your patch. The human sending this
email says "Seems orthogonal but also legit"
---
seg6: separate dst_cache for input and output paths in seg6 lwtunnel
This commit splits the shared seg6 lwtunnel dst_cache into separate input
and output caches to prevent blind reuse across different routing contexts.
> diff --git a/net/ipv6/seg6_iptunnel.c b/net/ipv6/seg6_iptunnel.c
> index 3e1b9991131a2..d6a0f7df90807 100644
> --- a/net/ipv6/seg6_iptunnel.c
> +++ b/net/ipv6/seg6_iptunnel.c
[ ... ]
> @@ -504,7 +505,7 @@ static int seg6_input_core(struct net *net, struct sock *sk,
> /* cache only if we don't create a dst reference loop */
> if (!dst->error && lwtst != dst->lwtstate) {
> local_bh_disable();
> - dst_cache_set_ip6(&slwt->cache, dst,
> + dst_cache_set_ip6(&slwt->cache_input, dst,
> &ipv6_hdr(skb)->saddr);
> local_bh_enable();
> }
This code appears to cache the dst entry resolved just prior by calling
ip6_route_input(skb).
Does ip6_route_input() assign a NOREF dst to the skb?
If so, this dst is protected only by RCU. If the underlying route is
concurrently deleted, its refcount can drop to zero. When
dst_cache_set_ip6() is called, it attempts to use dst_hold(dst).
If the refcount is already zero, dst_hold() will warn and skip incrementing
the refcount, but dst_cache_set_ip6() will still store the pointer.
Could this cause the cache to hold a dangling pointer, leading to a
use-after-free once the RCU grace period expires?
Should this path use skb_dst_force(skb) or dst_hold_safe(dst) to safely
upgrade the dst to a refcounted reference before it is cached?
--
pw-bot: cr
next prev parent reply other threads:[~2026-04-08 3:20 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-04 0:44 [PATCH net v3 0/2] seg6: fix dst_cache sharing in seg6 lwtunnel Andrea Mayer
2026-04-04 0:44 ` [PATCH net v3 1/2] seg6: separate dst_cache for input and output paths " Andrea Mayer
2026-04-08 3:20 ` Jakub Kicinski [this message]
2026-04-04 0:44 ` [PATCH net v3 2/2] selftests: seg6: add test for dst_cache isolation " Andrea Mayer
2026-04-08 3:30 ` [PATCH net v3 0/2] seg6: fix dst_cache sharing " patchwork-bot+netdevbpf
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=20260408032039.314762-1-kuba@kernel.org \
--to=kuba@kernel.org \
--cc=andrea.mayer@uniroma2.it \
--cc=davem@davemloft.net \
--cc=david.lebrun@uclouvain.be \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=justin.iurman@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=nicolas.dichtel@6wind.com \
--cc=pabeni@redhat.com \
--cc=paolo.lungaroni@uniroma2.it \
--cc=shuah@kernel.org \
--cc=stefano.salsano@uniroma2.it \
/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