Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: kuniyu@google.com
Cc: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com,
	kuba@kernel.org, pabeni@redhat.com, dsahern@kernel.org,
	idosch@nvidia.com, horms@kernel.org, kuni1840@gmail.com,
	netdev@vger.kernel.org, razor@blackwall.org
Subject: Re: [PATCH v6 net-next 09/15] ipv6: Replace &nd_tbl with nd_table(net).
Date: Fri, 04 Sep 2026 03:09:59 +0000	[thread overview]
Message-ID: <178849139948.4131868.2733291067982297494@kernel.org> (raw)
In-Reply-To: <20260902203722.926528-10-kuniyu@google.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider:

Critical: 1 · High: 0 · Medium: 0 · Low: 0

- [Critical] Calling `nd_table(net)` before `inet6_init()` executes
  results in a NULL pointer dereference during driver probe.

--

> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/rep/neigh.c b/drivers/net/ethernet/mellanox/mlx5/core/en/rep/neigh.c
> --- a/drivers/net/ethernet/mellanox/mlx5/core/en/rep/neigh.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/rep/neigh.c
> @@ -17,26 +17,27 @@
>  #include "fs_core.h"
>  #include "diag/en_rep_tracepoint.h"
>  
> -static unsigned long mlx5e_rep_ipv6_interval(void)
> +static unsigned long mlx5e_rep_ipv6_interval(struct net *net)
>  {
>  	if (IS_ENABLED(CONFIG_IPV6) && ipv6_mod_enabled())
> -		return NEIGH_VAR(&nd_tbl.parms, DELAY_PROBE_TIME);
> +		return NEIGH_VAR(&nd_table(net)->parms, DELAY_PROBE_TIME);
>  
>  	return ~0UL;
>  }
>  
>  static void mlx5e_rep_neigh_update_init_interval(struct mlx5e_rep_priv *rpriv)
>  {
> -	unsigned long ipv6_interval = mlx5e_rep_ipv6_interval();
>  	struct net_device *netdev = rpriv->netdev;
>  	struct net *net = dev_net(netdev);
>  	unsigned long ipv4_interval;
> +	unsigned long ipv6_interval;
>  	struct neigh_table *tbl;
>  	struct mlx5e_priv *priv;
>  
>  	priv = netdev_priv(netdev);
>  	tbl = arp_table(net);
>  	ipv4_interval = NEIGH_VAR(&tbl->parms, DELAY_PROBE_TIME);
> +	ipv6_interval = mlx5e_rep_ipv6_interval(net);
>  
>  	rpriv->neigh_update.min_interval = min_t(unsigned long, ipv6_interval, ipv4_interval);
>  	mlx5_fc_update_sampling_interval(priv->mdev, rpriv->neigh_update.min_interval);

[Severity: Critical]
Unlike &nd_tbl, which is a statically allocated object that is
valid from the very first instruction of the kernel, nd_table(net)
reads net->neigh_tables[NEIGH_ND_TABLE], which is only populated
once ndisc_init()/inet6_init() has run.

Both of the new dereferences here are on driver probe paths that can
run before that point: mlx5e_rep_ipv6_interval() (via
mlx5e_rep_neigh_update_init_interval()) and
mlxsw_sp_router_neighs_update_interval_init() take
&nd_table(net)->parms and feed it to NEIGH_VAR(), so a NULL table
turns into a dereference of offsetof(struct neigh_table, parms)
rather than a benign zero. For built-in drivers, drivers/ is linked
before net/, and both the driver module_init() and inet6_init() are
device_initcall(), so the driver can win that race and oops during
boot. Note that ipv6_mod_enabled() does not help here: it only
reflects the ipv6.disable boot parameter and returns true well
before the nd table exists.

The same concern applies to any other conversion in this series that
can be reached from driver probe or from a netdev notifier that runs
before inet6_init().

How do you want to handle this? Either nd_table(net) needs to be
safe to call before ndisc_init() (e.g. by allocating the per-netns
slots earlier, in a pernet subsys registered ahead of the drivers),
or these callers need an explicit NULL check on the returned table
before touching ->parms. Please spell out the ordering guarantee you
are relying on in the changelog, since it is no longer obvious once
&nd_tbl becomes an indirection through struct net.

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260902203722.926528-1-kuniyu%40google.com

  reply	other threads:[~2026-09-04  3:10 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-02 20:36 [PATCH v6 net-next 00/15] neighbour: Namespacify arp_tbl and nd_tbl Kuniyuki Iwashima
2026-09-02 20:36 ` [PATCH v6 net-next 01/15] selftest: net: Deflake Periodic GC test in test_neigh.sh Kuniyuki Iwashima
2026-09-04  3:09   ` netdev-bot+sashiko
2026-09-02 20:36 ` [PATCH v6 net-next 02/15] neighbour: Remove __neigh_for_each_release() Kuniyuki Iwashima
2026-09-02 20:36 ` [PATCH v6 net-next 03/15] neighbour: Remove lock dance for neigh_update_{gc,managed}_list() Kuniyuki Iwashima
2026-09-02 20:36 ` [PATCH v6 net-next 04/15] neighbour: Remove unnecessary EXPORT_SYMBOL() Kuniyuki Iwashima
2026-09-02 20:36 ` [PATCH v6 net-next 05/15] neighbour: Remove __rcu from neigh_tables[] Kuniyuki Iwashima
2026-09-02 20:36 ` [PATCH v6 net-next 06/15] neighbour: Store arp_tbl and nd_tbl in net->neigh_tables[] Kuniyuki Iwashima
2026-09-04  3:09   ` netdev-bot+sashiko
2026-09-02 20:36 ` [PATCH v6 net-next 07/15] neighbour: Remove neigh_tables[] Kuniyuki Iwashima
2026-09-02 20:36 ` [PATCH v6 net-next 08/15] ipv4: Replace &arp_tbl with arp_table(net) Kuniyuki Iwashima
2026-09-04  3:09   ` netdev-bot+sashiko
2026-09-02 20:36 ` [PATCH v6 net-next 09/15] ipv6: Replace &nd_tbl with nd_table(net) Kuniyuki Iwashima
2026-09-04  3:09   ` netdev-bot+sashiko [this message]
2026-09-02 20:36 ` [PATCH v6 net-next 10/15] neighbour: Clean up neigh_table_init() and neigh_table_clear() Kuniyuki Iwashima
2026-09-04  3:10   ` netdev-bot+sashiko
2026-09-02 20:36 ` [PATCH v6 net-next 11/15] neighbour: Convert neigh_table.entries to refcount_t Kuniyuki Iwashima
2026-09-04  3:10   ` netdev-bot+sashiko
2026-09-02 20:36 ` [PATCH v6 net-next 12/15] neighbour: Namespacify neigh_tables Kuniyuki Iwashima
2026-09-04  3:10   ` netdev-bot+sashiko
2026-09-02 20:36 ` [PATCH v6 net-next 13/15] neighbour: Don't store net in struct pneigh_entry Kuniyuki Iwashima
2026-09-02 20:36 ` [PATCH v6 net-next 14/15] neighbour: Remove unnecessary net_eq() Kuniyuki Iwashima
2026-09-02 20:36 ` [PATCH v6 net-next 15/15] selftest: net: Specify netns for ip ntable in test_neigh.sh Kuniyuki Iwashima
2026-09-04  3:10   ` netdev-bot+sashiko
2026-09-03 12:46 ` [PATCH v6 net-next 00/15] neighbour: Namespacify arp_tbl and nd_tbl Ido Schimmel

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=178849139948.4131868.2733291067982297494@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=idosch@nvidia.com \
    --cc=kuba@kernel.org \
    --cc=kuni1840@gmail.com \
    --cc=kuniyu@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=razor@blackwall.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