Received: by 2002:ac0:a591:0:0:0:0:0 with SMTP id m17-v6csp1412137imm; Thu, 5 Jul 2018 22:54:24 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeq1h2Wrr77podW1rnwVwMi+mcqzV69TewisH70T5Rya5gZeQ8tgxTM7vsbaX/lXVh11jHT X-Received: by 2002:a17:902:b581:: with SMTP id a1-v6mr8976971pls.338.1530856464579; Thu, 05 Jul 2018 22:54:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530856464; cv=none; d=google.com; s=arc-20160816; b=wSkJps7tqj0Qp9CPcO2xPF8vR6OayGUlnooyTkBGuqnfGClKED41yathD+GBeCiJmT 1NJMqXvPKD5FnKYiUcjzvcLpK9i7LZRO59L3IazJY/713ReZUo1S/O7Cm7Vo3xTHuo8N r6jMt2XmZmn2d+XjkZdom8R5qhepvV6UUgo8JHiAqyvk8Cn3BkQrIrYS1gVaqn5UQ8KD RvYu5b9/CJ4gyw2LbrJaOEdguDb3o0ZLYdY9A+QBtR8cPRFoEPrzKkmNiU4VeM20G/Et JTAWafm9rQ+RFeuqdNAIqUO+I/3zaV2DhLA2T29fyAFub6cjHhtsghsNUlZaj3IH/E/U ARiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=EUTGUZZBFzz/M/fuZqkBmO7X2je5DrMAmhe4vDQM294=; b=FT0ZSCRDC4EC6nJ28xNcCQbaJvFBcUCUUeAfMq4l4oFHGQsjjiIF656BgHvt1Y2fBu U6zDR6P/iH4wvQEw4XQ67LyKNxOIVs2etDM8DrwZQyUk05AUFL4sJIHO55wiEM8OslFg grNa0WF3Vi4kdn6xInyNM603Toefi1Uc/WBPN/iy+wGKclkI8U6BR30gfj+KZofDBhkJ YMM81f7IVvyBgm11Yn9I2vzBhYFSvhbQWz2GTiClZeiE9WRbbSw2HSlOiAEcmo8mJ1fo tP3/jkknW4BGyeqxXf2/ZksthSHTzGVzXzL+TmV+C0Vk6CEaFOQrDfhzmgniub7ElyCD ralw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a7-v6si8099500pfg.200.2018.07.05.22.54.10; Thu, 05 Jul 2018 22:54:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934707AbeGFFwu (ORCPT + 99 others); Fri, 6 Jul 2018 01:52:50 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:33988 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934657AbeGFFwq (ORCPT ); Fri, 6 Jul 2018 01:52:46 -0400 Received: from localhost (D57D388D.static.ziggozakelijk.nl [213.125.56.141]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 345AA898; Fri, 6 Jul 2018 05:52:45 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hao Wei Tee , Sara Sharon , Luca Coelho , Kalle Valo , Sasha Levin Subject: [PATCH 4.14 51/61] iwlwifi: pcie: compare with number of IRQs requested for, not number of CPUs Date: Fri, 6 Jul 2018 07:47:15 +0200 Message-Id: <20180706054714.295152969@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180706054712.332416244@linuxfoundation.org> References: <20180706054712.332416244@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Hao Wei Tee [ Upstream commit ab1068d6866e28bf6427ceaea681a381e5870a4a ] When there are 16 or more logical CPUs, we request for `IWL_MAX_RX_HW_QUEUES` (16) IRQs only as we limit to that number of IRQs, but later on we compare the number of IRQs returned to nr_online_cpus+2 instead of max_irqs, the latter being what we actually asked for. This ends up setting num_rx_queues to 17 which causes lots of out-of-bounds array accesses later on. Compare to max_irqs instead, and also add an assertion in case num_rx_queues > IWM_MAX_RX_HW_QUEUES. This fixes https://bugzilla.kernel.org/show_bug.cgi?id=199551 Fixes: 2e5d4a8f61dc ("iwlwifi: pcie: Add new configuration to enable MSIX") Signed-off-by: Hao Wei Tee Tested-by: Sara Sharon Signed-off-by: Luca Coelho Signed-off-by: Kalle Valo Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/net/wireless/intel/iwlwifi/pcie/trans.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) --- a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c +++ b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c @@ -1499,14 +1499,13 @@ static void iwl_pcie_set_interrupt_capa( struct iwl_trans *trans) { struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); - int max_irqs, num_irqs, i, ret, nr_online_cpus; + int max_irqs, num_irqs, i, ret; u16 pci_cmd; if (!trans->cfg->mq_rx_supported) goto enable_msi; - nr_online_cpus = num_online_cpus(); - max_irqs = min_t(u32, nr_online_cpus + 2, IWL_MAX_RX_HW_QUEUES); + max_irqs = min_t(u32, num_online_cpus() + 2, IWL_MAX_RX_HW_QUEUES); for (i = 0; i < max_irqs; i++) trans_pcie->msix_entries[i].entry = i; @@ -1532,16 +1531,17 @@ static void iwl_pcie_set_interrupt_capa( * Two interrupts less: non rx causes shared with FBQ and RSS. * More than two interrupts: we will use fewer RSS queues. */ - if (num_irqs <= nr_online_cpus) { + if (num_irqs <= max_irqs - 2) { trans_pcie->trans->num_rx_queues = num_irqs + 1; trans_pcie->shared_vec_mask = IWL_SHARED_IRQ_NON_RX | IWL_SHARED_IRQ_FIRST_RSS; - } else if (num_irqs == nr_online_cpus + 1) { + } else if (num_irqs == max_irqs - 1) { trans_pcie->trans->num_rx_queues = num_irqs; trans_pcie->shared_vec_mask = IWL_SHARED_IRQ_NON_RX; } else { trans_pcie->trans->num_rx_queues = num_irqs - 1; } + WARN_ON(trans_pcie->trans->num_rx_queues > IWL_MAX_RX_HW_QUEUES); trans_pcie->alloc_vecs = num_irqs; trans_pcie->msix_enabled = true;