Received: by 10.192.165.148 with SMTP id m20csp2427028imm; Sun, 22 Apr 2018 06:57:16 -0700 (PDT) X-Google-Smtp-Source: AIpwx49C0ag45Z01cvCMyXGWbhaX/kSX9BtYm2sb1Aot/sYGLjndLjtn8FT9GSKoz3PONpM9noX4 X-Received: by 2002:a17:902:2f43:: with SMTP id s61-v6mr13699853plb.99.1524405436683; Sun, 22 Apr 2018 06:57:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524405436; cv=none; d=google.com; s=arc-20160816; b=bv4GITCrb63rqDc8XKy533Y+w4pEAnZAImsjh5D7uSCqa1nJbrYzuosfuRGX1O1FB0 +B94oeT78JEOR50vSB/blglBIbifVHWAKtYQ2lx7+V7UwDpr/Uh+Fdul1GSKxc1pvKPI 8obdNhIHZxawwEnVEtQnQ0OIkwnbsPGpNLkDZW24fRZkDVtle/O25aqENRgStjD07YAJ GmF/AyJszJVzXq2FwoxORE7j0OJdX6yaZwjp1jf0bMBbl8VHPvLkcvO+T5LX8TOgswW0 q8BGirfp96DiF3PeZ8EL70bs8LPhrCIMlO3TApTloGWRNzQBdhG06kLWDrkQ1K17JJYS fwOA== 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=IwlJvrm5pYm5LcyxLpgT2EoSy8uGxUNqdmyToIbcXTg=; b=NHO0IQpiyJBRM1I6uUojlA/Tblqe4tVqfPVkanNnhqxJVMUadbHG/YQbYQk4ZzEolH k1btTOCR+7bTQsbJfWrezGxE5bbRhjaBfUf/G8YRFgI4cxOcdyUBQWEfTmmOmavfRjI2 iGV0R9RILwVnAdOtQYbtyPQk/aumx483VaXXNdZI/BFxm880txl1tTLI7V/oLFzOVCqx O4hqtfcBjrZDsjysaT+KB/5n/tA2T2tylxlq1FdHis583DliDRQ995cVxv1VMcDV85VP wgrF2hVis4PQvEYcfMWzOE/93YwMYPjgqvoktCzo3Xru/ILXttYTG72NeiLFWvAM/yeU 8FyA== 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 g14si8269927pgn.227.2018.04.22.06.57.02; Sun, 22 Apr 2018 06:57: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 S1753528AbeDVNz3 (ORCPT + 99 others); Sun, 22 Apr 2018 09:55:29 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:44602 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753508AbeDVNzY (ORCPT ); Sun, 22 Apr 2018 09:55:24 -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 63B6387A; Sun, 22 Apr 2018 13:55:23 +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 4.16 007/196] ubi: Reject MLC NAND Date: Sun, 22 Apr 2018 15:50:27 +0200 Message-Id: <20180422135104.594604614@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180422135104.278511750@linuxfoundation.org> References: <20180422135104.278511750@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: 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 @@ -854,6 +854,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++)