From: Stanislaw Pal <kuncy7@gmail.com>
To: Christian Marangi <ansuelsmth@gmail.com>,
Andrew Lunn <andrew@lunn.ch>, Vladimir Oltean <olteanv@gmail.com>
Cc: "David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH net 3/3] net: dsa: qca8k: check the length of MIB autocast frames
Date: Thu, 22 Oct 2026 21:29:33 +0200 [thread overview]
Message-ID: <20261022192933.384898-4-kuncy7@gmail.com> (raw)
In-Reply-To: <20261022192933.384898-1-kuncy7@gmail.com>
qca_tag_rcv() makes only the 2 byte tag linear before it hands a MIB
frame to qca8k_mib_autocast_handler(). The handler then reads the
counters that follow the Ethernet header, up to 164 bytes on QCA833x,
straight from skb->data, without checking the frame length. A short or
non-linear frame makes it read past the packet data.
Pull the counters into the linear area before reading them. A frame
that is too short is left uncounted, so the request times out and
the caller reads the counters from the registers instead.
Fixes: 5c957c7ca78c ("net: dsa: qca8k: add support for mib autocast in Ethernet packet")
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Stanislaw Pal <kuncy7@gmail.com>
---
drivers/net/dsa/qca/qca8k-8xxx.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/drivers/net/dsa/qca/qca8k-8xxx.c b/drivers/net/dsa/qca/qca8k-8xxx.c
index 56796df14..e5d858230 100644
--- a/drivers/net/dsa/qca/qca8k-8xxx.c
+++ b/drivers/net/dsa/qca/qca8k-8xxx.c
@@ -1656,6 +1656,7 @@ static void qca8k_mib_autocast_handler(struct dsa_switch *ds, struct sk_buff *sk
struct qca8k_priv *priv = ds->priv;
const struct qca8k_mib_desc *mib;
struct mib_ethhdr *mib_ethhdr;
+ unsigned int len = 0;
__le32 *data2;
u8 port;
int i;
@@ -1676,6 +1677,16 @@ static void qca8k_mib_autocast_handler(struct dsa_switch *ds, struct sk_buff *sk
if (port != mib_eth_data->req_port)
goto exit;
+ /* Past the first 3, the counters follow the header. Leave a short
+ * frame uncounted, so that the request times out and the caller
+ * reads the registers instead.
+ */
+ for (i = 3; i < priv->info->mib_count; i++)
+ len += ar8327_mib[i].size * sizeof(u32);
+ if (!pskb_may_pull(skb, len))
+ goto unlock;
+
+ mib_ethhdr = (struct mib_ethhdr *)skb_mac_header(skb);
data2 = (__le32 *)skb->data;
for (i = 0; i < priv->info->mib_count; i++) {
--
2.43.0
prev parent reply other threads:[~2026-10-22 19:29 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-22 19:29 [PATCH net 0/3] net: dsa: qca8k: fix concurrent register and MIB autocast access Stanislaw Pal
2026-10-22 19:29 ` [PATCH net 1/3] net: dsa: qca8k: let regmap serialize register access Stanislaw Pal
2026-10-22 19:29 ` [PATCH net 2/3] net: dsa: qca8k: drop MIB autocast frames once the request is over Stanislaw Pal
2026-10-26 19:30 ` netdev-bot+sashiko
2026-10-26 20:00 ` Stanislaw Pal
2026-10-22 19:29 ` Stanislaw Pal [this message]
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=20261022192933.384898-4-kuncy7@gmail.com \
--to=kuncy7@gmail.com \
--cc=andrew@lunn.ch \
--cc=ansuelsmth@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=olteanv@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.