Received: by 10.192.165.148 with SMTP id m20csp2474574imm; Sun, 22 Apr 2018 07:48:32 -0700 (PDT) X-Google-Smtp-Source: AIpwx48oFzg97EVqKss03fYdSBtujwQbPeJnXuq7muI/Yf74uNa3oMH9wcnR1Oa+1Z3JWnh8ples X-Received: by 2002:a17:902:bd41:: with SMTP id b1-v6mr17200025plx.302.1524408512548; Sun, 22 Apr 2018 07:48:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524408512; cv=none; d=google.com; s=arc-20160816; b=BtEmkchnUlPy/ZaY68zQtrfCy1HPf+hrKJXJ0VwQAUqSb5E7j1ITKSMe9QEBfcCag/ iyXn5cW1BbisYWxQi2SMEiltszVV6gwYuDI8uqQWcv1TOz+36qmyfk8EthDnpjj9otKL DDXpyQrcejj0AgpGAOoWgG0BrkQmcmx5NlKV2hAieJ2XBRIPqOr8Ps0yKfPYHCY4RNGI Sntnw0KgBM6XaN3wFP9ZxLZVcZGu/Q9N/fW5Gqr99Owp1lLoIS6BMG+cx8NaByG1gDUI cElBgragFg0Z7lo++ju3qBDJZG/bfRocmrkjJ7Av9o8ULjjKTLgh4/3Pj2gOnYueQHpl 4zAA== 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=Fseu/ebQ7Tok2feFjRNapdWABtR8lyhTIclm5UTyllo=; b=AiyX94gboEMypvXT+qpTnAzzKV7H1ZpyKRix6OqABtCGyFn9QAOM/EyodXkLbM/Loa 9iVtZSzpeNpTWxlDy/wjdzip4npZ6nHnPs85bQdCYaVzg1YXhuFMhgeKkgibxaoxJzHe +SE3BUeaD1snXxzeXOTkwPXPYdLZRa5IjEtwSfqBvRkV5bBk1M3SpxgMhWhsrEfkdsnn LQVOac3A/ALT7jp2ywUse+qUyFRqvgwlnM7qpk5g4P0SBdYfoy1sYWJa87JJNBAuSbys /qf2pp10jVEBjqprybjkHwfoM1vVe6O+/K8Nz7c+pdEyUj6aafFoMrOnyzpCtrm7xT1H varg== 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 y9si8463163pgp.525.2018.04.22.07.48.18; Sun, 22 Apr 2018 07:48:32 -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 S932254AbeDVOQV (ORCPT + 99 others); Sun, 22 Apr 2018 10:16:21 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:57324 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932105AbeDVOQO (ORCPT ); Sun, 22 Apr 2018 10:16:14 -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 AB2C4C79; Sun, 22 Apr 2018 14:16:13 +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.4 25/97] ubi: Reject MLC NAND Date: Sun, 22 Apr 2018 15:53:03 +0200 Message-Id: <20180422135306.451761209@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180422135304.577223025@linuxfoundation.org> References: <20180422135304.577223025@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.4-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 @@ -889,6 +889,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++)