From: Ido Schimmel <idosch@nvidia.com>
To: Chengfeng Ye <nicoyip.dev@gmail.com>
Cc: David Ahern <dsahern@kernel.org>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>,
Stefano Brivio <sbrivio@redhat.com>,
Sabrina Dubroca <sd@queasysnail.net>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH net v3] ipv4: fix use-after-free in fib_nhc_update_mtu()
Date: Sun, 9 Aug 2026 10:12:06 +0300 [thread overview]
Message-ID: <20260809071206.GA2297836@shredder> (raw)
In-Reply-To: <20260807181710.1178747-1-nicoyip.dev@gmail.com>
On Sat, Aug 08, 2026 at 02:17:10AM +0800, Chengfeng Ye wrote:
> fib_nhc_update_mtu() walks the nexthop exception table under RTNL, but
> RTNL does not serialize this walk with PMTU exception updates. The walk
> uses rcu_dereference_protected() with a constant true condition without
> holding fnhe_lock.
>
> The following interleaving can therefore occur:
>
> CPU 0 CPU 1
> fib_nhc_update_mtu() update_or_create_fnhe()
> load fnhe spin_lock_bh(&fnhe_lock)
> fnhe_remove_oldest()
> unlink fnhe
> kfree_rcu(fnhe, rcu)
> <quiescent state>
> access fnhe after grace period
>
> KASAN reported:
>
> BUG: KASAN: slab-use-after-free in fib_nhc_update_mtu+0x3df/0x410
> Read of size 8 at addr ffff888107d49000 by task poc/90
> Call Trace:
> fib_nhc_update_mtu+0x3df/0x410
> fib_sync_mtu+0x7a/0xd0
> fib_netdev_event+0x229/0x3f0
> netif_set_mtu_ext+0x33a/0x570
> dev_set_mtu+0x88/0x120
>
> The same walk updates fnhe_pmtu and fnhe_mtu_locked. These fields form a
> pair and other writers serialize them with fnhe_lock. RCU alone prevents
> reclamation, but would still allow concurrent writers to leave a mixed
> pair.
>
> Walk the table under RCU and acquire fnhe_lock only while updating each
> exception. RCU keeps the current entry alive while the short critical
> section serializes its paired PMTU fields. This avoids holding the global
> lock while scanning all 2048 buckets for every nexthop.
>
> Fixes: af7d6cce5369 ("net: ipv4: update fnhe_pmtu when first hop's MTU changes")
> Cc: stable@vger.kernel.org
> Suggested-by: Ido Schimmel <idosch@nvidia.com>
> Signed-off-by: Chengfeng Ye <nicoyip.dev@gmail.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
prev parent reply other threads:[~2026-08-09 7:12 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-07 18:17 [PATCH net v3] ipv4: fix use-after-free in fib_nhc_update_mtu() Chengfeng Ye
2026-08-09 7:12 ` Ido Schimmel [this message]
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=20260809071206.GA2297836@shredder \
--to=idosch@nvidia.com \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=nicoyip.dev@gmail.com \
--cc=pabeni@redhat.com \
--cc=sbrivio@redhat.com \
--cc=sd@queasysnail.net \
--cc=stable@vger.kernel.org \
/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