Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3678632pxv; Mon, 26 Jul 2021 09:14:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyl92u5BP8K/7Cg7KveaSLGR1F8yBgY+87yd1Kp1mRhCFGgeRwqb8agtAvwoEIekTczuRRK X-Received: by 2002:a17:906:888e:: with SMTP id ak14mr486762ejc.134.1627316039831; Mon, 26 Jul 2021 09:13:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627316039; cv=none; d=google.com; s=arc-20160816; b=MSWzPzjUKVCvsl1cl/c74tUJxYHYdad5qlR0HCLlLcUtiLfZDRfcXM54Zh2PX5lwlM HmAW8m6XhrHcDoODumD/9fxnSG1Xy5A1alMEeX93lm6H15fqu7GoCooe+h8GdrlM5SM0 EHnLToy1pnzLJ1EiX0gDsqvXI+Lxqk4qKsWMHaTO0YKy7J/xa6rzf/XmMP2pjs+uAciV PMGLJ4dALP+c44svkYgl9TVHLSdkcsnrEfyG78Z9yKlYu8MBG7onDoTRg4/siyNZpGQ1 f/u9U1MICYSikYIt8G+kJZIZU7rbxelJ//4jQsAqg4+3ftHRboJdYeBZiOj1UrkQ39pY pt7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=fyPJJo4L0XgwYMhLWU5olgVoEuSnPCl/zo+r263Lsq8=; b=cDdaJLn5UtXoa4vcKiTxQoCiuq25k/ffWcBQcmKklzQhh8S4JAmhkdZgRrRtKMLsaj 4mN3b6xv1swyZ74pY+7vFllD6Yofzi+AKh4pUAnLenziqaTeDBfZKLYdioEIx8Gum2kh C05SG4iFkuo4tsu9fp55bTU9M50V7srEuD+Ew86zpdNx7qM/lpr1xyUMloI8/CZS8dQ5 Jwv6RxnwaZEyQjKABuMqfROH9OZPhoSJpo1wDs2+ZH+KbKOBieYOgaQ2Qll1BTt6FOUe 6RHSnfTAEhFqobSOMgssQuSar0YzkazX8xcnvrySuvClJHIP7fxO3l5J8KxPZ5UMXuYg TrWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="x89/yefv"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cw2si250592ejc.730.2021.07.26.09.13.36; Mon, 26 Jul 2021 09:13:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="x89/yefv"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232935AbhGZP2h (ORCPT + 99 others); Mon, 26 Jul 2021 11:28:37 -0400 Received: from mail.kernel.org ([198.145.29.99]:54248 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237419AbhGZPPo (ORCPT ); Mon, 26 Jul 2021 11:15:44 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1522460F44; Mon, 26 Jul 2021 15:54:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1627314895; bh=b4jyb8tQKBwTQ3tPaTVyQQni4alkBWFwWHERT/spFs4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=x89/yefvDfcy5q3XqguWRzfyk11pdZQ/cwE7kxXo53WLAKuhrINFxVtutv8AHbEgW OdKALvrFY6A2WKrQtePc/nDJoR8Tz4ocSmYJOG9QPBQ+I6hNMzqvLj/OShqhmzenAV aQdhexAH7ZDzev0CL8ybArcSXXHHPxLe8l6kYPBo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Aleksandr Loktionov , Grzegorz Siwik , Arkadiusz Kubalewski , Slawomir Laba , Sylwester Dziedziuch , Mateusz Palczewski , Tony Brelinski , Tony Nguyen , Sasha Levin Subject: [PATCH 5.4 011/108] igb: Check if num of q_vectors is smaller than max before array access Date: Mon, 26 Jul 2021 17:38:12 +0200 Message-Id: <20210726153832.064840350@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210726153831.696295003@linuxfoundation.org> References: <20210726153831.696295003@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Aleksandr Loktionov [ Upstream commit 6c19d772618fea40d9681f259368f284a330fd90 ] Ensure that the adapter->q_vector[MAX_Q_VECTORS] array isn't accessed beyond its size. It was fixed by using a local variable num_q_vectors as a limit for loop index, and ensure that num_q_vectors is not bigger than MAX_Q_VECTORS. Fixes: 047e0030f1e6 ("igb: add new data structure for handling interrupts and NAPI") Signed-off-by: Aleksandr Loktionov Reviewed-by: Grzegorz Siwik Reviewed-by: Arkadiusz Kubalewski Reviewed-by: Slawomir Laba Reviewed-by: Sylwester Dziedziuch Reviewed-by: Mateusz Palczewski Tested-by: Tony Brelinski Signed-off-by: Tony Nguyen Signed-off-by: Sasha Levin --- drivers/net/ethernet/intel/igb/igb_main.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c index bf8da4869c0f..35b096ab2893 100644 --- a/drivers/net/ethernet/intel/igb/igb_main.c +++ b/drivers/net/ethernet/intel/igb/igb_main.c @@ -940,6 +940,7 @@ static void igb_configure_msix(struct igb_adapter *adapter) **/ static int igb_request_msix(struct igb_adapter *adapter) { + unsigned int num_q_vectors = adapter->num_q_vectors; struct net_device *netdev = adapter->netdev; int i, err = 0, vector = 0, free_vector = 0; @@ -948,7 +949,13 @@ static int igb_request_msix(struct igb_adapter *adapter) if (err) goto err_out; - for (i = 0; i < adapter->num_q_vectors; i++) { + if (num_q_vectors > MAX_Q_VECTORS) { + num_q_vectors = MAX_Q_VECTORS; + dev_warn(&adapter->pdev->dev, + "The number of queue vectors (%d) is higher than max allowed (%d)\n", + adapter->num_q_vectors, MAX_Q_VECTORS); + } + for (i = 0; i < num_q_vectors; i++) { struct igb_q_vector *q_vector = adapter->q_vector[i]; vector++; -- 2.30.2