From: Artemii Mashanov <ralerrdirsardx@gmail.com>
To: netdev@vger.kernel.org
Cc: Doug Berger <opendmb@gmail.com>,
Florian Fainelli <florian.fainelli@broadcom.com>,
Nicolai Buchwitz <nb@tipi-net.de>,
Broadcom internal kernel review list
<bcm-kernel-feedback-list@broadcom.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Subject: [PATCH net-next v2] net: bcmgenet: reject undersized RX classification rule buffers
Date: Sun, 22 Nov 2026 11:22:22 +0300 [thread overview]
Message-ID: <20261122091748.18292-1-ralerrdirsardx@gmail.com> (raw)
The rule list can grow between ETHTOOL_GRXCLSRLCNT and
ETHTOOL_GRXCLSRLALL. If the supplied array is too small,
bcmgenet_get_rxnfc() currently reports success with only the rule
locations that fit.
Return -EMSGSIZE when another location cannot fit so callers can
detect an incomplete dump. On success, continue reporting the number
of locations copied.
Signed-off-by: Artemii Mashanov <ralerrdirsardx@gmail.com>
---
Changes in v2:
- Retarget to net-next as requested by Nicolai.
- Clarify the commit message and drop the Fixes and test lines.
- No code changes.
v1: https://lore.kernel.org/netdev/20261121001550.732679-1-ralerrdirsardx@gmail.com/
drivers/net/ethernet/broadcom/genet/bcmgenet.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
index 6545caf..a84c8ce 100644
--- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c
+++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
@@ -1664,7 +1664,7 @@ static int bcmgenet_get_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd,
struct bcmgenet_priv *priv = netdev_priv(dev);
struct bcmgenet_rxnfc_rule *rule;
int err = 0;
- int i = 0;
+ u32 i = 0;
switch (cmd->cmd) {
case ETHTOOL_GRXCLSRLCNT:
@@ -1675,9 +1675,11 @@ static int bcmgenet_get_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd,
err = bcmgenet_get_flow(dev, cmd, cmd->fs.location);
break;
case ETHTOOL_GRXCLSRLALL:
- list_for_each_entry(rule, &priv->rxnfc_list, list)
- if (i < cmd->rule_cnt)
- rule_locs[i++] = rule->fs.location;
+ list_for_each_entry(rule, &priv->rxnfc_list, list) {
+ if (i == cmd->rule_cnt)
+ return -EMSGSIZE;
+ rule_locs[i++] = rule->fs.location;
+ }
cmd->rule_cnt = i;
cmd->data = MAX_NUM_OF_FS_RULES;
break;
next reply other threads:[~2026-11-22 9:18 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-22 8:22 Artemii Mashanov [this message]
2026-11-22 16:46 ` [PATCH net-next v2] net: bcmgenet: reject undersized RX classification rule buffers Nicolai Buchwitz
2026-11-29 16:30 ` patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261122091748.18292-1-ralerrdirsardx@gmail.com \
--to=ralerrdirsardx@gmail.com \
--cc=andrew+netdev@lunn.ch \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=florian.fainelli@broadcom.com \
--cc=kuba@kernel.org \
--cc=nb@tipi-net.de \
--cc=netdev@vger.kernel.org \
--cc=opendmb@gmail.com \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.