Received: by 10.192.165.148 with SMTP id m20csp4193621imm; Mon, 30 Apr 2018 13:35:16 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqOoUHHrhhW93zUOz48QRF7VGmP9e6tcsBNhXZS9/b7vCRAKUsdXhzzgD55bmT2+/Z5pbMj X-Received: by 2002:a63:7e09:: with SMTP id z9-v6mr11225298pgc.437.1525120516689; Mon, 30 Apr 2018 13:35:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525120516; cv=none; d=google.com; s=arc-20160816; b=oyNUVQu3EhQi6e2c0s5Z/PKrGFV2lOhR35IoSSp/rbXow4FYN9NVmIcdgNTNeXA0L2 jgaVdkxOpt6bX4oqrbgdXxglrXZvnrtGL9eKs7V1FQmKRy6Ic5FUmBHbpq+c62y6ZPQJ 0Eo5PDlk0GP0OmwTWoS/SxO3rrp8zfRAP6T0L2b/PqiNgcfpO1E/1tEfuJ9fdXBqJy4V 714bA8yUhqLNwZEKZdz6THHK0rtOsrtpGiF0RFB/swCmhznVypvs52MHwXSYvt2hSjVL R/9UvsCq+OJ4eHQVUMtEZa+sjqwNwHwbmBihzRAOR1wGTsOWJnKGM79HOiMmUisZaj2C JZgg== 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:dmarc-filter :arc-authentication-results; bh=mCTxIxcdPDpuUA8nso5b0plFd7rQq89H2BdwGXy5AU8=; b=eALKSCJO8LT57zGFA8UyPJeBOAqfoYMwEjZtfY+cCzV0HcPuXG4kRmUCHXxwF88b3B 1mgirO+eugAMN6MscASi7jGBCyMqYAYLykg47IiuFf7mBlUdHiIYlkXajJY+cqkGjuHP LOWm6yuogRrKABnhS3I37OxFKz4J9oU4RHb+vNMCZWmACkCvXSJvVRxatQzzMWMIdCjy 7t0p23VQbhB26eG/HeIv/1m6mSTSpmhWPBv+VhU/Sf7saTZbJxId8j98ezBx2cn66+yj pcMLnlExcjRZCBfj5OEfwQrUH5hwbzOfrmKU7gw52LxlSYHW88tsfy6IiMLlFU7WhtoD J6WA== 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 34-v6si7992261plb.230.2018.04.30.13.35.02; Mon, 30 Apr 2018 13:35:16 -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 S1755551AbeD3Ueu (ORCPT + 99 others); Mon, 30 Apr 2018 16:34:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:59088 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751195AbeD3T0A (ORCPT ); Mon, 30 Apr 2018 15:26:00 -0400 Received: from localhost (unknown [104.132.1.102]) (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 5CFC122DAC; Mon, 30 Apr 2018 19:25:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5CFC122DAC Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linuxfoundation.org Authentication-Results: mail.kernel.org; spf=fail smtp.mailfrom=gregkh@linuxfoundation.org From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Joakim Tjernlund , Richard Weinberger , Boris Brezillon Subject: [PATCH 4.4 32/44] mtd: cfi: cmdset_0002: Do not allow read/write to suspend erase block. Date: Mon, 30 Apr 2018 12:24:43 -0700 Message-Id: <20180430190947.617318706@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180430190946.093694747@linuxfoundation.org> References: <20180430190946.093694747@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.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Joakim Tjernlund commit 7b70eb14392a7cf505f9b358d06c33b5af73d1e7 upstream. Currently it is possible to read and/or write to suspend EB's. Writing /dev/mtdX or /dev/mtdblockX from several processes may break the flash state machine. Taken from cfi_cmdset_0001 driver. Signed-off-by: Joakim Tjernlund Cc: Reviewed-by: Richard Weinberger Signed-off-by: Boris Brezillon Signed-off-by: Greg Kroah-Hartman --- drivers/mtd/chips/cfi_cmdset_0002.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) --- a/drivers/mtd/chips/cfi_cmdset_0002.c +++ b/drivers/mtd/chips/cfi_cmdset_0002.c @@ -814,9 +814,10 @@ static int get_chip(struct map_info *map (mode == FL_WRITING && (cfip->EraseSuspend & 0x2)))) goto sleep; - /* We could check to see if we're trying to access the sector - * that is currently being erased. However, no user will try - * anything like that so we just wait for the timeout. */ + /* Do not allow suspend iff read/write to EB address */ + if ((adr & chip->in_progress_block_mask) == + chip->in_progress_block_addr) + goto sleep; /* Erase suspend */ /* It's harmless to issue the Erase-Suspend and Erase-Resume @@ -2265,6 +2266,7 @@ static int __xipram do_erase_chip(struct chip->state = FL_ERASING; chip->erase_suspended = 0; chip->in_progress_block_addr = adr; + chip->in_progress_block_mask = ~(map->size - 1); INVALIDATE_CACHE_UDELAY(map, chip, adr, map->size, @@ -2354,6 +2356,7 @@ static int __xipram do_erase_oneblock(st chip->state = FL_ERASING; chip->erase_suspended = 0; chip->in_progress_block_addr = adr; + chip->in_progress_block_mask = ~(len - 1); INVALIDATE_CACHE_UDELAY(map, chip, adr, len,