Received: by 10.192.165.148 with SMTP id m20csp4152907imm; Mon, 30 Apr 2018 12:46:11 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoU2uSJi+iZs/PUFeTf9nJanT0/EnlylqrGITmC0KlDE3hq5Rx6ik4c6R3nig7VY4KcaW91 X-Received: by 10.98.68.156 with SMTP id m28mr7481547pfi.145.1525117571468; Mon, 30 Apr 2018 12:46:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525117571; cv=none; d=google.com; s=arc-20160816; b=vd25RM0yJGy8QP3WO+06RLOTGgSUTeU0l0WoZCU25yct+L9Wvws6rrB/xWxnaKTl64 8ditPjahQDC89h3tzClMvjRaZLi3Jf1xTnmXlOaMoz81iUjfcvRRaPqoEU/3+qezZoS8 /WivYY6zc0z60FTgh7HQjGRk6mfestYXGmtA8NNEW9Q6u2OWyiPn7RDtjHPle6AJc+r8 a5W1Zp56tClQvoSbxl/emWvwrKJpLInfsBSfZSjlu5+5W5kW/A4g00PXkjARWOLmGqcv 2+CSWO/ME50ZJ8O3Rjf5ed9M1U4+UqJ48I0kqVtJe+8ioWrd1PQ6qsPG+b6F/uGRIfOV GZDA== 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=t+5tv2IM+HNuSwYwL8ZMHZOChl66DNn8YJWIFsSf6Nw=; b=l/Us1LTziAJD3AAW9CiYwG00joxYfQkUOlDKVVsyJRhPqNcVK+CeovNkvTowqlT0C0 jM5CvSzPcCYYoER9/bFiPvRqqwq97tqljyG2SJL/Zfx8/frAgHud4o8rmRpM431Aib4E eyyoAMCadi0/9Eytbv3ESDFomSdWgHL17RABHqBbT2QnLKOKGaAdvg0+lFfjvY6JnMFL I0z9qmX9YYG+994tDos2KGBrkxha2TDSffWq/CMCv9M1XMsnb8J+XKgGP7CA+lz9LZCb j1zz1u4zjea9tijV7s1b4kYtOa8QatiikpTqC1f5u3dOwPqD4lUE+ZTOXvfSWKteMGUL wbew== 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 e5-v6si758921pgp.461.2018.04.30.12.45.57; Mon, 30 Apr 2018 12:46:11 -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 S932421AbeD3TpD (ORCPT + 99 others); Mon, 30 Apr 2018 15:45:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:36022 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932267AbeD3T2X (ORCPT ); Mon, 30 Apr 2018 15:28: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 9F1FA22E72; Mon, 30 Apr 2018 19:28:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9F1FA22E72 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.16 057/113] mtd: cfi: cmdset_0002: Do not allow read/write to suspend erase block. Date: Mon, 30 Apr 2018 12:24:28 -0700 Message-Id: <20180430184017.470046971@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180430184015.043892819@linuxfoundation.org> References: <20180430184015.043892819@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.16-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,