net: mlx4_en: report the actual RX classification rule count
Subsystems (5)
PATCH 1/1 net: mlx4_en: report the actual RX classification rule count
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.
--- drivers/net/ethernet/mellanox/mlx4/en_ethtool.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)
drivers/net/ethernet/mellanox/mlx4/en_ethtool.c +11 -5
@@ -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 :
Signature · 1 line
2.56.0
[email protected]
AI reviewThis is an automated message. This series looks like a fix, but its commit messages seem to be missing some information:
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.
Signature · 2 lines
The evaluation is done by an LLM so it may be wrong, if you think that is the case please reply and explain.
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, <[email protected]>:
Quoted 27 lines
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.
[email protected]
AI reviewSashiko has reviewed this patch and found no issues.
Quoted 13 lines
mlx4_en_get_rxnfc()treats the inputrule_cntas the number of rules it needs to find forETHTOOL_GRXCLSRLALL.With room for four locations and only one rule installed, the ioctl succeeds with
rule_cntstill 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
-EMSGSIZEwhen the next rule cannot fit and setrule_cntto the number of copied locations on success.
Quoted 4 lines
The source-extracted ASan/UBSan regression tests passed.
Fixes 820672812f82 ("net/mlx4_en: Manage flow steering rules with ethtool")Signed-off-by Artemii Mashanov <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1