Received: by 10.192.165.148 with SMTP id m20csp2489689imm; Sun, 22 Apr 2018 08:05:57 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/dq9kGeFmoZAcDpkLcK8iMtiBaWMg80oFGbiBTWEfVvu3h7jXYAhUh6ltEkJL5L10ALyqD X-Received: by 10.167.133.66 with SMTP id y2mr16979613pfn.210.1524409556936; Sun, 22 Apr 2018 08:05:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524409556; cv=none; d=google.com; s=arc-20160816; b=augCkDskpUDhFNLOPralDkaRkPs+7avaJ5ffuI2KVrhsYIl07dLsDz1AL+A52rjChZ QjzxfMMQfdsN5rlpPVUMqA+CJwcIm/yKsru3Hf2Ldig4PN/E/lIhVI8FfTHeYW2YuKoq wJIVRSnHOYvKXZHJeutjsAsvoiW7zu6D+41FNwws8PC3T+8WCBT6Z3zkpPtUJhUajUd7 0soOe3dUfCCaquGXKQ5NNZW7BiTmwXGC/vzhSApsSHPF+cjVYJVEdjY/c0aFHHum3b14 u8VTnVjjog0ANbaDnxlTxtIDJYJdWnEzdAkghKnjl7k6ASymBQgrlmbiBWgaj4n7QsJ2 sRJw== 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=/jEM1d7GenbDLGq1RVkmmam6kp+9UmxPQM9t6uQMQso=; b=Cc+xcp/h3+A/yyU/nN6Pfv8WGC2sG/5lBm8miui/4cRCEv3h8n7Xp0iZP8O86+eZMB WbVEAVxQoirnbE7nnCMIM2ylJ8iHas/GxTnEE9oUEPO05bi04ZUoojIyu9TzGtd8rP1u 7ve8rWYK5tQqf7HWDE/y/GhUXGY81dkTjDVMxmXNJTJbmUxj48/gDavP4u8XgdGPTjiP Xffjx/R8xhStJSTfpDGyMRDpjBBvJIx8Kalv/e1eB2wesv18UTYs8C3b7ppe51zgM+kT IywS3wtTlkTw+j4bZ8DjcYAsKUGjGZ+1KA/9gBCwktdiZhZQdatGOZ0EoR0OnuTEnPy+ DGOg== 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 v72si9516985pfa.59.2018.04.22.08.05.42; Sun, 22 Apr 2018 08:05:56 -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 S1756598AbeDVOL4 (ORCPT + 99 others); Sun, 22 Apr 2018 10:11:56 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:54606 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756539AbeDVOLs (ORCPT ); Sun, 22 Apr 2018 10:11:48 -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 C5A83CB7; Sun, 22 Apr 2018 14:11:47 +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.9 05/95] ubi: Reject MLC NAND Date: Sun, 22 Apr 2018 15:52:34 +0200 Message-Id: <20180422135210.654568274@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180422135210.432103639@linuxfoundation.org> References: <20180422135210.432103639@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: 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 @@ -894,6 +894,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++)