Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp883083pxk; Thu, 17 Sep 2020 20:15:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyUjp9F/a1XVVWJeRFWPt4LTyJ+OPHtlIPQjB2YLcWRM4AUPCf/BUODqJHCBaH15aVoGKJQ X-Received: by 2002:a17:906:c0d1:: with SMTP id bn17mr32788404ejb.311.1600398956391; Thu, 17 Sep 2020 20:15:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600398956; cv=none; d=google.com; s=arc-20160816; b=EXC30PQM6W4l+oN5F4DPNoFbo4m2pbEcXp02SexAnjQaxMaYwTEWT7dCyCM6XqrK1R ABrt0TqouCCQKyvxsWhdE+4zh/yUIfBWoemqJ3NmTlPX1TVQE55oTOjrjf6QBH3EkDeJ 39MDNE9MbPUQkOlzoT9BzJDaeRfmt3vZloO6y3/D+ikjTsc1XEUvNmVaNOw7WJcC5rFy /PmCKYcOSVxVwoRWUd5wCU5qtov3YFguRaiEepIXqitZVLkhr7jpzhxcKh39dTmF4NhS WemLt45lF3rJab7ZHDqFtaZsU1eQbuVUOdnHsXVd71j5wQpp/6cKUdvtunVx9LE88bkw /5cA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=6F9426RvSVL9hEBWYSahsM81Ry/adC5N8yII7J61h+M=; b=KLPZBNQE+yP/4cELC2kKKSEseNfzNzrh7zfv8ZHc065nPqCxJ0Ogulm+kz70FLHYTU IA6xjE6TQVIUqRz1nI1ISNngLLYAZH5/6ZAyT6Gvjdmj4KHelgz1w0LZ/P88ZijJsep1 pWPBzybtREud+UB6knpLIM+9GeA4zIyagvWU8W/gfzd2ygS9bdkAlQ5IUxJflZfaAsXW lASbPtbSJhvdV33gcdAVyAmWu0Hk8+kkdDR2qIpPhYV6d5o9qIm/kbDypuHF+CFEgalN 7P2pd4EiU1fkolN86G9IRT9d1GBvM8PNGITrsceyRAHDIj+xFSleUHERK3pyKpVXgcDC +Reg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=dWFQ1Z+p; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a15si1129520eds.350.2020.09.17.20.15.33; Thu, 17 Sep 2020 20:15:56 -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=@kernel.org header.s=default header.b=dWFQ1Z+p; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728286AbgIRDLy (ORCPT + 99 others); Thu, 17 Sep 2020 23:11:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:47314 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726713AbgIRCCR (ORCPT ); Thu, 17 Sep 2020 22:02:17 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E6AC72344C; Fri, 18 Sep 2020 02:02:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600394536; bh=C38Pw512GiRJJmiYpDblaE9vHIMrSG1yDZ7v6tJDsU0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dWFQ1Z+pP2Ga5y5/JzDQla4q/lW+5xJApKIgVSINGmEikpfl9ULw/0OPc2sKXwAuO GLvQJ85l8PGdBOANE6QkI1u1u6CfdWjgaKNX5KJFQJ10by+iP/cT+u221x1Vjl+VJJ hu24/ioJer3q1+FLWGWAMGVdgj3lyRfy2B+KNNEM= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Bradley Bolen , Ulf Hansson , Sasha Levin , linux-mmc@vger.kernel.org Subject: [PATCH AUTOSEL 5.4 055/330] mmc: core: Fix size overflow for mmc partitions Date: Thu, 17 Sep 2020 21:56:35 -0400 Message-Id: <20200918020110.2063155-55-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200918020110.2063155-1-sashal@kernel.org> References: <20200918020110.2063155-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Bradley Bolen [ Upstream commit f3d7c2292d104519195fdb11192daec13229c219 ] With large eMMC cards, it is possible to create general purpose partitions that are bigger than 4GB. The size member of the mmc_part struct is only an unsigned int which overflows for gp partitions larger than 4GB. Change this to a u64 to handle the overflow. Signed-off-by: Bradley Bolen Signed-off-by: Ulf Hansson Signed-off-by: Sasha Levin --- drivers/mmc/core/mmc.c | 9 ++++----- include/linux/mmc/card.h | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index b7159e243323b..de14b5845f525 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c @@ -297,7 +297,7 @@ static void mmc_manage_enhanced_area(struct mmc_card *card, u8 *ext_csd) } } -static void mmc_part_add(struct mmc_card *card, unsigned int size, +static void mmc_part_add(struct mmc_card *card, u64 size, unsigned int part_cfg, char *name, int idx, bool ro, int area_type) { @@ -313,7 +313,7 @@ static void mmc_manage_gp_partitions(struct mmc_card *card, u8 *ext_csd) { int idx; u8 hc_erase_grp_sz, hc_wp_grp_sz; - unsigned int part_size; + u64 part_size; /* * General purpose partition feature support -- @@ -343,8 +343,7 @@ static void mmc_manage_gp_partitions(struct mmc_card *card, u8 *ext_csd) (ext_csd[EXT_CSD_GP_SIZE_MULT + idx * 3 + 1] << 8) + ext_csd[EXT_CSD_GP_SIZE_MULT + idx * 3]; - part_size *= (size_t)(hc_erase_grp_sz * - hc_wp_grp_sz); + part_size *= (hc_erase_grp_sz * hc_wp_grp_sz); mmc_part_add(card, part_size << 19, EXT_CSD_PART_CONFIG_ACC_GP0 + idx, "gp%d", idx, false, @@ -362,7 +361,7 @@ static void mmc_manage_gp_partitions(struct mmc_card *card, u8 *ext_csd) static int mmc_decode_ext_csd(struct mmc_card *card, u8 *ext_csd) { int err = 0, idx; - unsigned int part_size; + u64 part_size; struct device_node *np; bool broken_hpi = false; diff --git a/include/linux/mmc/card.h b/include/linux/mmc/card.h index e459b38ef33cc..cf3780a6ccc4b 100644 --- a/include/linux/mmc/card.h +++ b/include/linux/mmc/card.h @@ -226,7 +226,7 @@ struct mmc_queue_req; * MMC Physical partitions */ struct mmc_part { - unsigned int size; /* partition size (in bytes) */ + u64 size; /* partition size (in bytes) */ unsigned int part_cfg; /* partition type */ char name[MAX_MMC_PART_NAME_LEN]; bool force_ro; /* to make boot parts RO by default */ -- 2.25.1