Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1693271pxb; Thu, 16 Sep 2021 13:09:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxogdmESr5b9GWIJ+IesvpEe/TkdVlMcXy27nsGP4EiVnPu3jILaaUU5OQDHwW/QCYVeKu5 X-Received: by 2002:aa7:ca19:: with SMTP id y25mr8295634eds.197.1631822945086; Thu, 16 Sep 2021 13:09:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631822945; cv=none; d=google.com; s=arc-20160816; b=TTGjwx1WQnp69P6GN6hEdJ22Gw+8v+yASGbBHVFdvQzN+So3Sb2CWpGAUno348wfDe XpdgiNQjsmPXuJJk8DrL+N0Z9QIrIL9zJ0rvWua3jtyAfqFBlJ4FSNKSmQFROgSSgj2l KUsnQhmbB+NYbbVp5qSfStcHM400CbTW5PAWa+VNJ2DpKz6mQvQYVL5906l2hrC/6L3S y6HaOcuVG9n4h3ye4i7cwjlkExHbbd6K475MLh8Ck6O/iwv/8hsrBrnbVcAv5OghPnPU DbFok+S6hiZj4Nj0vtPLnW3PkQB/zakl5WJoHaEbMXjE2g6YI2hjKhcMqzKUr22dH7B4 Hvmg== 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=G4bY7X9xPQLjmX/rJz1EHh3wUpgsFbPYX2dDQfc+2I0=; b=xOJEd2pf9XS907G32aZjtFQC63d34qPoSqmvsxrRXxXtgkwmDbXFSyzB7kLEVRYz5R kW3Sw2zOM7hy5JraJmt98plER9lLAfCd/LiMM5OzLNlyfi5adEYQ5RVwDXT0SdcYJeAk ZZ4FI3UfIpw/nKq4V7AucwX0QXyUKEwij5MqAe7RMRZL71q+Lqy15SgUKb3cg5RObTsg 5eavBjkwTfRNQ5HC07lKvwzBysJNeVN1clWJjidx7V2gcRmInBj3K14p3oqp1q5g7g4/ WdFETBKlZT8iWcBC4Xi7Zi7wvj0xb7gW+1Ej6m/hk3ZFeJSmbl73CqmEjGngw0VVoaVJ qXvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=kyjXJLTr; 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 n10si4466315ejk.210.2021.09.16.13.08.41; Thu, 16 Sep 2021 13:09:05 -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=kyjXJLTr; 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 S239683AbhIPQUj (ORCPT + 99 others); Thu, 16 Sep 2021 12:20:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:49032 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239057AbhIPQLo (ORCPT ); Thu, 16 Sep 2021 12:11:44 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6317961371; Thu, 16 Sep 2021 16:09:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631808546; bh=WygAbG7iP1zh71CPbUOS9aJO6ys4FnuEnntvpvMb+oM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kyjXJLTr/xxldxkV31V5tHBy17nX0U0p/Sbv5mJPMbgUkui2YvjisH6jIfvbFa8mm 0OTOXw/F7TOI+3+1Ur+AEWZ8opQB+5ho7Qq4whS62gEuF6784GiOP8RO2yHiHU7raB WoIXgeIKF4Gtlz7Yblo0EowWvMJHCRVJsQnLkwMs= 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.10 131/306] igc: Check if num of q_vectors is smaller than max before array access Date: Thu, 16 Sep 2021 17:57:56 +0200 Message-Id: <20210916155758.522878765@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210916155753.903069397@linuxfoundation.org> References: <20210916155753.903069397@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 013dd2955381..cae090a07252 100644 --- a/drivers/net/ethernet/intel/igc/igc_main.c +++ b/drivers/net/ethernet/intel/igc/igc_main.c @@ -4083,6 +4083,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; @@ -4091,7 +4092,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