Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Lorenzo Bianconi" <lorenzo@kernel.org>
Cc: conor+dt@kernel.org, robh@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH net-next v8 05/10] net: airoha: Move qos_sq_bmap in airoha_gdm_dev struct
Date: Wed, 20 May 2026 08:59:25 +0000	[thread overview]
Message-ID: <20260520085926.97A481F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260519-airoha-eth-multi-serdes-v8-5-6bd70e329df6@kernel.org>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Off-by-one in airoha_tc_remove_htb_queue() clears the hardware rate limit of the wrong QDMA channel, corrupting cross-device shared state.
- [High] Dynamic real_num_tx_queues accounting causes out-of-bounds queue indices and bypasses hardware QoS entirely.
--

commit cfd982e85e1dc0ffc8dc017589e1128ecce7248e
Author: Lorenzo Bianconi <lorenzo@kernel.org>

net: airoha: Move qos_sq_bmap in airoha_gdm_dev struct

This commit moves the qos_sq_bmap field from airoha_gdm_port to
airoha_gdm_dev to prevent overwriting configurations from multiple
net_devices sharing the same GDM port. It also introduces
qos_channel_map in airoha_qdma to track shared QDMA channel usage.

> diff --git a/drivers/net/ethernet/airoha/airoha_eth.c b/drivers/net/ethernet/airoha/airoha_eth.c
> index 847f432b0a2b0..594fbebcb12ce 100644
> --- a/drivers/net/ethernet/airoha/airoha_eth.c
> +++ b/drivers/net/ethernet/airoha/airoha_eth.c
[ ... ]
> +static int airoha_tc_htb_alloc_leaf_queue(struct net_device *netdev,
> +					  struct tc_htb_qopt_offload *opt)
> +{
> +	u32 channel = TC_H_MIN(opt->classid) % AIROHA_NUM_QOS_CHANNELS;
> +	int err, num_tx_queues = netdev->real_num_tx_queues;
[ ... ]
>  	err = netif_set_real_num_tx_queues(netdev, num_tx_queues + 1);
>  	if (err) {
[ ... ]
> -	set_bit(channel, port->qos_sq_bmap);
> +	set_bit(channel, dev->qos_sq_bmap);
>  	opt->qid = AIROHA_NUM_TX_RING + channel;

Can this dynamic real_num_tx_queues accounting cause out-of-bounds queue
indices?

The driver tracks allocated QoS leaf queues by incrementing
dev->real_num_tx_queues by 1. However, the assigned hardware queue index is
derived from a sparse hash of the user-provided classid.

If a user allocates a non-sequential classid that hashes to a higher channel
number while having only a few queues active, won't opt->qid exceed the
incremented dev->real_num_tx_queues?

During transmission, would netdev_core_pick_tx() then detect this
out-of-bounds queue mapping, reset the queue index, and route the traffic to
the default ring 0, silently bypassing the hardware HTB rate limits?

[ ... ]
>  static void airoha_tc_remove_htb_queue(struct net_device *netdev, int queue)
>  {
>  	struct airoha_gdm_dev *dev = netdev_priv(netdev);
> -	struct airoha_gdm_port *port = dev->port;
> +	struct airoha_qdma *qdma = dev->qdma;
>  
>  	netif_set_real_num_tx_queues(netdev, netdev->real_num_tx_queues - 1);
>  	airoha_qdma_set_tx_rate_limit(netdev, queue + 1, 0, 0);

Is there an off-by-one error when clearing the hardware rate limit here?

The queue + 1 offset causes it to clear the configuration of the adjacent
channel instead of the one actually being deleted, as the allocation path
uses channel without the offset.

Since this patch enables multiple net_devices to share the same QDMA block,
could clearing queue + 1 silently destroy the active hardware QoS
configuration belonging to a completely different net_device?

Does this also leave the rate limit for the actual deleted queue active,
and potentially cause an out-of-bounds register write if the deleted queue is
the maximum channel index (15)?

> -	clear_bit(queue, port->qos_sq_bmap);
> +
> +	clear_bit(queue, qdma->qos_channel_map);
> +	clear_bit(queue, dev->qos_sq_bmap);
>  }

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260519-airoha-eth-multi-serdes-v8-0-6bd70e329df6@kernel.org?part=5

  reply	other threads:[~2026-05-20  8:59 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-19  8:57 [PATCH net-next v8 00/10] net: airoha: Support multiple net_devices connected to the same GDM port Lorenzo Bianconi
2026-05-19  8:57 ` [PATCH net-next v8 01/10] dt-bindings: net: airoha: Add GDM port ethernet child node Lorenzo Bianconi
2026-05-19  8:57 ` [PATCH net-next v8 02/10] net: airoha: Introduce airoha_gdm_dev struct Lorenzo Bianconi
2026-05-20  8:59   ` sashiko-bot
2026-05-20 12:25     ` Lorenzo Bianconi
2026-05-19  8:57 ` [PATCH net-next v8 03/10] net: airoha: Move airoha_qdma pointer in " Lorenzo Bianconi
2026-05-19  8:57 ` [PATCH net-next v8 04/10] net: airoha: Rely on airoha_gdm_dev pointer in airoha_is_lan_gdm_port() Lorenzo Bianconi
2026-05-19  8:57 ` [PATCH net-next v8 05/10] net: airoha: Move qos_sq_bmap in airoha_gdm_dev struct Lorenzo Bianconi
2026-05-20  8:59   ` sashiko-bot [this message]
2026-05-20 12:24     ` Lorenzo Bianconi
2026-05-19  8:57 ` [PATCH net-next v8 06/10] net: airoha: Move {cpu,fwd}_tx_packets " Lorenzo Bianconi
2026-05-19  8:57 ` [PATCH net-next v8 07/10] net: airoha: Support multiple net_devices for a single FE GDM port Lorenzo Bianconi
2026-05-20  8:59   ` sashiko-bot
2026-05-20 12:28     ` Lorenzo Bianconi
2026-05-20 12:33     ` Lorenzo Bianconi
2026-05-19  8:57 ` [PATCH net-next v8 08/10] net: airoha: Do not stop GDM port if it is shared Lorenzo Bianconi
2026-05-19  8:57 ` [PATCH net-next v8 09/10] net: airoha: Introduce WAN device flag Lorenzo Bianconi
2026-05-20  8:59   ` sashiko-bot
2026-05-20 12:46     ` Lorenzo Bianconi
2026-05-19  8:57 ` [PATCH net-next v8 10/10] net: airoha: Support multiple LAN/WAN interfaces for hw MAC address configuration Lorenzo Bianconi
2026-05-20  8:59   ` sashiko-bot
2026-05-20 12:49     ` Lorenzo Bianconi

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=20260520085926.97A481F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=lorenzo@kernel.org \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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