Received: by 10.192.165.148 with SMTP id m20csp4184677imm; Mon, 30 Apr 2018 13:24:48 -0700 (PDT) X-Google-Smtp-Source: AB8JxZr/jjnJWp6FxXJVDtplVcz1GFDu2UWblKjgdCMSN4T976+c3GzJ0B3hZiUK+ZJzLQvDposF X-Received: by 10.98.15.200 with SMTP id 69mr4760708pfp.14.1525119888548; Mon, 30 Apr 2018 13:24:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525119888; cv=none; d=google.com; s=arc-20160816; b=KaQyv5XXgXxUayDbrB8xrLtR50/kM1AUsQyC7eCtB8KT8JW82mMCoViOIbAX252tT2 gyf9HoeA2rMxgFPGparm5szAPUlOpmU7Ep2iN4ghU/qo7idhu0Wx1fSPOZbXf6xd1DUv AdTUfp+iGCMm3MIjrEs3RNPMXi23XNCYFWT3/XpCADBpczLuDXYufVlTZQJFog6udDFX 7P09Q+oiGDxVM2HvAnrD8rAmisIl/kdAk9GD06IwpQT3NncY2OwmMnuPJKwBl+HWiJEy fbfziHfF/ZD4ZyEsPjBobJqDEeUHvS0GO0zqycZO5BwRcdDpWV2LIwetZUHxG2dSLfm6 YxZA== 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=0ZmCBg9cddY69m1EhAuW7p0qcVgcyIUwCtNFSwnafy4=; b=MRg+NrZQFchKXV/p/2kdBeZFZzYNMdx+xDHnN1HPj+vZnJLnmuHsPswRamqxwy0YFJ oIHMsyJpSIhzwtdZqH54MFMlZxlugsTKwdAzroRxot8i1qO3//Ept4pzX7hm7jGVPz5y q/3hV2JiPQyu6Uhg9DEMuwX+M2+rulUkptQ/nk8FcpLan5IencG9fm+9Cr9S36mVCbKm nvSpPt7jZt2YXEkKPw5yTEl8Sl5tIGYTg386etxh24NcEt+W/4977vjFVcSMF6fvIwtO r0L+z7iUadoUE6Nt6TYM2p6p17AClWLYOXFzaKYGn/9E3a9765Nt6SMu4h4RcmWD8vgD 6DtA== 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 24si2723022pfp.161.2018.04.30.13.24.34; Mon, 30 Apr 2018 13:24:48 -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 S1755925AbeD3UX5 (ORCPT + 99 others); Mon, 30 Apr 2018 16:23:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:60416 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755701AbeD3T0f (ORCPT ); Mon, 30 Apr 2018 15:26:35 -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 B62D922DCB; Mon, 30 Apr 2018 19:26:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B62D922DCB 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.9 38/61] mtd: cfi: cmdset_0002: Do not allow read/write to suspend erase block. Date: Mon, 30 Apr 2018 12:24:41 -0700 Message-Id: <20180430183954.580338167@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180430183951.312721450@linuxfoundation.org> References: <20180430183951.312721450@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.9-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 @@ -812,9 +812,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 @@ -2263,6 +2264,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, @@ -2352,6 +2354,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,