All of lore.kernel.org
 help / color / mirror / Atom feed
* [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-21  0:23 ` sashiko-bot
  0 siblings, 2 replies; 3+ 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] 3+ 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  0:23 ` sashiko-bot
  1 sibling, 0 replies; 3+ 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] 3+ 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  0:23 ` sashiko-bot
  1 sibling, 0 replies; 3+ messages in thread
From: sashiko-bot @ 2026-11-21  0:23 UTC (permalink / raw)
  To: Artemii Mashanov; +Cc: 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>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261121001414.724236-1-ralerrdirsardx@gmail.com?part=1

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-21  0:23 UTC | newest]

Thread overview: 3+ 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  0:23 ` sashiko-bot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.