Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1981888imm; Thu, 24 May 2018 04:00:57 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrSxIiZq8nGuoqGpW68YF+h3r++DOUlxrhtWECfbSV7wqF0cSueGPFjbA/UQ/4donTkcp99 X-Received: by 2002:a17:902:bc4a:: with SMTP id t10-v6mr2588132plz.133.1527159657724; Thu, 24 May 2018 04:00:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527159657; cv=none; d=google.com; s=arc-20160816; b=fCrNQiv+ew7witib1gIrxvVoGoTTcpRaV0wVS7E4T/kcEr9dNCDpOdlocP9HUXbUbw aUzqNapaRL4cvKQpKDJUDz8ARg2wl3bgf57KfSN6+qLbA7C4HXUXXzo2k7guPttZR7lM PJHSZ4mV6sgzukLbds2S7r4MgfGAzMJRGsMbsmTrPjz5e4MJbiRrRobvwwuWCKlBs4/x XMeAHT+wQ7cnBRBnGhF7S+2mgqC/WTJecTzQSHxrMawGCU7YB5kw+uoGcf7IuSIqIXzT GIaqgSP9aIBxu8hYuu/bZjEhG+nadtwxjc0BvSU+0OrE6ruLYrbGjjtP/lCjSNOVUz+M xPMw== 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:dkim-signature :arc-authentication-results; bh=nbWVlEK305dyQKLH2eFoeiM524bMRs3buYF0GfBrSsg=; b=nQSHf4dOx2aDbWPNSeEN8riRq21oGxcRjdKHrJCXv6GuHws78m7Kqcu9bTvQyF/xGn IAOBr1x6eGe7vyQmuOVaahnyqxri/AQSyDPS9A85Rl1sS7lVm5yfAlGEzV/WfktrUzU6 U1A4Zr2baH7meJSAIiEudvxiJYBLyp6Q1EILFtUwE9ORXiBWfj8oPqkWiDdKakjkxiMN mBjO+Zy4MlEgdw5CmWfBprtKKVihhAW9Y7t95DBTP/f1tqxvNDOTrihOcEegWF19vVPM c0RwPZF36W5Rg2tDkhoa33+7XqParEQX98fhm2n+aWNnov9a6qlFg4sYf4sgUfsZOxMP TYCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=h8S6oCk9; 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 f7-v6si16955927pgq.393.2018.05.24.04.00.42; Thu, 24 May 2018 04:00:57 -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; dkim=pass header.i=@kernel.org header.s=default header.b=h8S6oCk9; 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 S1030201AbeEXJzs (ORCPT + 99 others); Thu, 24 May 2018 05:55:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:35734 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S967993AbeEXJzk (ORCPT ); Thu, 24 May 2018 05:55:40 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5D12020892; Thu, 24 May 2018 09:55:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527155739; bh=RzrQdfy8O8PaqrPRP2QQSrgmlRSKRrhNUU5d3P6ydJE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=h8S6oCk9hvs6mCmbRqQ+yGeuTk21i13BZbu+LbPkSsYliKpRyrcSHPt5/3BYBqy7a 5dJWbUKMQg8LPxv0wZUg40VjbzfoB0MZfoozfPTfH5BXZxkhetSXpxbb6YF/gs88IM hdT5E5ssxSNp9YWa40U+aYRP/PyBk6iPvt3TsuzM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tomas Henzl , Suganath Prabu Subramani , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 4.14 099/165] scsi: mpt3sas: fix an out of bound write Date: Thu, 24 May 2018 11:38:25 +0200 Message-Id: <20180524093626.022594428@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180524093621.979359379@linuxfoundation.org> References: <20180524093621.979359379@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: Tomas Henzl [ Upstream commit 4a8842de8db4953fdda7866626b78b12fb8adb97 ] cpu_msix_table is allocated to store online cpus, but pci_irq_get_affinity may return cpu_possible_mask which is then used to access cpu_msix_table. That causes bad user experience. Fix limits access to only online cpus, I've also added an additional test to protect from an unlikely change in cpu_online_mask. [mkp: checkpatch] Fixes: 1d55abc0e98a ("scsi: mpt3sas: switch to pci_alloc_irq_vectors") Signed-off-by: Tomas Henzl Acked-by: Suganath Prabu Subramani Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/scsi/mpt3sas/mpt3sas_base.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) --- a/drivers/scsi/mpt3sas/mpt3sas_base.c +++ b/drivers/scsi/mpt3sas/mpt3sas_base.c @@ -1921,8 +1921,11 @@ _base_assign_reply_queues(struct MPT3SAS continue; } - for_each_cpu(cpu, mask) + for_each_cpu_and(cpu, mask, cpu_online_mask) { + if (cpu >= ioc->cpu_msix_table_sz) + break; ioc->cpu_msix_table[cpu] = reply_q->msix_index; + } } return; }