Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1902836pxb; Thu, 16 Sep 2021 19:40:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx2PkgVZmJHGPil8K3wN9FiNS6PrUq5TS6acgvX+ybqpM10HkR+ESjEF8mp93WLIAtOhNrH X-Received: by 2002:a05:6638:2183:: with SMTP id s3mr6914535jaj.11.1631846441660; Thu, 16 Sep 2021 19:40:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631846441; cv=none; d=google.com; s=arc-20160816; b=qlGm9K0xVCMAo8PnYB0fCj1EXO9P/RE2Je/+pRjYkG7UMwa0YMPipdi8y9rJ/Ic4Jt OnOAyAfO8/LJkVLyERiUjU9Fh1YhnxfhYP8L4ErLOEY4YSh8kuAPdhEqPTb9V5HP4TmO X+dl5+C0S92w+H2EM8nmU63P7AfUCgvOPoWfnZTyT+RkPdYoWefbtYL8aBC2hCeVH0W1 dekOahQn3evod5FSZ+zFAcM8V7P+wiiIYC97HQnpHoDhmK2QeHZPFSIujMT8Rbz8lLaX +mcjiN6LgScCCJbae20mWhIjRVub46jCj2PuVorhzcHe0GJeZBQ+5GEAeJQyXwxIedQl 7WGQ== 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=309tNI+unOEw2R8dKKbDgrjlvnkzZIyJDaz/qobBRnc=; b=Ri0hNQDoqxGO5W+IwbGgQua/VpvN2FZ9dkRA4Uy3rRMP5P7HJwujgAojiQ4zQFC0uR g7pnHbcdtoch8CwuQ+6Ig7urX7NK6YH6wyWMRq8xnSNePKrAxIFgKa0x480jAFBQSNlk JN+kMVXP3cRw5gZtTG7KkgXO0MBHXlhG+pt7Tm6wdifMsBDtnH3DhcCxYeu2fk8tcdw1 JHv7lWrYh+OVOmL9c/NbdtZlRnY9UVQNAoLC01yUlXq4YogbBlHY7OezdXQgA73HFIJp fTHtBgjhSxgCttWJMHiCAGr08fcPHIa38kgzxNphU+M11T2ztXopy+XYWMhG4ntLj/Qr NGZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Q9BZVAEE; 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 i62si4217841iof.83.2021.09.16.19.40.27; Thu, 16 Sep 2021 19:40:41 -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=Q9BZVAEE; 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 S1347249AbhIPRbU (ORCPT + 99 others); Thu, 16 Sep 2021 13:31:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:44398 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344045AbhIPRWG (ORCPT ); Thu, 16 Sep 2021 13:22:06 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 45B556044F; Thu, 16 Sep 2021 16:43:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631810583; bh=VIATtPJ0D92dbWg+eENiigWc7KCEyc/ZyJO/wyvcxVE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q9BZVAEEMmSAmnL0oTLT00G88e0loDmCak2NtfzD3NVbbvfd1W7d2rBqWbUot6BHJ dgf3ORtjD8QXz7cc8UlkxSk3yxsD6DFHuiX/I4aW8Zh1kRhJ+NEULXHtRL5reS1V9G AYZmcGtoi7i6l4bjBWezluhHfCDCPXRptUkTVBrI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Aleksandr Loktionov , Sasha Neftin , Dvora Fuxbrumer , Tony Nguyen , Sasha Levin Subject: [PATCH 5.14 193/432] igc: Check if num of q_vectors is smaller than max before array access Date: Thu, 16 Sep 2021 17:59:02 +0200 Message-Id: <20210916155817.298427239@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210916155810.813340753@linuxfoundation.org> References: <20210916155810.813340753@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: Sasha Neftin [ Upstream commit 373e2829e7c2e1e606503cdb5c97749f512a4be9 ] 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. Suggested-by: Aleksandr Loktionov Signed-off-by: Sasha Neftin Tested-by: Dvora Fuxbrumer Signed-off-by: Tony Nguyen Signed-off-by: Sasha Levin --- drivers/net/ethernet/intel/igc/igc_main.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/intel/igc/igc_main.c b/drivers/net/ethernet/intel/igc/igc_main.c index ed2d66bc2d6c..f62982c4d933 100644 --- a/drivers/net/ethernet/intel/igc/igc_main.c +++ b/drivers/net/ethernet/intel/igc/igc_main.c @@ -4817,6 +4817,7 @@ static irqreturn_t igc_msix_ring(int irq, void *data) */ static int igc_request_msix(struct igc_adapter *adapter) { + unsigned int num_q_vectors = adapter->num_q_vectors; int i = 0, err = 0, vector = 0, free_vector = 0; struct net_device *netdev = adapter->netdev; @@ -4825,7 +4826,13 @@ static int igc_request_msix(struct igc_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 igc_q_vector *q_vector = adapter->q_vector[i]; vector++; -- 2.30.2