Article View: linux.kernel.netdev
Article #18450Re: [PATCH net-next V2 09/10] net/mlx5: LAG, drop MLX5_MAX_PORTS scratch array from device rescan
From: netdev-bot+sashiko
Date: Wed, 18 Nov 2026 10:31
Date: Wed, 18 Nov 2026 10:31
136 lines
13208 bytes
13208 bytes
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 1 · Medium: 0 · Low: 0
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [High] In mlx5_lag_rescan_devices_locked_filter()
(drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c), this patch…
--
net/mlx5: LAG, drop MLX5_MAX_PORTS scratch array from device rescan
This commit removes the devs[MLX5_MAX_PORTS] array from
mlx5_lag_rescan_devices_locked_filter(). The post-unlock rescan loop now
walks the LAG members again with mlx5_lag_for_each(). The commit message
describes this as having no functional change.
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c b/drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c
> index a7b12353b7225..3e88b3f51612e 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c
[ ... ]
> @@ -1356,12 +1354,16 @@ static void mlx5_lag_rescan_devices_locked_filter(struct mlx5_lag *ldev,
> fn->dev->priv.flags &= ~MLX5_PRIV_FLAGS_DISABLE_IB_ADEV;
> else
> fn->dev->priv.flags |= MLX5_PRIV_FLAGS_DISABLE_IB_ADEV;
> - devs[num_devs++] = fn->dev;
> }
>
> mlx5_lag_drop_lock_for_reps(ldev, filter);
> - for (i = 0; i < num_devs; i++)
> - mlx5_rescan_drivers_locked(devs[i]);
> + mlx5_lag_for_each(i, 0, ldev, filter) {
> + fn = mlx5_lag_fn(ldev, i);
> + if (fn->dev->priv.flags & MLX5_PRIV_FLAGS_DISABLE_ALL_ADEV)
> + continue;
> +
> + mlx5_rescan_drivers_locked(fn->dev);
> + }
[Severity: High]
This loop now walks ldev->fns after mlx5_lag_drop_lock_for_reps() has
released ldev->lock. Can a concurrent SD member removal free a lag_fn
while the walk is in progress?
On each step, mlx5_get_next_lag_func() reads xarray entries and fn->dev.
mlx5_lag_fn() then does an xa_load(), and the loop dereferences
fn->dev->priv.flags. The only thing guarding membership while the lock is
dropped is ldev->mode_changes_in_progress. The comment in
mlx5_lag_drop_lock_for_reps() says:
/* Keep PF membership stable while ldev->lock is dropped. Device add
* and remove paths observe mode_changes_in_progress and retry.
*/
The SD paths in lib/sd.c don't appear to check that counter, though.
sd_lag_cleanup() takes the lock directly:
mutex_lock(&ldev->lock);
mlx5_sd_for_each_secondary(i, primary, pos)
mlx5_ldev_remove_mdev(ldev, pos);
mlx5_ldev_remove_mdev() then frees the entry right away, with no RCU
deferral:
fn->dev = NULL;
dev->priv.lag = NULL;
xa_erase(&ldev->fns, fn->idx);
kfree(fn);
sd_lag_cleanup() is serialized only by sd->devcom. For
MLX5_LAG_FILTER_ALL, this function runs under the HCA devcom instead.
mlx5_do_bond_work() takes only the HCA devcom trylock plus ldev->lock, and
not mlx5_mpesw_sd_devcoms_lock(). It reaches this function as follows:
mlx5_do_bond_work()
mlx5_do_bond()
mlx5_lag_shared_fdb_create(ldev, ..., MLX5_LAG_MODE_SRIOV, 0)
mlx5_lag_remove_devices_filter(ldev, MLX5_LAG_FILTER_ALL)
mlx5_lag_rescan_devices_locked_filter()
mlx5_disable_lag() -> mlx5_lag_shared_fdb_destroy(ldev, 0) reaches it the
same way. Group id 0 maps to MLX5_LAG_FILTER_ALL, which matches every
member, SD secondaries included.
At the same time, removing an SD member's eth aux driver can run:
mlx5e_remove() / mlx5e_suspend()
mlx5_sd_cleanup()
sd_lag_cleanup()
mlx5_ldev_remove_mdev()
This removal can come from a sysfs unbind of mlx5_core.eth.N. It can also
come from a reload of an SD secondary whose hca_devcom_comp is NULL or in a
different component. Neither case holds the HCA devcom that the bond work
holds.
If that happens, mlx5_get_next_lag_func() could read fn->dev from a freed
lag_fn. mlx5_lag_fn() could also return NULL after xa_erase(), and the
loop would then dereference it.
The old loop touched only the devs[] core_dev pointers once the lock was
dropped. Those pointers stay valid across an aux unbind, so lag_fn and
xarray state was never accessed without the lock.
A similar question applies to sd_lag_init(), which also takes ldev->lock
without checking mode_changes_in_progress and calls mlx5_ldev_add_mdev().
Could the second loop then rescan a newly added member whose
MLX5_PRIV_FLAGS_DISABLE_IB_ADEV flag the first loop never updated?
Given the above, is the "no functional change" statement in the commit
message accurate?
Would it be safer to keep a snapshot taken under the lock? For example, a
dynamically sized array, or a reference on each core_dev collected before
mlx5_lag_drop_lock_for_reps().
As far as I can tell, the last patch in the series doesn't touch this
function or the SD paths, so this would still be present at the end of the
series.
> mlx5_lag_retake_lock_after_reps(ldev);
> }
>
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261116103010.1129666-1-tariqt%40nvidia.com
Technical Details
Message-ID:
<179499791924.3136.16901930891335328702@kernel.org>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-366043-linux-kernel-netdev=dewy.ruReferences:
<20261116103010.1129666-10-tariqt@nvidia.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-366043-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net-next V2 09/10] net/mlx5: LAG, drop MLX5_MAX_PORTS scratch array from device rescan Date: Wed, 18 Nov 2026 10:31:59 +0000 Organization: Usenet Network Message-ID: <179499791924.3136.16901930891335328702@kernel.org> References: <20261116103010.1129666-10-tariqt@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="2569505"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:LEOjRp6C0mWaNUFE4Fv/fnl8Exg= sha256:KUaa1iogEdprpgRekhLiMQJa6oeWnNtuRlsIE/19QTM= sha1:Y3pXpU214OkxqpEyodiA3nDnpEI= sha256:5ZIgRD/Uxlpalg1TlF2JOa4j+ZlRDVRg0Pg6YLFwanQ= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 1D420115250; Wed, 18 Nov 2026 13:32:39 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.4 X-Spam-Status: No, score=-3.4 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id LhqlCgZprYcS; Wed, 18 Nov 2026 13:32:34 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-366043-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id 551B4115246; Wed, 18 Nov 2026 13:32:26 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id EAC5343FC1; Wed, 18 Nov 2026 10:32:08 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1794997921; b=t/XM/MmSMsU9A5UwDp4E/iu0KGfhTQ/9ewPt9RtSOZkRd6P1jhwpuPOAqsiDc2i9vm1h JEFoMv+teRKhKwj2wcU5VvoFFsPrre6trBKcaAJ6Tf/bP4EGxadsSNQPxuMDd79VarMq6 gJ9yHxO55XvV9tRE8qEoMm39C/IuQxp0uXlwgLtBNf2LXCWDeLmfXun6apGBboT/N0LbD NtgHCS/tPrtZ+zS6Is74ry03mF2+ZTgOjP7Wt77mOdTQMI+/6ZwZwom+tjw9R5AxQQ23b szEOIES5GajGcHroan0hAMfACDRbhwD/TmhkDiTFLBoMAoQpfPDMpmCXkFTuxo3m1Cg== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794997921; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=vUDaTvuHrh3mVBGV0XI8KLL+YVaBFwQcVx5vyMv/fyk=; b=XN0cBYUCKMorYGtyeyqj3kGx+eqxXNKsphPnNy7yidlCbrhDo5rUVcj7rHpvBZUBqvNU lit+gPM15CKUM7WXSYhH7ZjOlemwCYJr0qA5Wzlf7I9u4UE2ggWGAwXk8a+iCQTv6IEFP XQa7uzJvsDv3d/IW3kfHkxe/r4v3UT5ZVc741io/2G20sh/0868+HdJ4d5DIoxQzxLlgh pzWAn8hDcE2BGxYeYLQeV32nXRrCmLvir5IJwpG2ELMGXuhHKZ4OblIY4SoUMkeEEI3YQ WdtHLSblBx+rsiqBbEX2vRuVRMH+oR/nwNZ+tb/lBj5WQ/YI32uRDPphkODLHTFa5EQ== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=T1K8suaz; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B1BB560A2610; Wed, 18 Nov 2026 10:32:01 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=T1K8suaz X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794997920; b=qBqCqWGwSuQR5aJiC9Z1VVRhIgS5lKmSY87J7VfsR5x8eaT3aC4t/G62NAcXi5ihzWFG OZSfxHyNUMmS2xxiwlKSb4FbC70cTnGtXyzCotax+F/o1w58o2QtpILUjAitEthXMYLeN 7cd2vH9/g7vNLRcobjWtBNAzdKz8PG4j8uSVLB95HCDqYH8wGcCPIXVuSkB/rWh94ddrJ THkxGJVCU6MMcR8QfQsc6kruc8b1F2rhm18BI2wq9L7Xsk6GOjejQs+CeI8Wss6qDZmtT jnTlq+vil3NmM5gh3vUaegBfx3ifve1kU38cWor0RoCopLy1p6NayoAodqqXapGYUBA== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794997920; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=vUDaTvuHrh3mVBGV0XI8KLL+YVaBFwQcVx5vyMv/fyk=; b=n2cDAzeWvk34IWBz5/qI87GWmooJz44BnwhNKCbcSdopt6QzUSg9tOF6Z1h7gaWsRpiU lfAChPxhNBvUfyroAN1ZPQUf6mwEamhXAfVjWsIkgzCJ7UZhjwAD+00lY49QPTI8tRzsp L1UNfYuPaXPugqrkS58xbUJtTa9eAnPHEvskIag5sn47k0isDbRVgt7yqz11ZPHhID362 3acVwSetmgumDKw75/ANxZXFdO4hTZd5Sc01OpVXn7+uW22rC5RcblHkzHK0EgwjICObT wUjI4R1dLcAK6Cj72rWcfu6tlyxc+wRY3ALDgoHVW59LuHaz4dOeVdRwb4uHsFThf7A== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=T1K8suaz; arc=none smtp.remote-ip=100.103.45.18 X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D544B60A2631; Wed, 18 Nov 2026 10:32:00 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id A186E1F000CF; Wed, 18 Nov 2026 10:31:59 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1794997920; bh=vUDaTvuHrh3mVBGV0XI8KLL+YVaBFwQcVx5vyMv/fyk=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=T1K8suazXDmkT4riBj91hegerc2qOlLW/WEaQImrD0tHjRrQ8fc01GVHxt5rBk4Wf kkRV/jhnf5bfYz2aqHVO+RBy5/CuuUU7/6TjczXvxSk+i5zyO4QZD/qRCjDx9x2QlZ iXoKfeB5sNebEjiI6/L24gcWYwQ7bujKzZh759winvp9YzGQF+3xjnIz06ctsv+3o3 P+C6ksxX7kWscwZYy6bGy0PPphmAl71vF9x+NfcrLtOIdwFKWwoyDVHQ96oi5MGRQk JCoofy4QLZVMMLBg9c6U/J+Kr7wIifwZEnFBbtMU2lF/JmF9b3i70omzfXbbwEhP1D 6YhetRzj1e9CQ== X-Cc: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, netdev@vger.kernel.org, pabeni@redhat.com, cjubran@nvidia.com, cratiu@nvidia.com, gal@nvidia.com, leon@kernel.org, linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org, mbloch@nvidia.com, moshe@nvidia.com, ohartoov@nvidia.com, phaddad@nvidia.com, saeedm@nvidia.com, shayd@nvidia.com, udar@nvidia.com X-In-Reply-To: <20261116103010.1129666-10-tariqt@nvidia.com> X-sashiko-severity: High X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list