From: Ido Schimmel <idosch@nvidia.com>
To: Zhou Qiuyue <n0ps1edzz@gmail.com>
Cc: netdev@vger.kernel.org, David Ahern <dsahern@kernel.org>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>,
Hangbin Liu <hangbin.liu@linux.dev>,
linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH net] ipv4: route: fix use-after-free in ipv4_confirm_neigh()
Date: Wed, 25 Nov 2026 21:04:03 +0200 [thread overview]
Message-ID: <20261125190403.GA466528@shredder> (raw)
In-Reply-To: <20261123133000.2.n0ps1edzz@gmail.com>
On Mon, Nov 23, 2026 at 01:30:00PM +0800, Zhou Qiuyue wrote:
>
> ipv4_confirm_neigh() loads dst->dev with dst_dev() and hands the
> resulting net_device to the neighbour lookup. The load is outside any
> RCU read-side section: __ipv4_confirm_neigh() does take rcu_read_lock(),
> but only after the pointer has been read, which is too late to protect
> it. The load is only a READ_ONCE(); it does not pin the device.
> udp_sendmsg(), raw_sendmsg() and ping_v4_sendmsg() reach
> dst_confirm_neigh() when sendmsg() is issued with MSG_CONFIRM and
> MSG_PROBE, without holding RCU or a net_device reference.
>
> The first stale field read is dev_net(dev) in arp_table(), reached from
> the neighbour lookup. Route teardown drops the reference the dst held on
> the device: dst_dev_put() does it for dsts removed from the fib tree, and
> rt_flush_dev() does it for uncached routes. Both replace dst->dev with
> blackhole_netdev, so a reader that loaded the old pointer just before the
> replacement can dereference a freed net_device.
>
> Take rcu_read_lock(), load the device with dst_dev_rcu(), and keep the
> section through the gateway dispatch and __ipv4_confirm_neigh().
[...]
> Fixes: 95c47f9cf5e0 ("ipv4: call dst_dev_put() properly")
> Cc: stable@vger.kernel.org
> Signed-off-by: Zhou Qiuyue <n0ps1edzz@gmail.com>
Should be posted together with the IPv6 patches:
https://lore.kernel.org/netdev/20261125190113.GA421469@shredder/
pw-bot: cr
prev parent reply other threads:[~2026-11-25 19:04 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-23 5:30 [PATCH net] ipv4: route: fix use-after-free in ipv4_confirm_neigh() Zhou Qiuyue
2026-11-23 7:02 ` netdev-bot+sinfo
2026-11-25 19:04 ` 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=20261125190403.GA466528@shredder \
--to=idosch@nvidia.com \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@kernel.org \
--cc=hangbin.liu@linux.dev \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=n0ps1edzz@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.