🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.netdev
4 messages
4 total messages Started by Artemii Mashanov Sat, 21 Nov 2026 00:14
[PATCH net] net: mlx4_en: report the actual RX classification rule count
#20028
Author: Artemii Mashanov
Date: Sat, 21 Nov 2026 00:14
61 lines
12670 bytes
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
Re: [PATCH net] net: mlx4_en: report the actual RX classification rule count
#20030
Author: netdev-bot+sinfo
Date: Sat, 21 Nov 2026 00:17
27 lines
8882 bytes
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.
Re: [PATCH net] net: mlx4_en: report the actual RX classification rule count
#20222
Author: Artemii Mashanov
Date: Sat, 21 Nov 2026 20:56
49 lines
13935 bytes
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.
Re: [PATCH net] net: mlx4_en: report the actual RX classification rule count
#24924
Author: patchwork-bot+netdevbpf
Date: Tue, 01 Dec 2026 03:00
25 lines
8614 bytes
Hello:

This patch was applied to netdev/net.git (main)
by Willem de Bruijn <willemb@google.com>:

On Sat, 21 Nov 2026 03:14:14 +0300 you 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.
> 
> [...]

Here is the summary with links:
  - [net] net: mlx4_en: report the actual RX classification rule count
    https://git.kernel.org/netdev/net/c/fcf40733391f

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads