* Re: [PATCH net] net/mlx5: Fix divide by zero when a function has no completion EQs
2026-12-02 13:04 [PATCH net] net/mlx5: Fix divide by zero when a function has no completion EQs Tariq Toukan
@ 2026-12-02 13:08 ` netdev-bot+sinfo
2026-12-03 13:28 ` Dragos Tatulea
2026-12-03 13:05 ` sashiko-bot
2026-12-03 13:13 ` netdev-bot+sashiko
2 siblings, 1 reply; 5+ messages in thread
From: netdev-bot+sinfo @ 2026-12-02 13:08 UTC (permalink / raw)
To: Tariq Toukan
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
netdev, Paolo Abeni, Willem de Bruijn, Dragos Tatulea,
Gal Pressman, Jiri Pirko, Leon Romanovsky, linux-rdma, Mark Bloch,
Parav Pandit, Saeed Mahameed, Shahar Shitrit, Shay Drory,
Yishai Hadas
Hi!
This is an automated message. This series looks like a fix, but its
commit messages seem to be missing some information:
- How the issue was discovered, e.g. hit in production, hit during
development, syzbot report, manual code inspection, LLM or static
analysis tool scan.
- Whether the issue was actually triggered, or is only theoretical
(e.g. found by LLM and not proven at runtime). If it was triggered
please include the symptoms, like the stack trace or kernel messages.
- What hardware the change was tested on. For driver fixes please
mention the device (and if relevant firmware version) used for
testing, or say that the change was not tested on real hardware.
Please do not repost the series just to address the above. Instead,
reply to this email with the missing information, so that reviewers
can take it into account.
*IMPORTANT*: If you do repost (for other reasons) - please include
the relevant info in the cover letter or commit messages.
--
The evaluation is done by an LLM so it may be wrong, if you think
that is the case please reply and explain.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net] net/mlx5: Fix divide by zero when a function has no completion EQs
2026-12-02 13:08 ` netdev-bot+sinfo
@ 2026-12-03 13:28 ` Dragos Tatulea
0 siblings, 0 replies; 5+ messages in thread
From: Dragos Tatulea @ 2026-12-03 13:28 UTC (permalink / raw)
To: netdev-bot+sinfo, Tariq Toukan
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
netdev, Paolo Abeni, Willem de Bruijn, Gal Pressman, Jiri Pirko,
Leon Romanovsky, linux-rdma, Mark Bloch, Parav Pandit,
Saeed Mahameed, Shahar Shitrit, Shay Drory, Yishai Hadas
On Wed, Dec 02, 2026 at 01:08:26PM +0000, netdev-bot+sinfo@kernel.org wrote:
> Hi!
>
> This is an automated message. This series looks like a fix, but its
> commit messages seem to be missing some information:
>
> - How the issue was discovered, e.g. hit in production, hit during
> development, syzbot report, manual code inspection, LLM or static
> analysis tool scan.
>
Found during AI review of a feature.
> - Whether the issue was actually triggered, or is only theoretical
> (e.g. found by LLM and not proven at runtime). If it was triggered
> please include the symptoms, like the stack trace or kernel messages.
>
Was not triggered.
> - What hardware the change was tested on. For driver fixes please
> mention the device (and if relevant firmware version) used for
> testing, or say that the change was not tested on real hardware.
>
Although change issue was not triggered, change was tested against CX7.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net] net/mlx5: Fix divide by zero when a function has no completion EQs
2026-12-02 13:04 [PATCH net] net/mlx5: Fix divide by zero when a function has no completion EQs Tariq Toukan
2026-12-02 13:08 ` netdev-bot+sinfo
@ 2026-12-03 13:05 ` sashiko-bot
2026-12-03 13:13 ` netdev-bot+sashiko
2 siblings, 0 replies; 5+ messages in thread
From: sashiko-bot @ 2026-12-03 13:05 UTC (permalink / raw)
To: Tariq Toukan; +Cc: linux-rdma
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] net/mlx5: checking max_comp_eqs in alloc_rmap() aborts probe or
misses SFs and !CONFIG_RFS_ACCEL
--
commit f8141098642e0cdde28ad4ddb5d332f35642c1ce
Author: Yishai Hadas <yishaih@nvidia.com>
net/mlx5: Fix divide by zero when a function has no completion EQs
This commit returns -EINVAL from alloc_rmap() when eq_table->max_comp_eqs
is zero to avoid passing zero to alloc_irq_cpu_rmap().
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eq.c b/drivers/net/ethernet/mellanox/mlx5/core/eq.c
> index d11ec263d53c9..0795ee24ad7f2 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/eq.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/eq.c
> @@ -930,6 +930,9 @@ static int alloc_rmap(struct mlx5_core_dev *mdev)
> if (mlx5_core_is_sf(mdev))
> return 0;
>
> + if (!eq_table->max_comp_eqs)
> + return -EINVAL;
> +
> eq_table->rmap = alloc_irq_cpu_rmap(eq_table->max_comp_eqs);
> if (!eq_table->rmap)
> return -ENOMEM;
[Severity: High]
Should eq_table->max_comp_eqs == 0 fail device probe or only skip aRFS
rmap allocation, and why is it checked only here?
mlx5_eq_table_create() treats any error from alloc_rmap() as fatal,
tearing down the control EQs and aborting mlx5_load():
drivers/net/ethernet/mellanox/mlx5/core/eq.c:mlx5_eq_table_create() {
...
err = alloc_rmap(dev);
if (err) {
mlx5_core_err(dev, "Failed to allocate rmap\n");
goto err_rmap;
}
return 0;
err_rmap:
destroy_async_eqs(dev);
...
}
If the function is meant to keep running with only control EQs and
without aRFS (where rmap consumers already tolerate a NULL rmap),
returning -EINVAL here aborts the entire mlx5_core load when
CONFIG_RFS_ACCEL=y.
Conversely, if probing with zero completion EQs is not supported and is
intended to fail mlx5_eq_table_create(), placing the check inside the
CONFIG_RFS_ACCEL version of alloc_rmap() after the mlx5_core_is_sf(mdev)
return misses both !CONFIG_RFS_ACCEL builds and SFs (which also wire up
mlx5_devlink_port_fn_max_io_eqs_set()). In those cases,
mlx5_eq_table_create() succeeds with max_comp_eqs == 0, which still
triggers a divide-by-zero in callers such as mlx5vf_create_cq()
(raw_smp_processor_id() % mlx5_comp_vectors_max(mdev)) or
ib_cq_pool_get() when ib_dev.num_comp_vectors is set to 0.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261202130435.3442321-1-tariqt@nvidia.com?part=1
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH net] net/mlx5: Fix divide by zero when a function has no completion EQs
2026-12-02 13:04 [PATCH net] net/mlx5: Fix divide by zero when a function has no completion EQs Tariq Toukan
2026-12-02 13:08 ` netdev-bot+sinfo
2026-12-03 13:05 ` sashiko-bot
@ 2026-12-03 13:13 ` netdev-bot+sashiko
2 siblings, 0 replies; 5+ messages in thread
From: netdev-bot+sashiko @ 2026-12-03 13:13 UTC (permalink / raw)
To: tariqt
Cc: andrew+netdev, davem, edumazet, kuba, netdev, pabeni, willemb,
dtatulea, gal, jiri, leon, linux-rdma, mbloch, parav, saeedm,
shshitrit, shayd, yishaih
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 1 · Medium: 0 · Low: 1
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] The fix is incomplete: a function with zero completion EQs can
still load, and the divide by zero is still reachable.
- [Low] The new -EINVAL in alloc_rmap() (eq.c:933-934) does more than
disable aRFS.
--
net/mlx5: Fix divide by zero when a function has no completion EQs
This patch adds a zero check on max_comp_eqs to the aRFS version of
alloc_rmap(). The check stops a divide by zero in alloc_irq_cpu_rmap() when
an administrator sets max_io_eqs to 0 and ODP is enabled. For non-SF
functions, alloc_rmap() now returns -EINVAL in that case.
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eq.c b/drivers/net/ethernet/mellanox/mlx5/core/eq.c
> index d11ec263d53c9..0795ee24ad7f2 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/eq.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/eq.c
> @@ -930,6 +930,9 @@ static int alloc_rmap(struct mlx5_core_dev *mdev)
> if (mlx5_core_is_sf(mdev))
> return 0;
>
> + if (!eq_table->max_comp_eqs)
> + return -EINVAL;
[Severity: High]
Does this check close the divide by zero for every function that has
zero completion EQs?
The check is only compiled into the CONFIG_RFS_ACCEL variant of
alloc_rmap(). The other stub still accepts the zero value:
#else
static int alloc_rmap(struct mlx5_core_dev *mdev) { return 0; }
The check also comes after the mlx5_core_is_sf() early return, so SFs
never reach it, whatever the build config.
With max_io_eqs=0 and CONFIG_INFINIBAND_ON_DEMAND_PAGING=y, get_num_eqs()
computes max_num_eqs_24b (0 + 4) minus MLX5_MAX_ASYNC_EQS (4), which is 0.
mlx5_eq_table_create() still succeeds for SFs on any build, and for
PFs/VFs on CONFIG_RFS_ACCEL=n builds. The exported mlx5_comp_vectors_max()
then returns 0 to callers that divide by it:
drivers/vfio/pci/mlx5/cmd.c:mlx5vf_create_cq() {
...
vector = raw_smp_processor_id() % mlx5_comp_vectors_max(mdev);
...
}
Here mdev is the PF core dev returned by mlx5_vf_get_core_dev(). This code
runs when VFIO dirty page tracking starts. For example, the ECPF admin sets
max_io_eqs=0 for the host PF, and the host kernel is built without
CONFIG_RFS_ACCEL. The host kernel would then hit a divide error here.
mlx5_ib does the same in drivers/infiniband/hw/mlx5/main.c:
dev->ib_dev.num_comp_vectors = mlx5_comp_vectors_max(mdev);
That value then reaches ib_cq_pool_get(), which is used by nvme-rdma,
nvmet-rdma, iser, isert and srpt:
vector = comp_vector_hint % num_comp_vectors;
It also reaches ipoib_transport_dev_init() in legacy IPoIB:
cq_attr.comp_vector = req_vec % priv->ca->num_comp_vectors;
Would it be better to reject max_comp_eqs == 0 where it is set, in
mlx5_eq_table_create() or get_num_eqs()? That would cover every config and
every user of mlx5_comp_vectors_max(). The check in this patch only
protects alloc_irq_cpu_rmap(), on aRFS builds, for non-SFs.
[Severity: Low]
The commit message says:
Handle the zero case by returning an error for non SFs: aRFS
can't function without it.
This -EINVAL does more than disable aRFS. mlx5_eq_table_create() treats it
as fatal and destroys the async EQs:
err = alloc_rmap(dev);
if (err) {
mlx5_core_err(dev, "Failed to allocate rmap\n");
goto err_rmap;
}
mlx5_load() then aborts with "Failed to create EQs". As a result, a VF or
host PF with max_io_eqs=0 no longer loads at all. Meanwhile,
mlx5_devlink_port_fn_max_io_eqs_set() still accepts 0 with only an
overflow check.
Failing the load seems reasonable, because returning 0 here would leave
max_comp_eqs == 0 visible to the mlx5_comp_vectors_max() users mentioned
above.
Could the commit message say that the whole function fails to load? And
could the error message be more specific than "Failed to allocate rmap"?
Nothing actually failed to allocate here; the real cause is the devlink
max_io_eqs setting.
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261202130435.3442321-1-tariqt%40nvidia.com
^ permalink raw reply [flat|nested] 5+ messages in thread