Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp403958ybx; Wed, 6 Nov 2019 19:27:28 -0800 (PST) X-Google-Smtp-Source: APXvYqzXyje7rYbnCajBRyO76X3TUgnXrslJhkWVYt37z1Hw5UFuJSGTTmaeUihdc5CMM+LWFv6Q X-Received: by 2002:a17:906:7c4e:: with SMTP id g14mr966135ejp.150.1573097248423; Wed, 06 Nov 2019 19:27:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573097248; cv=none; d=google.com; s=arc-20160816; b=GDbRcR0/b3Hcf+6UM4E54/2LAzt/I2B8a7vk1tYC/aWFyWaXY6kehhNm/7gvD8zDZw IvIo3mZPDU3tx1YLYiWSJWX5SM6aniOVlC4flk5uZzC1Rjlz+P9d3EwSRoTVUqX9Zyr/ 02B/xRt4aOr1Mgip9oWVi4EOHuapCZKvoNclEgPfxZ0u5M+RmlOgGXyiCq4pVna+dKP5 eBSHjriGNRaw24B/d9G9tOOaZOQmz/enC2PG0cb2BoxrznBZ4zTjn8W0xbq+1OCW/x2h e4rs5D4eNTpfAc6vlSXfO0RkYKQb/ZhqPvdwnwHIw3Zd/FCH1Q18troQZttwTy4qLwlK 0iSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=i7lPlVFXCwaRBfgllPbIuG84TNHexMw3eUuR2CC5D+w=; b=kmPCOWhQdhKdpKkYbTdUqGTzbt8X4G3EAd8z31hjHSR+UEV3tECKq1qWeZlcJoJNWd PLwyoVqnhsOyPohJnw5x9F8X12Pk8bfhcotZ+spUqbf65RVQJX+qLYCeKa0r0wylvmiC ixTMOGhFMVg74txqLzJsV7y49QmileT6scqrj5tJZ7SVAv/g1pccwzCGN+H8I2wlVtpR A37PTUs4dYnax6r0Bm7kUUu9/M+K6byMhSQT9/XQyB2W/8REKtfrXWF+IOwsOAIHhKfM qLTsfkXZqojZCSU1NZ+TdX1gMsCnzbukPVIttyNh+r0v98BoTRhoBOT4iu595NM4wMxv jzeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=U6lX2Zno; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c8si622331eja.67.2019.11.06.19.27.04; Wed, 06 Nov 2019 19:27:28 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=U6lX2Zno; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733051AbfKGD0W (ORCPT + 99 others); Wed, 6 Nov 2019 22:26:22 -0500 Received: from mail-yw1-f67.google.com ([209.85.161.67]:41267 "EHLO mail-yw1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733026AbfKGD0W (ORCPT ); Wed, 6 Nov 2019 22:26:22 -0500 Received: by mail-yw1-f67.google.com with SMTP id j190so137932ywf.8; Wed, 06 Nov 2019 19:26:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=i7lPlVFXCwaRBfgllPbIuG84TNHexMw3eUuR2CC5D+w=; b=U6lX2ZnoRL0dPtyIBg3cnH1/TPonJFZeawdSmmx8HafU1R9vc8NgDfKIfFiRn1DLsT xuzIT/EJZS/g4PBS1rE64BaSe5ZDXrD3YgnbYpWrufF4vn/g2cLk9zO16yVgO9zMuNJu vQ5IfyhA3YWuHgaVKkpvSEY87oe8f20BHwHbJDcj0TO11Q4js0ygOY+3LcyAQcOW2507 ifBM+jSUcs64gAI/WoP5N21XWSc4xrNHBdCETj9EsIlg7z3VePG/OYhCFJqaO5sUdxcf NTuhabHP7O0Uid3IhdC1uJ2rahOIjp2VPcct7nCtxq8imj5R569nxmL/6wHlgmsAhgEw Ss2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=i7lPlVFXCwaRBfgllPbIuG84TNHexMw3eUuR2CC5D+w=; b=PS/NYarti70Qs6/jlwl/L9vQhUH2do03hJbJfLqJ1vSt26ggmOf2ag1agP0xBbCbyu OVxh4u3q3JPsQDpLfNYQuIfWCPg4n/tH+0cXZp/rdNzEOUIcg24m1eNSenaui+B5BOyW PuXcviUp3DsbkO+TQZ0pr/LxGtR4jVonmqA/WmgxRePk3z00Pd1PPJEAnroesh/nFLL8 UAYZyzpdNJKhnpMRxR6HbeHKYK4qx/pby26H/zq4J/cyKx3rPZtwNaxZDnfA/zqJHpfH qnGqTJqSfPf4YOx/IPXicBlytGHWdL7lp6Dzi611ChgWFmf/bgR+W85dalekLgBpRa8K Fecg== X-Gm-Message-State: APjAAAXHciP5CkONK79/HF1w4oassPdQEVqkSMkiccy+d3j1hpFc0Q3g zTxG2qrFUKZmCEzG3Yt5M7DnAbI/Ln0= X-Received: by 2002:a0d:ddc3:: with SMTP id g186mr721122ywe.201.1573097178953; Wed, 06 Nov 2019 19:26:18 -0800 (PST) Received: from localhost.localdomain (cpe-76-177-112-180.natcky.res.rr.com. [76.177.112.180]) by smtp.gmail.com with ESMTPSA id i190sm276826ywg.1.2019.11.06.19.26.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 06 Nov 2019 19:26:17 -0800 (PST) From: Bradley Bolen To: linux-mmc@vger.kernel.org Cc: ulf.hansson@linaro.org, kstewart@linuxfoundation.org, tglx@linutronix.de, avri.altman@wdc.com, wsa+renesas@sang-engineering.com, yinbo.zhu@nxp.com, hongjiefang@asrmicro.com, linux-kernel@vger.kernel.org, Bradley Bolen Subject: [PATCH v2] mmc: core: Fix size overflow for mmc partitions Date: Wed, 6 Nov 2019 22:25:59 -0500 Message-Id: <1573097159-3914-1-git-send-email-bradleybolen@gmail.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- drivers/mmc/core/mmc.c | 6 +++--- include/linux/mmc/card.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index c880489..fc02124 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 -- @@ -362,7 +362,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 9b6336a..b59d35b 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.7.4