From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.52 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796100224; b=VBwMM0k0R5BqwxaAo9zeYN+NSMT4cZVatBme9/63YT6zwjyiQT/5w4orbu92yGou9ZCm qKMI0piM5WYM5zE7f3Bsc5vIw1elMEUDbaNDXVs0XhguhBLDVs9ngJn9Iy1f5d1NYPSTo 7hQjxVBUcudcnkXITmYQQrtB+am/BLxDxlLtmJcNrBGYFx5F9Rca6O9wKd39qTt+pkmZ7 9K0B1CrQcCqln4L+tGZIM175IxtVRPkUipDSzaIIbUSAagZGYhtnktHP/3nc+ys3XjkJO lXlfiVioRZrc5/2CYqPQ8ACSPiWZhuXbGOS58cRX2wwWEMgC/UIhdBwIpMpyHWMa/5g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796100224; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:MIME-Version: Content-Transfer-Encoding; bh=nYJgaWxfUif8x2/gl861aeOMLa3r6gq9Xoj99O3mmyY=; b=wl66yx3pFTN0Mj3arcUjQWwdXrt6wkcU9HrM1G/DWHbNqJV3MXOLq/2G8c4pImMzz5By 8AB4a1iLdcCPaIUewGxPJUP06IWQ/faPwD6F2zSnHVxqcIZ8nSV8iRLXSDwbVKucM/PHt pPcJy+FcslQkqnFjf/zABHOVRxEjpaRBWK8NJWi2DqEm0hDPAGAnSG5Oz9/8euxo7Izh9 n0VWy4RmR3WZ8JDAIXCPBleDNWSQIieTLFhcH7Q/c2e/6cPxAehtmDCDhwoSsSu+fHTHI K5O+MRvvS9SKo3QSVQK4yH2Dba2teeau34paXkFJetPLNtxaswNVEXpg+bpLNmP7ukA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=yPo27khX; arc=none smtp.remote-ip=74.125.82.52 Received: from mail-dl1-f52.google.com (mail-dl1-f52.google.com [74.125.82.52]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 18373606A32E for ; Tue, 1 Dec 2026 04:43:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 18373606A32E Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=yPo27khX Received: by mail-dl1-f52.google.com with SMTP id a92af1059eb24-1aefd1bf74aso7059869c88.1 for ; Mon, 30 Nov 2026 20:43:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796100223; x=1796705023; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=nYJgaWxfUif8x2/gl861aeOMLa3r6gq9Xoj99O3mmyY=; b=yPo27khXaCxPnVbnWcFvvukYCE2Za9OM9AI4LxeKhCXs/SWrxfTermRm71XwlHTJAw fOQjj5/3LwDQIzAAjNEhG4VCWUzLfL25ZqlWID9e7vacplEiJDZV6hko2IuHyk/kmvSq Sxbt6PuftU3gbFrLTl3+ywRwY9kEgGbR1mqg/ukagNMDQV8xSGRrorOxvyP8mvUxoDXM Q+OvwQqdjSOUYA16Mh07Sqj6bvonrjXsh/eRRrrZ5DUFE1Nep7kqmEx3TDgyu2vYBzKQ kgS3rd5ENpwbuQZsvx0rAThyo8HlBKBQ45xXJeyd1KvYKEQnS6wNVPMrl8iRSs0aI/Ji jsfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796100223; x=1796705023; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=nYJgaWxfUif8x2/gl861aeOMLa3r6gq9Xoj99O3mmyY=; b=OKCNmvNFmCcN6vOr4dmBZzkaGr52nMGrfA8OvWtCiwcMhqX/FxmVTLKoVNr9JwbDBo LglWQ2oNYc2Uo8aY3y6sUyzl5SgR7fHopOER8Z8WUbiffiZdhKHoslF9rmPr6dsoqyAy LSFyMdq6U20xFXPPptwQYrhtb9BqKRYTgMpF1kdNVirYugT4dTwNhYjQZw8/ry1vVHEU dfPB3wBXdr7sMJud3iIaHEsl8nDSqgCX7GKYxKmvsIVmFCBABaoqjIPnJBh8oLMv01A2 yw2yPnmh+W5EbWUHSOp+606UrIAdkrpcnN5yWiiu6dbnEvhleU86ZruPbfVZaxuvlt7F nN7g== X-Forwarded-Encrypted: i=1; AL+hErFNsmqp8ayaE3E9evPwjwOpESkeUbOMr8AcmVVshMAtDE4ZgLy8uqzWPeXyIxyJ+Ae8jhb58XeLNNh2RVM=@vger.kernel.org X-Gm-Message-State: APuU4Z/ICCNtD4b3cjhzg0GaipRfX2bXDZjcLSNonDDmEcsNNJDIWckw dUyt3N9Jd0mSWBDhD4oVk+EeCL3j05TBO3CLbIclIkhjmshWKy+A3fcU X-Gm-Gg: AZFdTZdu3BvP8y9CQs84URV8nK3i9KXAEGyjoYNUmwNfjFtL2tJuPwluyEGGF54xCVG 5yEifxWiRs0dL9VuYi4aewkXkb6Sa0V87IWl3VpcoCG6mhK6tPJiDBJYqU0aWyGxsfKTtW3uEqg qkusF4gq9wEpDRT445gFyd9IwFQfBX20xElLQP7HE+Fk9aDNrbMYp5wJpiCEzFmXxgXGuJTdchF gQPyNp7ZOHLRlawo1vQDGZA6KMqiGr0/dPuULbYp3fKVoUfF8BOHF6yyy4vP6+EXOmY9/pgSfc3 oz5/DYcHMEpcC1XefHisk11sGfyxdub4JdjmImx8mtgoaiviXr1GhD4iDRvQEyhVEqsgtW4H8sE GHsr/HU5qTsC9+F6O8clzqN1l/gWL0tEtjOW0qSl4vE3nvyqI2WvQVrgaSBsD2Fgutxe9sIFmex feK1nDboiUomqgRGuW2AfdwWWyNmvi9CVBYv++mkcPKJH0YmN+xXoh6wtVG8us6lAwe785fAt6j 82SWN0CHscCYD6ZM4Vpl7jMR90mhIPeg+3wtq+BRvFSesPoqxqV1fdrskKpZRYR9Q2XFW9JAUAr PfBhMzshFrR8cxqXyauVx9DzM6nU3lhexROZSHkCM1TpioE0Db1BMq7DDcYKm/ayGhddXzvuomM wRYhEB2gnVD9z87Za4gPBZPxGtqHJi6Vw X-Received: by 2002:a05:7023:a41:b0:1a7:77ae:11f6 with SMTP id a92af1059eb24-1b55691518fmr32707267c88.17.1796100222972; Mon, 30 Nov 2026 20:43:42 -0800 (PST) Received: from jmaxwell-thinkpadp1gen4i.redhat.corp (14-203-60-241.tpgi.com.au. [14.203.60.241]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-1b55681301asm82311299c88.8.2026.11.30.20.43.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2026 20:43:42 -0800 (PST) From: Jon Maxwell To: haiyangz@microsoft.com Cc: wei.liu@kernel.org, decui@microsoft.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, dipayanroy@linux.microsoft.com, ernis@linux.microsoft.com, longli@microsoft.com, gargaditya@linux.microsoft.com, hamzamahfooz@linux.microsoft.com, linux-hyperv@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, jmaxwell37@gmail.com Subject: [PATCH net-next] net: mana: Clamp the recorded RX queue in mana_select_queue() Date: Tue, 1 Dec 2026 15:43:30 +1100 Message-ID: <20261201044330.3046262-1-jmaxwell37@gmail.com> X-Mailer: git-send-email 2.55.0 X-Mailing-List: linux-hyperv@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit mana_select_queue() falls back to the RX queue recorded in the skb when the socket-cached TX queue is unusable: txq = sk_tx_queue_get(skb->sk); if (txq < 0 || skb->ooo_okay || txq >= ndev->real_num_tx_queues) { if (skb_rx_queue_recorded(skb)) txq = skb_get_rx_queue(skb); else txq = mana_get_tx_queue(ndev, skb, txq); } return txq; The bounds check only decides whether the socket-cached value has to be recomputed; it does not validate the value that is returned. The recorded RX queue belongs to whichever device the skb was received on, so when a packet is forwarded from an interface with more queues than the MANA port has, an out of range index is returned and netdev_core_pick_tx() complains: enPX selects TX queue 43, but real number of TX queues is 32 enPX selects TX queue 42, but real number of TX queues is 32 enPX selects TX queue 33, but real number of TX queues is 32 netdev_cap_txqueue() then forces every one of those packets onto TX queue 0, so besides the log spam all affected flows collapse onto a single queue. This is easy to hit on Azure when container traffic is forwarded out of a MANA VF: veth sizes its queues with num_possible_cpus(), while mana sizes them with num_online_cpus(). On a guest with more possible than online CPUs the veth devices end up with more queues than the VF, and the index chosen on the veth survives into the VF transmit path. Wrap the recorded queue into range, the same thing the generic path does in skb_tx_hash() and that mlx5e_txq_to_ch_ix() does for mlx5e. A single subtraction is not enough: the recorded index can be an arbitrary multiple of real_num_tx_queues, so use a modulo and keep it off the fast path with an unlikely() check. Read real_num_tx_queues once while at it, so that all three tests agree on one value even if the queue count is changed concurrently. The other two sources are already bounded: the socket-cached index is range checked above, and mana_get_tx_queue() returns an indirection table entry, which is always below apc->num_queues. Fixes: ca9c54d2d6a5 ("net: mana: Add a driver for Microsoft Azure Network Adapter (MANA)") Signed-off-by: Jon Maxwell --- drivers/net/ethernet/microsoft/mana/mana_en.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/microsoft/mana/mana_en.c b/drivers/net/ethernet/microsoft/mana/mana_en.c index 95bf153c3e1a..eafba38488e8 100644 --- a/drivers/net/ethernet/microsoft/mana/mana_en.c +++ b/drivers/net/ethernet/microsoft/mana/mana_en.c @@ -684,18 +684,26 @@ static int mana_get_tx_queue(struct net_device *ndev, struct sk_buff *skb, static u16 mana_select_queue(struct net_device *ndev, struct sk_buff *skb, struct net_device *sb_dev) { + int num_txq = READ_ONCE(ndev->real_num_tx_queues); int txq; - if (ndev->real_num_tx_queues == 1) + if (num_txq == 1) return 0; txq = sk_tx_queue_get(skb->sk); - if (txq < 0 || skb->ooo_okay || txq >= ndev->real_num_tx_queues) { - if (skb_rx_queue_recorded(skb)) + if (txq < 0 || skb->ooo_okay || txq >= num_txq) { + if (skb_rx_queue_recorded(skb)) { + /* The queue was recorded by another device, which may + * have many more queues than this port, so wrap it + * into range like skb_tx_hash() does. + */ txq = skb_get_rx_queue(skb); - else + if (unlikely(txq >= num_txq)) + txq %= num_txq; + } else { txq = mana_get_tx_queue(ndev, skb, txq); + } } return txq; -- 2.55.0