From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DB137C7EE22 for ; Thu, 4 May 2023 19:47:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231244AbjEDTrw (ORCPT ); Thu, 4 May 2023 15:47:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231142AbjEDTrC (ORCPT ); Thu, 4 May 2023 15:47:02 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF48E93CB; Thu, 4 May 2023 12:45:02 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 57F0F636FB; Thu, 4 May 2023 19:45:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DDD7EC433D2; Thu, 4 May 2023 19:44:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1683229499; bh=2+TVHQ0x7JBkdhdD8gcqJKqlfWReNNJ0PvWqGtk0d9U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Fn/Bkh3/nAd/ZC9D3y2taSH5Q7dCGltkohtUZafSVfd3cryRPEkLSZyb+lwJHqVeJ VSocJH7kCco0nfWCgVFGBXbI0LMIJWqYY8YYqGSvGWVmxmK15NGwzgXWNjqNNPE+LG AmcQEi9DRH2lyiSC8d2KvmeKman9kDEWqeiBdc3M2iqp3/dbLcOC/m2DRSKf9UzMZu M9YHpITREITasIio6/BH8G0mbWnJk0pFzP1DDqwGfb6PIMUXu0REd80tI40FtiAy0/ GB//XvE/Di0AJma6HPDYbIwzgbdIDXeSOgQdmLf16c8yOs/EiJ544UrBVvG58ANI99 TeqFF6qNDPXXw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Nick Child , Jakub Kicinski , Sasha Levin , davem@davemloft.net, edumazet@google.com, pabeni@redhat.com, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 6.2 15/53] netdev: Enforce index cap in netdev_get_tx_queue Date: Thu, 4 May 2023 15:43:35 -0400 Message-Id: <20230504194413.3806354-15-sashal@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230504194413.3806354-1-sashal@kernel.org> References: <20230504194413.3806354-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Nick Child [ Upstream commit 1cc6571f562774f1d928dc8b3cff50829b86e970 ] When requesting a TX queue at a given index, warn on out-of-bounds referencing if the index is greater than the allocated number of queues. Specifically, since this function is used heavily in the networking stack use DEBUG_NET_WARN_ON_ONCE to avoid executing a new branch on every packet. Signed-off-by: Nick Child Link: https://lore.kernel.org/r/20230321150725.127229-2-nnac123@linux.ibm.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- include/linux/netdevice.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 84668547fee63..138cb4d552e73 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -2445,6 +2445,7 @@ static inline struct netdev_queue *netdev_get_tx_queue(const struct net_device *dev, unsigned int index) { + DEBUG_NET_WARN_ON_ONCE(index >= dev->num_tx_queues); return &dev->_tx[index]; } -- 2.39.2