Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp2249294ybd; Mon, 24 Jun 2019 03:17:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqwLVKmO6jU2HzRST336DIkJHWgvew9tDKDYVAhuwSKy8lPBl1M4njhqegsG6MNYA7dJwxmh X-Received: by 2002:a63:205b:: with SMTP id r27mr32578001pgm.330.1561371434650; Mon, 24 Jun 2019 03:17:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561371434; cv=none; d=google.com; s=arc-20160816; b=ds3/O51OmZu24pDQQ+ZOepMmj46nVT0eKkmTlr+ZXUUatpiqvu0aGe6JEE2btKYiia UI9bjnhYPPEbHHjxE9K8qJ6fyOZEzwa8Y4iHNf9N6Gxp+HYhjoWagEbTIte5Wx6Lu9eT gnb5GCRDJbWPTqBvEO9Y1Y6Nuc2z5aHeBbauTa8TyhKoebhpZ0/PEsAGfdNvAoSNj60g 3tPSYfHej2lOEdtjptNcTWvxCZ16SFM4D+oNuP7/2L2zhdP2XQLiFbSRR/b/s7xkrck0 ucVm2lOSEo2B/87lKPRqB9ttm0VNm8lyjLJBdN45xorTZh3nAoxWJiIx4ADl84UqUnLx l4bQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=qMv36LG5ykGtg35EI9fZngLjXFDdzg4Wm+8WGm0XWSQ=; b=SDdAbBhWzapmU+hPClHqCGFeB/P18nU4FODComgUzxkUNpl34vYkJX9n4BXrpAwt2J dfOh9xoMyWn9t6iJ6AoDz3jZYa7/y66yA5pfuYgf0R70aCtsNDb2oJJK/A/R7q2bVuTt f0qvh7f4JrZCrSpXLXIriDNsAKfUVNgPkyDOvFl8PQvjh82m2unNoAQ9C05WhdkKa2kU KyoKB2cu8YWQ2hBGul+LXJxy112jIHImRwTSUjGb9i6DUA/6ZAoA1DOS3QnLpqPKVaYw N9eKwZWNJqAY5Um+4pKj8rKCU1T9tHWQHS268dka8HGUQ5Mwbyfr5KBuOG3wPjI6ORaK 4x8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=fw+LhZGK; 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 z2si9316500pln.247.2019.06.24.03.16.58; Mon, 24 Jun 2019 03:17:14 -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=fw+LhZGK; 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 S1729742AbfFXKQi (ORCPT + 99 others); Mon, 24 Jun 2019 06:16:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:54110 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730759AbfFXKQf (ORCPT ); Mon, 24 Jun 2019 06:16:35 -0400 Received: from localhost (f4.8f.5177.ip4.static.sl-reverse.com [119.81.143.244]) (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 C96F721473; Mon, 24 Jun 2019 10:16:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1561371395; bh=ZoUvg6Cuj0gLOckE2E1pb8pVmMdC6IXEbv+tF/XOAV0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fw+LhZGKx+1GB6Th3Zjyra0OgWQNqdTwEbqimPd5LCnajMQPLpfAaM2Xj1umuzarp 67NpV8ib+33pjCG3BlaP9LS/nddAjqJdKGlqpcviu1srZjbz5xunZjQUqwrafti03S JDdIKeURdtXRdBqbtmJCRbLrN75dVb2G/afyKuLU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jaesoo Lee , Christoph Hellwig , Sagi Grimberg , Sasha Levin Subject: [PATCH 5.1 088/121] nvme: Fix u32 overflow in the number of namespace list calculation Date: Mon, 24 Jun 2019 17:57:00 +0800 Message-Id: <20190624092325.313690600@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190624092320.652599624@linuxfoundation.org> References: <20190624092320.652599624@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit c8e8c77b3bdbade6e26e8e76595f141ede12b692 ] The Number of Namespaces (nn) field in the identify controller data structure is defined as u32 and the maximum allowed value in NVMe specification is 0xFFFFFFFEUL. This change fixes the possible overflow of the DIV_ROUND_UP() operation used in nvme_scan_ns_list() by casting the nn to u64. Signed-off-by: Jaesoo Lee Reviewed-by: Christoph Hellwig Signed-off-by: Sagi Grimberg Signed-off-by: Sasha Levin --- drivers/nvme/host/core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index 35d2202ee2fd..3a390b2c7540 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -3397,7 +3397,8 @@ static int nvme_scan_ns_list(struct nvme_ctrl *ctrl, unsigned nn) { struct nvme_ns *ns; __le32 *ns_list; - unsigned i, j, nsid, prev = 0, num_lists = DIV_ROUND_UP(nn, 1024); + unsigned i, j, nsid, prev = 0; + unsigned num_lists = DIV_ROUND_UP_ULL((u64)nn, 1024); int ret = 0; ns_list = kzalloc(NVME_IDENTIFY_DATA_SIZE, GFP_KERNEL); -- 2.20.1