Received: by 10.192.165.148 with SMTP id m20csp2462209imm; Sun, 22 Apr 2018 07:32:36 -0700 (PDT) X-Google-Smtp-Source: AIpwx49zxglWyKA/QVXq/mVgWdFYo10aFRF8CRRYZi4f7dHMC3OFY03o+F88uctGAgZ3RG1KRwrO X-Received: by 10.167.134.25 with SMTP id p25mr16681574pfn.93.1524407556042; Sun, 22 Apr 2018 07:32:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524407555; cv=none; d=google.com; s=arc-20160816; b=Ys+kYrvVdVzhEYacfZ3b7cJxcbnzJbLseYNqKlmo32kH61NZE9NRfEC4hZy3Ta9/Tj bEwkJ98jI2ZhN6YrilamuNrb0aZo0zdgBv7+ANpBYtiE9xlVgZvodoYjAPVWHHE1rADe EEfSrlWLTIwV0cAmjGBT5XVLfPWoxrVbyoKcvC52xzxncsVBUV4r8h1zhqJZFrCbjCPr d0wRvIZiOtOkGFgiq4kUGGe+gea70kssDJ7WUDdYiyQ4TrxTpzW1i6W/gLnvBObbqhke zHPmppdRrifgzSf2kkE8SHwSJ4zlwb6JTG8YsQOqfu68cIH6i8Q3qV5W5oj7vCdIOoMO XC2w== 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=7wqedEjkYCrrG+V02z37RdSpxjm9JHmnK3VsOTXZ5Qc=; b=ObfgGo3jlA9wrq+Fd7Gc+M3zkjsQ/t2a5ThGcqHebMPnlj2ka1qh0Aute+H/qNocP/ ZmZCjRcJWckoF9tdV9VNVy0BYbRtnPuwiyAAqjM2Bh7xlX65YgHQtsuGXrTUfKClhPjz N8k2HpbilT3Su7YRJBFMp+66khPk6Q0D7rPgEH9muo+xwOGjtMVsMaY3u6GqyYtFWqtg RXxQyYPBLk4ieUmdYSVgBCN5ZZZ2rV0T6C3CPR0hDKLqpKEL7Hh3/S/M7JNPT3rd7AfV HQx0zHXlRbQbJwXkEBRAF/c2ozYP7+UpB7AkQHIbwhRVxemfdEWzehB94i4wB+8/CGL0 1MLw== 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 b124si8115363pgc.121.2018.04.22.07.32.21; Sun, 22 Apr 2018 07:32:35 -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 S1757485AbeDVOUw (ORCPT + 99 others); Sun, 22 Apr 2018 10:20:52 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:60626 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757452AbeDVOUp (ORCPT ); Sun, 22 Apr 2018 10:20:45 -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 C0E08CB7; Sun, 22 Apr 2018 14:20:44 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Richard Weinberger , Boris Brezillon , Artem Bityutskiy Subject: [PATCH 3.18 09/52] ubi: Reject MLC NAND Date: Sun, 22 Apr 2018 15:53:42 +0200 Message-Id: <20180422135315.675774120@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180422135315.254787616@linuxfoundation.org> References: <20180422135315.254787616@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 3.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Richard Weinberger commit b5094b7f135be34630e3ea8a98fa215715d0f29d upstream. While UBI and UBIFS seem to work at first sight with MLC NAND, you will most likely lose all your data upon a power-cut or due to read/write disturb. In order to protect users from bad surprises, refuse to attach to MLC NAND. Cc: stable@vger.kernel.org Signed-off-by: Richard Weinberger Acked-by: Boris Brezillon Acked-by: Artem Bityutskiy Signed-off-by: Greg Kroah-Hartman --- drivers/mtd/ubi/build.c | 11 +++++++++++ 1 file changed, 11 insertions(+) --- a/drivers/mtd/ubi/build.c +++ b/drivers/mtd/ubi/build.c @@ -905,6 +905,17 @@ int ubi_attach_mtd_dev(struct mtd_info * return -EINVAL; } + /* + * Both UBI and UBIFS have been designed for SLC NAND and NOR flashes. + * MLC NAND is different and needs special care, otherwise UBI or UBIFS + * will die soon and you will lose all your data. + */ + if (mtd->type == MTD_MLCNANDFLASH) { + pr_err("ubi: refuse attaching mtd%d - MLC NAND is not supported\n", + mtd->index); + return -EINVAL; + } + if (ubi_num == UBI_DEV_NUM_AUTO) { /* Search for an empty slot in the @ubi_devices array */ for (ubi_num = 0; ubi_num < UBI_MAX_DEVICES; ubi_num++)