mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Josef Schlehofer <pepe.schlehofer@gmail.com>
To: netdev@vger.kernel.org
Cc: marcin.s.wojtas@gmail.com, andrew+netdev@lunn.ch,
	davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
	pabeni@redhat.com, maxime.chevallier@bootlin.com, w@1wt.eu,
	linux-kernel@vger.kernel.org
Subject: [PATCH net-next v4 3/6] net: mvneta: check the TX queue range of an mqprio offload
Date: Wed, 18 Nov 2026 10:30:09 +0100	[thread overview]
Message-ID: <20261118093012.90121-4-pepe.schlehofer@gmail.com> (raw)
In-Reply-To: <20261118093012.90121-1-pepe.schlehofer@gmail.com>

An mqprio offload without a shaper can map a traffic class to TX
queues that do not exist. Reading the class statistics then reads past
the TX queue array of the device, also as an unprivileged user:

  # kernel command line: mvneta.txq_number=4
  tc qdisc add dev eth2 root handle 100: mqprio num_tc 2 \
    map 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 queues 4@0 4@4 hw 1
  tc -s class show dev eth2

mvneta_setup_mqprio() checks the queue ranges against the number of RX
queues, and against the number of TX queues only when a shaper is set.
With fewer TX than RX queues a range can pass the RX check and end
beyond the last TX queue. Check every queue of a class against both
numbers.

Found by an AI code review agent while working on this series, and
confirmed on a Turris Omnia (Armada 385) booted with
mvneta.txq_number=4. Without this patch the setup was accepted, and
the class dump as uid 65534 caused a kernel oops in
mqprio_dump_class_stats(). With this patch the range is rejected with
-EINVAL, so the class dump stays within the TX queue array. Tested
with the series applied up to this patch and with the whole series
applied. No kernel selftest covers the mvneta mqprio offload.

Fixes: 4906887a8ae5 ("net: mvneta: Implement mqprio support")
Signed-off-by: Josef Schlehofer <pepe.schlehofer@gmail.com>
---
v4: New patch. Answering TC_QUERY_CAPS with validate_queue_counts would
let the core check the TX range, but it would also reject classes
without queues and overlapping ranges, which the driver accepts today,
and it does not check the RX queues.
---
 drivers/net/ethernet/marvell/mvneta.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c
index 06b5453543a1..76dfbc484269 100644
--- a/drivers/net/ethernet/marvell/mvneta.c
+++ b/drivers/net/ethernet/marvell/mvneta.c
@@ -5277,7 +5277,8 @@ static int mvneta_setup_mqprio(struct net_device *dev,
 		for (rxq = mqprio->qopt.offset[tc];
 		     rxq < mqprio->qopt.count[tc] + mqprio->qopt.offset[tc];
 		     rxq++) {
-			if (rxq >= rxq_number)
+			/* The range sets the TX queues of the class as well */
+			if (rxq >= rxq_number || rxq >= txq_number)
 				return -EINVAL;
 
 			mvneta_map_vlan_prio_to_rxq(pp, tc, rxq);
-- 
2.54.0 (Apple Git-157)


  parent reply	other threads:[~2026-11-18  9:30 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-18  9:30 [PATCH net-next v4 0/6] net: mvneta: fix the TX queue arbitration and the " Josef Schlehofer
2026-11-18  9:30 ` [PATCH net-next v4 1/6] net: mvneta: lift the per-queue TX rate limits Josef Schlehofer
2026-11-18  9:30 ` [PATCH net-next v4 2/6] net: mvneta: fix the removal of the mqprio offload Josef Schlehofer
2026-11-18  9:30 ` Josef Schlehofer [this message]
2026-11-18  9:30 ` [PATCH net-next v4 4/6] net: mvneta: keep the TX rate limits across open and MTU change Josef Schlehofer
2026-11-18  9:30 ` [PATCH net-next v4 5/6] net: mvneta: validate an mqprio setup before applying it Josef Schlehofer
2026-11-18  9:30 ` [PATCH net-next v4 6/6] net: mvneta: serve the TX queues in weighted round robin Josef Schlehofer

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=20261118093012.90121-4-pepe.schlehofer@gmail.com \
    --to=pepe.schlehofer@gmail.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcin.s.wojtas@gmail.com \
    --cc=maxime.chevallier@bootlin.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=w@1wt.eu \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®