Received: by 10.192.165.148 with SMTP id m20csp4171224imm; Mon, 30 Apr 2018 13:07:49 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqhTl4Fgt2ZG2c1odVKgj/noZbzli8MKvYRHL0WTFMbffnQhjUFCgTWLtE9vwqjkTBRQLec X-Received: by 2002:a17:902:9886:: with SMTP id s6-v6mr13543176plp.380.1525118869754; Mon, 30 Apr 2018 13:07:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525118869; cv=none; d=google.com; s=arc-20160816; b=Sdb/E2ZeMtuShTrsCm79GYtOYw5pqP0JfrlhSBma/g1SiR6koTAFILDSxJXKJNfXEi kSiffghHpf1LhZSc/1yQmUj03FBRH22oyA9YDeCiANlmNOQq0GKR0F61yeP6zRVChm7Q Clr6ME34/ajaIWrweLUHwC97Nuvpve6wi4zNXWzGvOcD0mniB2pP+N8LbxOjpkbteg8H ZpaHC2A18OTU5gMA6WurT/AQzIGe4MvHBa1nuQgnhroryc2+C0crPTH9+jFep69cJhjh /DfHdGhdBvN7tyKJhhDA1DtU4I+3FaCV+n9usWi6omollK0wnsydTQKrFJSr71S3uM0P Lueg== 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=9Z0+QTtWV48Eez3EDjsy9pKY9XsTVNn/TGN9ud1nOT8=; b=UTJV/B5xCsQA+WjdrcwzONWHPvGV1Py9siqz7J9oKVfSHJ0t9B8dkerw+Omq2qTZ5/ VLO+S3sOBQ52sCxWcqy5ymkiLFkrf7WKslYIEsqAJdX7N6sk3Id76LfHQrnCMwYQdfrm gRXIAq86HH5SF0RpWe7kPOqYxqX1XCkd7iyATvKJlR4TL2Vi5fl+OQjaBrqm6TIOCxit kKsgKz1+u2DWmDMW4wXjEfDntTYGg9wfaUI1SOemk3ZrQkS14o8+BDd6xkAgDYwyyt2a QVifbD9FMc6a2aW0oHWBjMwbsNGbKTpe0AI5pnZSP5siBSnt9Q0oRmkX+o5v3xr6kHjw zKaA== 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 a81si7603019pfj.300.2018.04.30.13.07.35; Mon, 30 Apr 2018 13:07:49 -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 S1756007AbeD3UH1 (ORCPT + 99 others); Mon, 30 Apr 2018 16:07:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:33790 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932182AbeD3T1X (ORCPT ); Mon, 30 Apr 2018 15:27:23 -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 C4C1E22E01; Mon, 30 Apr 2018 19:27:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C4C1E22E01 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.14 53/91] mtd: cfi: cmdset_0002: Do not allow read/write to suspend erase block. Date: Mon, 30 Apr 2018 12:24:35 -0700 Message-Id: <20180430184006.945240271@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180430184004.216234025@linuxfoundation.org> References: <20180430184004.216234025@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.14-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 @@ -816,9 +816,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 @@ -2267,6 +2268,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, @@ -2356,6 +2358,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,