Received: by 10.223.176.5 with SMTP id f5csp1036555wra; Fri, 2 Feb 2018 10:04:58 -0800 (PST) X-Google-Smtp-Source: AH8x224SujYG1QRcySEUOlyVaVpKV6GT13u+KfmjIdKD7AUmGwck3YFTRsq3bCnH6EHx3Qc5564h X-Received: by 10.98.49.199 with SMTP id x190mr41088231pfx.1.1517594698057; Fri, 02 Feb 2018 10:04:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517594698; cv=none; d=google.com; s=arc-20160816; b=bijx5slH0wapMvjslJVwFkTp11Tx5F2/G2HlVhbNw7E38YtHRm+JdkYzvdfbOv8dgn enCLDssQOUfmpDdHiRkZmGTFAhaUuw3SpTLnAwZfpaAVQYyNqiqprqtl5q7C1qu6agcv 0ERC7bcYY2jnRFPwr6a0QsPgnus5lovbXKQ1zgbkeMEwAyAXWSt2+1KgXtnJdklGtDLg haCrTtqnluKat1DmRhKgKAx5NzSStK+y8Kfw5muIbdGBlca9e+E/lhZhCia4GPYFMgxI BFQ1Z1sDl9ejKAUQAX1siKNIq5+CQs4sd2exWSNDwXbRmXtuo7bR3OURfKeZFIkFPLuL rT9w== 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=SzQqp1Kh1WzHCrhEY3SYr7rZKd5DqWNOL0tkg/MJfd4=; b=Vn7BwTZoQyDATnrDTUMh2RVU+y+ZjMcPvtEuPNzfadc5SPTVNB6PoqYD76jER34G4b CG/V+D3+vpHq46jxgoN4JB6FDrIZRvOjEOAFCOApOG0M1Gr2nXn0bs0jeNjbh27JjiJn uuNYdZvGbcGMHOWh71KaeMa/0AAxADt2+548Xk7IxTIS3mNQflDUTtEF8XM72cqyDEr6 BrqAeltHxcgSZMEf1BnvES3Wlovgp9fz7emzp5zfpHx8DTocuM3kGKNWxTequPR5hfNv tmnrlEjalFLxnAht+6Bl/mkNeFjFaFx3TqSvLkjpoG0XIbmYD+DbtSbP/0ZwD+Fn7rWR 4HTg== 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 p9-v6si277077pls.317.2018.02.02.10.04.43; Fri, 02 Feb 2018 10:04:58 -0800 (PST) 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 S1752892AbeBBSDV (ORCPT + 99 others); Fri, 2 Feb 2018 13:03:21 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:37840 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752775AbeBBRJN (ORCPT ); Fri, 2 Feb 2018 12:09:13 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 52455DA4; Fri, 2 Feb 2018 17:09:12 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Minwoo Im , Keith Busch , Christoph Hellwig , Sasha Levin Subject: [PATCH 4.14 050/156] nvme-pci: avoid hmb desc array idx out-of-bound when hmmaxd set. Date: Fri, 2 Feb 2018 17:57:11 +0100 Message-Id: <20180202140842.549809202@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180202140840.242829545@linuxfoundation.org> References: <20180202140840.242829545@linuxfoundation.org> User-Agent: quilt/0.65 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: Minwoo Im [ Upstream commit 244a8fe40a09c218622eb9927b9090b0a9b73a1a ] hmb descriptor idx out-of-bound occurs in case of below conditions. preferred = 128MiB chunk_size = 4MiB hmmaxd = 1 Current code will not allow rmmod which will free hmb descriptors to be done successfully in above case. "descs[i]" will be set in for-loop without seeing any conditions related to "max_entries" after a single "descs" was allocated by (max_entries = 1) in this case. Added a condition into for-loop to check index of descriptors. Fixes: 044a9df1("nvme-pci: implement the HMB entry number and size limitations") Signed-off-by: Minwoo Im Reviewed-by: Keith Busch Signed-off-by: Christoph Hellwig Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/nvme/host/pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -1645,7 +1645,7 @@ static int __nvme_alloc_host_mem(struct if (!bufs) goto out_free_descs; - for (size = 0; size < preferred; size += len) { + for (size = 0; size < preferred && i < max_entries; size += len) { dma_addr_t dma_addr; len = min_t(u64, chunk_size, preferred - size);