From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.51 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796100224; b=FO6PQYcM9XwmrdSRC42irwIutR1KnLN4xuGqqBH2/QJBxKKTES18sIkJAAfVRO7rQkZc 6eB4QCIRPgt59irKE5NQpINfH9R4ZW7j9NiWI9anSE7P/ydKxz0VmSy77tV11s57RzdQS VLEz2pIUzOW7EKlvDV15ee/az9nf8b8T59fZCX9sN//oPisczbBrtiQsd9heO2gTpyn9C t+zvSHh0oJ3+Fu609a99zXAuprzy6hfbTi9/1G958l4+hRZvV4p2hnaaKWCUtoOdhHTHn VMWvWPfpaqGXKHbjF70JoC6ugUVMALWHuihPlWDGPjnaRW4fcK+I9q5a9YHYN8DMdwA== 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=3hM3kUj1Sey2oygdeh4p3FYUu7fsgC8FsAYiXM+QAcDL2eFXTJD0gnEWxeKxVE9scT30 OwwnO0MHW2p3Nev4rZAhkkCKTXbROoK6a2nqsYDClYeQtuI8bGTTJlBIqKe8XFtC3D0Ye 3lCz0eMnbC8+xIesDsxU7spqtA7biwuVAksHVcHe16FmHS27tHsgJP463xN9GhovFTKJC /5wmR7t/H4Q7BlM2r785TmNT6aRu/axAJgs4aewRQKEHhoZ+31YAbHOtw4cTxbjD4OWCy ploZOYZYJ8oVGV+ly8C8zvLQPgXMRsW0WCdqsFP/T0mvN+3L06nsU20Dn0dL8tHPK0Q== 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.51 Received: from mail-dl1-f51.google.com (mail-dl1-f51.google.com [74.125.82.51]) (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 0AA76606A32C for ; Tue, 1 Dec 2026 04:43:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 0AA76606A32C 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-f51.google.com with SMTP id a92af1059eb24-1aefd1bf74aso7059866c88.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=WynNRlS62uiKFcIEnlnLnk42lXdgj15vsanil4GdBvx7awcppSWRfL7g8YvhpGFefM o54tDpSEDptzGrWev9w23SG2CCYWCwTbktC4Wa4ltH/I+AR6hwBp8VhNrnsTvFLoRJNM FQyahhLVSno1Tnx01BPTC7DmdCjh66aAHFS/yMQ52bA+DgGkwb2whvNIS9y7N7iK+iPB O/53k/EOnNfUD2W8ocQkGx4m6Q6E7RpByyRvqIBwm7ztP0f0n/Ex1ZPEISG0dq2eAhXa dxuJPq6MQTyYndpf0Tl37WyV/gqrbTALelitwiMl6FB6pgOVbGweoNdA8CU4o4L93Jv/ bC9w== X-Forwarded-Encrypted: i=1; AL+hErG3Ge9UrT/46x41Ca314FD1sC7azOhPTjR9b1PfaAYi5aKQ+m7nSubi7GYD1yRn8FGR9wRQpXI=@vger.kernel.org X-Gm-Message-State: APuU4Z8k6s2dhSKESLyoemZGv13Ki0Yx5vbP+lqTFJSGeRURu0grei/F OZSxmlmkQ9EL342Fg+3MUyAlH1Rrq+zmpWKQ4WeUwXsJV79wHsNXfc9V X-Gm-Gg: AZFdTZfr/NeUZqQFQxxrbsZO7KLKR52w3CMIO4Q6ciaYK68JRO5zgmXEoX+HWVfPu3n Iw4lo73wjela6S/kbqwr9X0YBYzxGyKYksHRr4GaBk9dK9gOwybi3RSN5n8sMaClLM2CL59vjsp 6CrZOuqm/jP7m/GijO0E91gPm2+NesPnwvFq3VhVHG/pVsOm6LvRjA+E3rhSp3mfCVRTqtpofIE FsRaQ7djNUvp5YgorlV0PpTCdxReCpqIt8Xrtkl57m2StTbp9/hOIiN0Ogq8XFsPfVJkLCBjHvn eXDDekolxyTszoz7MEnqEk2hLDH+Ko2py4WQjJLY0QyLZ3ujsNrEmwlXHXgdbPSpuIaQwLOAh4e hgN/35IfHDOXxdd8V/rZQA/JqPDx9nSMFGt9M0aNNOELYI419na6+tUTdv13VW2s2SIH+KsAVo8 kOZYhxMGhQsGf67l8ZYdlNKdb2NuvElEeu78E3XSVG4EG7TP3OP+nPSM/IIrtUevtz32UuQb/XK Z6XQFAkaEHwk6BoagxRUeMqofd3NuLca2q04zMACgxwHOYCkOhmdg0u61RFI+qwaJmvrzCr7PNA SMOvZ9jvZCwq0cVgsAD54L7Den0I7lpD+HLhOisTisg+1TPqdIDZmxHt3LdGzVJ+GebeVFlNHKJ oWMsdo6LTW0cPiEYVdGcMz/yFfLiFboF4 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: netdev@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