* [PATCH net] net: mlx4_en: report the actual RX classification rule count
@ 2026-11-21 0:14 Artemii Mashanov
2026-11-21 0:17 ` netdev-bot+sinfo
2026-11-25 6:51 ` Tariq Toukan
0 siblings, 2 replies; 4+ messages in thread
From: Artemii Mashanov @ 2026-11-21 0:14 UTC (permalink / raw)
To: netdev
Cc: Tariq Toukan, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, linux-rdma
mlx4_en_get_rxnfc() treats the input rule_cnt as the number of
rules it needs to find for ETHTOOL_GRXCLSRLALL.
With room for four locations and only one rule installed, the
ioctl succeeds with rule_cnt still set to four and three extra
zero entries. When the buffer has too few slots, the ioctl
succeeds with an incomplete list.
Bound the scan by the rule table size, skip empty slots and
propagate unexpected lookup errors. Return -EMSGSIZE when the next
rule cannot fit and set rule_cnt to the number of copied locations
on success.
The source-extracted ASan/UBSan regression tests passed.
Fixes: 820672812f82 ("net/mlx4_en: Manage flow steering rules with ethtool")
Signed-off-by: Artemii Mashanov <ralerrdirsardx@gmail.com>
---
drivers/net/ethernet/mellanox/mlx4/en_ethtool.c | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
index 4ba1947..463c1a4 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
@@ -1739,8 +1739,9 @@ static int mlx4_en_get_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd,
{
struct mlx4_en_priv *priv = netdev_priv(dev);
struct mlx4_en_dev *mdev = priv->mdev;
+ u32 count = 0;
int err = 0;
- int i = 0, priority = 0;
+ int i;
if ((cmd->cmd == ETHTOOL_GRXCLSRLCNT ||
cmd->cmd == ETHTOOL_GRXCLSRULE ||
@@ -1758,12 +1759,17 @@ static int mlx4_en_get_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd,
break;
case ETHTOOL_GRXCLSRLALL:
cmd->data = MAX_NUM_OF_FS_RULES;
- while ((!err || err == -ENOENT) && priority < cmd->rule_cnt) {
+ for (i = 0; i < MAX_NUM_OF_FS_RULES; i++) {
err = mlx4_en_get_flow(dev, cmd, i);
- if (!err)
- rule_locs[priority++] = i;
- i++;
+ if (err == -ENOENT)
+ continue;
+ if (err)
+ return err;
+ if (count == cmd->rule_cnt)
+ return -EMSGSIZE;
+ rule_locs[count++] = i;
}
+ cmd->rule_cnt = count;
err = 0;
break;
default:
--
2.56.0
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH net] net: mlx4_en: report the actual RX classification rule count
2026-11-21 0:14 [PATCH net] net: mlx4_en: report the actual RX classification rule count Artemii Mashanov
@ 2026-11-21 0:17 ` netdev-bot+sinfo
2026-11-21 20:56 ` Artemii Mashanov
2026-11-25 6:51 ` Tariq Toukan
1 sibling, 1 reply; 4+ messages in thread
From: netdev-bot+sinfo @ 2026-11-21 0:17 UTC (permalink / raw)
To: Artemii Mashanov
Cc: netdev, Tariq Toukan, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, linux-rdma
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] 4+ messages in thread
* Re: [PATCH net] net: mlx4_en: report the actual RX classification rule count
2026-11-21 0:17 ` netdev-bot+sinfo
@ 2026-11-21 20:56 ` Artemii Mashanov
0 siblings, 0 replies; 4+ messages in thread
From: Artemii Mashanov @ 2026-11-21 20:56 UTC (permalink / raw)
To: netdev-bot+sinfo
Cc: netdev, Tariq Toukan, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, linux-rdma
Hi,
I found this while auditing ETHTOOL_GRXCLSRLALL handlers. Reading
mlx4_en_get_rxnfc() showed that the original loop used rule_cnt
as its stopping condition and could return success without
reporting how many rule locations it had copied.
The ioctl behavior described in the commit message was inferred
from the original code. I did not reproduce it through an ioctl
on a running kernel. I tested the patched handler in a standalone
harness with ASan and UBSan, checking the returned rule count and
the -EMSGSIZE return when the buffer was too small.
An earlier revision also built as mlx4_en.ko against Linux
7.4-rc2. I did not test the change on real mlx4 hardware.
Thanks,
Artemii
сб, 21 нояб. 2026 г. в 03:17, <netdev-bot+sinfo@kernel.org>:
>
> 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] 4+ messages in thread
* Re: [PATCH net] net: mlx4_en: report the actual RX classification rule count
2026-11-21 0:14 [PATCH net] net: mlx4_en: report the actual RX classification rule count Artemii Mashanov
2026-11-21 0:17 ` netdev-bot+sinfo
@ 2026-11-25 6:51 ` Tariq Toukan
1 sibling, 0 replies; 4+ messages in thread
From: Tariq Toukan @ 2026-11-25 6:51 UTC (permalink / raw)
To: Artemii Mashanov, netdev
Cc: Tariq Toukan, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, linux-rdma
On 21/11/2026 2:14, Artemii Mashanov wrote:
> mlx4_en_get_rxnfc() treats the input rule_cnt as the number of
> rules it needs to find for ETHTOOL_GRXCLSRLALL.
>
> With room for four locations and only one rule installed, the
> ioctl succeeds with rule_cnt still set to four and three extra
> zero entries. When the buffer has too few slots, the ioctl
> succeeds with an incomplete list.
>
> Bound the scan by the rule table size, skip empty slots and
> propagate unexpected lookup errors. Return -EMSGSIZE when the next
> rule cannot fit and set rule_cnt to the number of copied locations
> on success.
>
> The source-extracted ASan/UBSan regression tests passed.
>
> Fixes: 820672812f82 ("net/mlx4_en: Manage flow steering rules with ethtool")
> Signed-off-by: Artemii Mashanov <ralerrdirsardx@gmail.com>
> ---
> drivers/net/ethernet/mellanox/mlx4/en_ethtool.c | 16 +++++++++++-----
> 1 file changed, 11 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
> index 4ba1947..463c1a4 100644
> --- a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
> +++ b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
> @@ -1739,8 +1739,9 @@ static int mlx4_en_get_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd,
> {
> struct mlx4_en_priv *priv = netdev_priv(dev);
> struct mlx4_en_dev *mdev = priv->mdev;
> + u32 count = 0;
> int err = 0;
> - int i = 0, priority = 0;
> + int i;
>
> if ((cmd->cmd == ETHTOOL_GRXCLSRLCNT ||
> cmd->cmd == ETHTOOL_GRXCLSRULE ||
> @@ -1758,12 +1759,17 @@ static int mlx4_en_get_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd,
> break;
> case ETHTOOL_GRXCLSRLALL:
> cmd->data = MAX_NUM_OF_FS_RULES;
> - while ((!err || err == -ENOENT) && priority < cmd->rule_cnt) {
> + for (i = 0; i < MAX_NUM_OF_FS_RULES; i++) {
> err = mlx4_en_get_flow(dev, cmd, i);
> - if (!err)
> - rule_locs[priority++] = i;
> - i++;
> + if (err == -ENOENT)
> + continue;
> + if (err)
> + return err;
> + if (count == cmd->rule_cnt)
> + return -EMSGSIZE;
> + rule_locs[count++] = i;
> }
> + cmd->rule_cnt = count;
> err = 0;
> break;
> default:
Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
Thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-11-25 6:51 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-21 0:14 [PATCH net] net: mlx4_en: report the actual RX classification rule count Artemii Mashanov
2026-11-21 0:17 ` netdev-bot+sinfo
2026-11-21 20:56 ` Artemii Mashanov
2026-11-25 6:51 ` Tariq Toukan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox