Received: by 10.213.65.68 with SMTP id h4csp868586imn; Tue, 27 Mar 2018 10:14:55 -0700 (PDT) X-Google-Smtp-Source: AIpwx48yUIqyG42FNilGs4MT80RKkm0LxnR2X56nP8MMaxUZZpmCtBguJkT1xC/yG/x+LmLbZFqW X-Received: by 2002:a17:902:76c5:: with SMTP id j5-v6mr181410plt.166.1522170895235; Tue, 27 Mar 2018 10:14:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522170895; cv=none; d=google.com; s=arc-20160816; b=KwXQHU5XwPKVXIIw+KFZPln7V/l/g+IAbQ0Fh301IkiR8w0DGheoPPCnMnIthM7dmc tFPnqyysI3fIwVkIWcle2dTWlvjJxD8gtYoqa2oGJliBomthkqc5OI2PQR/6A/HZGH5G LL+HHmdiLI9+4r7j5NZHfxPjvhfj8b7evNqy9puJ5GUtcTRihm3rRLByrjbfFvsDX+xG 9IUsEpT3ATvMg6IyEyO0I7hO3uct/LO2TuNBikUMLt42HIrQ4dY1vcOU+D5eRHndWHIX q1Lw7F697Ji87ZCp5eMCLef9h9nmTHKWA0k3VUuFwqR68+1sBMjIFNuy6EQ2Bc5STJ+1 w4iQ== 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=jWcXO8t3Yk6wBva7XOn4pZWt2tkBZdxE4n2rPvm2baU=; b=uJB7DYSk/jiDFx8cW9j/Tgk8KqvS1cksDIV15VIMjg7+GpEjR7KfHMwn66hK72cdhg n5OIfasQc8ep+tVbXPZUqmY/2Zf3lzVyh9/Hw/flqbE/qF0mDbAeoCIHw0gH3ppnh8RU 4TMcak+0bjAkpmaH/YWYfDQ86HLadtq1t4o09jRC4WOCw0JIPkcZ1H2w7vpWn/mcU4ro +zP84wixyocufkA26rWGvMsHhx+KaslVVs2BjHyxX4Eq5sgN57yrqMyzpj5wvJdtsj/Y 1LdLqQnNzb+KZIotNGmvBjiI5chhENDg/j7v/i4NX+4IWx9bhqt3ZOGzLDvKH+XYyl3h /KCw== 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 r2si1115355pgp.704.2018.03.27.10.14.40; Tue, 27 Mar 2018 10:14:55 -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; 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 S932131AbeC0QjJ (ORCPT + 99 others); Tue, 27 Mar 2018 12:39:09 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:47070 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932088AbeC0QjH (ORCPT ); Tue, 27 Mar 2018 12:39:07 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id D06AF102D; Tue, 27 Mar 2018 16:39:06 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Bastian Stender , Jan Luebbe , Ulf Hansson Subject: [PATCH 4.15 018/105] mmc: block: fix updating ext_csd caches on ioctl call Date: Tue, 27 Mar 2018 18:26:58 +0200 Message-Id: <20180327162758.604371066@linuxfoundation.org> X-Mailer: git-send-email 2.16.3 In-Reply-To: <20180327162757.813009222@linuxfoundation.org> References: <20180327162757.813009222@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.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Bastian Stender commit e74ef2194b41ba5e511fab29fe5ff00e72d2f42a upstream. PARTITION_CONFIG is cached in mmc_card->ext_csd.part_config and the currently active partition in mmc_blk_data->part_curr. These caches do not always reflect changes if the ioctl call modifies the PARTITION_CONFIG registers, e.g. by changing BOOT_PARTITION_ENABLE. Write the PARTITION_CONFIG value extracted from the ioctl call to the cache and update the currently active partition accordingly. This ensures that the user space cannot change the values behind the kernel's back. The next call to mmc_blk_part_switch() will operate on the data set by the ioctl and reflect the changes appropriately. Signed-off-by: Bastian Stender Signed-off-by: Jan Luebbe Cc: stable@vger.kernel.org Signed-off-by: Ulf Hansson Signed-off-by: Greg Kroah-Hartman --- drivers/mmc/core/block.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) --- a/drivers/mmc/core/block.c +++ b/drivers/mmc/core/block.c @@ -66,6 +66,7 @@ MODULE_ALIAS("mmc:block"); #define MMC_BLK_TIMEOUT_MS (10 * 60 * 1000) /* 10 minute timeout */ #define MMC_SANITIZE_REQ_TIMEOUT 240000 #define MMC_EXTRACT_INDEX_FROM_ARG(x) ((x & 0x00FF0000) >> 16) +#define MMC_EXTRACT_VALUE_FROM_ARG(x) ((x & 0x0000FF00) >> 8) #define mmc_req_rel_wr(req) ((req->cmd_flags & REQ_FUA) && \ (rq_data_dir(req) == WRITE)) @@ -580,6 +581,24 @@ static int __mmc_blk_ioctl_cmd(struct mm } /* + * Make sure the cache of the PARTITION_CONFIG register and + * PARTITION_ACCESS bits is updated in case the ioctl ext_csd write + * changed it successfully. + */ + if ((MMC_EXTRACT_INDEX_FROM_ARG(cmd.arg) == EXT_CSD_PART_CONFIG) && + (cmd.opcode == MMC_SWITCH)) { + struct mmc_blk_data *main_md = dev_get_drvdata(&card->dev); + u8 value = MMC_EXTRACT_VALUE_FROM_ARG(cmd.arg); + + /* + * Update cache so the next mmc_blk_part_switch call operates + * on up-to-date data. + */ + card->ext_csd.part_config = value; + main_md->part_curr = value & EXT_CSD_PART_CONFIG_ACC_MASK; + } + + /* * According to the SD specs, some commands require a delay after * issuing the command. */