From patchwork Fri Mar 25 12:00:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= X-Patchwork-Id: 554033 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1248:0:0:0:0 with SMTP id z8csp5360423mag; Fri, 25 Mar 2022 05:01:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzgiuD74ZRnBXtIKw6eQTi3C2F+m5ZQxX5az14855r3+w3m4VF5ACo+2xPH9jmDEsR/A6jY X-Received: by 2002:a17:90a:7f84:b0:1bc:aba8:f281 with SMTP id m4-20020a17090a7f8400b001bcaba8f281mr12279084pjl.101.1648209706880; Fri, 25 Mar 2022 05:01:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648209706; cv=none; d=google.com; s=arc-20160816; b=cG3mNRSuFVEd912mKuNmqmtUZTCp0rNqv3htu4sps8WmTUJhQiHnS8ez1f+dP4lvIq S/WypQEvGPoaBreJqzc0bjghnhvVtCKbh5UR6ufohrd73X5IDuJyvIGabzDqQvCz2Co9 7BUXs0f0paXSFCLs372qFYu+WPrrcdg6B2n8n5xRRh/cHQY7eMiBQPPYUseKaAR+nUgY 8oD0vw0B9mPmJPvyfsoG8M5FoB3oxo0+x0+XmGMc5jp8BkyqmlvLaiBaeU/HHFc7Cv6A MBPC/oUEvSW7EA7HOBLaU4z3WUEKaN9ii134yHIQojrmIXH7F6jEzBJUl/iVXTJLYFjE rtDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :mime-version:message-id:date:subject:cc:to:from:dkim-signature :dkim-signature; bh=SDIX3idQXXZZz0tzGMOyM2sZS/+KTkNWypjb+UsY3Jw=; b=B+OanvH3nNKCOqvgKoQJ8Rr/tUROH7xcPueU8wTaR2XW3k0C2oqOF8kDdRVcllmfly 4kUU9EjFfiZLIkKKFyA80iCrWBwJS5f1JyMIHpNpwqJjd3HslCgMO0fE5mqk63Fg0zuz AZ2WFDTAdoSbE1CT25htT0FeCSy1AInpsrNPJbjKULal90Ml/FK33lKXCqmirLr2RDXz TR/EWkG6kg0k1TbGHdSmztrnkZFTBvEwcOPAlZI+C5keWrlUNh2Pgn5VxqiayDZ9djLu 71TSl4l6/MBCd0jP60T9iYVZJrYljvAOYmolFZuGMzOZqmBvv52th8OD0k9MHE7bnT2e 342g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20210309 header.b=IpxTieLm; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b="FjZI3/Oo"; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom="linux-mtd-bounces+patch=linaro.org@lists.infradead.org"; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id lx3-20020a17090b4b0300b001bd14e03066si3012073pjb.62.2022.03.25.05.01.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Mar 2022 05:01:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20210309 header.b=IpxTieLm; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b="FjZI3/Oo"; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom="linux-mtd-bounces+patch=linaro.org@lists.infradead.org"; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=SDIX3idQXXZZz0tzGMOyM2sZS/+KTkNWypjb+UsY3Jw=; b=IpxTieLmtyKOQd 3zLnVDcy5wN0ukwWd4dYwNQWcB0IJj5pDLsypHMHk+pSymlh1vibuTL3I3ZyveN4MoEYw9OIlmhuC MbelPfMt4tUKN3gFNAgbPP1MHLPQ1m+6xGzalW6e8fnOpF0g92hm6VU0jXoxSvZKNKkq9Zbxx7omS rSPq0u7rLmhMB5Vx96Nj3FwcXB7d9Jbuy3OOOfI4PLeWbSRYEkjraF7R0VSvAY5QkAjj0Bq0bjGhK 8V1kKTvlp9fN05BBE8tGSngzxHgpvHc9DKbYzKTB7yqtjb8YQiEvtgyF+0K+S6tDCayzLgLgM5BzE u3MRkBaIlRSPikEGktYw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nXicX-001xX2-SE; Fri, 25 Mar 2022 12:00:45 +0000 Received: from mail-lf1-x12f.google.com ([2a00:1450:4864:20::12f]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nXicT-001xUx-Oa for linux-mtd@lists.infradead.org; Fri, 25 Mar 2022 12:00:43 +0000 Received: by mail-lf1-x12f.google.com with SMTP id p10so7119952lfa.12 for ; Fri, 25 Mar 2022 05:00:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=WrDsrRGiIY0uVMcbpwBnoLj/TxiPgA8IFWvZnnYMgWo=; b=FjZI3/OoXoRLPNajJuALSfBjhMAzZjJ3gWxAT1bv6fNIzKAVyRQo0ZZ+G1vN70nmyn pIQmgbMYVT0sZev812SlZUePbIzKuhYnzxtYwKDk39KQMTWHXT+l8umXnp2eyyjnSn65 9hggXcBdhX1QeaRuBDAlVC5dKeytoiOelA0Uz+aCs7PfNPva9Jn80BGfjMCryaeSG/YL q56AwS0ndf8KzEYDhfSk9ZSPLYDBY2YhOW4DsUyBSh+rC1pLzFzF/XGqt8MA04mgR4Ak 6LneggpLO7jxd/pQm2UXQ66xJxHNUDvKZaX/3FYZS5cEo4iRjKL2IsbvWbnoDYMYhNoW e3gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=WrDsrRGiIY0uVMcbpwBnoLj/TxiPgA8IFWvZnnYMgWo=; b=Vg69Tx91ve1BfXVuwVHorB6O/Vp0lhASnztYnOaoDZuLA7OFEnOJ6zxSZVviJ6+y2v XUMOFscJeIt4cbBLSNPvkhQiCzVTOvVpWIC4q5kGcr6hf+1U4en65W2c50H0PYAjxhQs G0OUHSrTxnbyNTvIGS337LvBVZJwIsTI152TPYqdBShsZJlj8dGOIDwqt1lZkUr/34dk jushcPcrA/QaD9VV1ZLyGiy1ryw2U/hdadRtpVugFt188FLnZosUvaIkd296bCldIDCo 9ii2Z34u/PbYD3L+WOLFOkVjvu+6+i9BgNE9lnYgp+KhBXP6rSvEMVRZDOq4Z+xtWw3U vZVQ== X-Gm-Message-State: AOAM531DcsEAtzunh1HcnQmdd0feooVVJoNLVeoYGFfq3uT6JlKbmxVm JFHnGcK4w9p+gNlRGRRXcsfGOIx6AZA= X-Received: by 2002:a05:6512:3d9f:b0:44a:4960:5b79 with SMTP id k31-20020a0565123d9f00b0044a49605b79mr7561467lfv.413.1648209636238; Fri, 25 Mar 2022 05:00:36 -0700 (PDT) Received: from localhost.lan (ip-194-187-74-233.konfederacka.maverick.com.pl. [194.187.74.233]) by smtp.gmail.com with ESMTPSA id u2-20020a197902000000b00448a4a7cfc3sm681115lfc.136.2022.03.25.05.00.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Mar 2022 05:00:35 -0700 (PDT) From: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= To: Miquel Raynal , Richard Weinberger Cc: linux-mtd@lists.infradead.org, =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= Subject: [PATCH mtd-utils] nandwrite: warn about writing 0xff blocks Date: Fri, 25 Mar 2022 13:00:25 +0100 Message-Id: <20220325120025.17931-1-zajec5@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220325_050041_825262_430B2804 X-CRM114-Status: GOOD ( 13.58 ) X-Spam-Score: 0.1 (/) X-Spam-Report: =?utf-8?q?Spam_detection_software=2C_running_on_the_system_?= =?utf-8?q?=22bombadil=2Einfradead=2Eorg=22=2C?= =?utf-8?q?_has_NOT_identified_this_incoming_email_as_spam=2E__The_original?= =?utf-8?q?_message_has_been_attached_to_this_so_you_can_view_it_or_label?= =?utf-8?q?_similar_future_email=2E__If_you_have_any_questions=2C_see?= =?utf-8?q?_the_administrator_of_that_system_for_details=2E?= =?utf-8?q?_?= =?utf-8?q?_Content_preview=3A__From=3A_Rafa=C3=85=C2=82_Mi=C3=85=C2=82ecki_S?= =?utf-8?q?uch_blocks_may_be_incorrectly_treated?= =?utf-8?q?_as_empty_=28even_though_they_may_have_non-erase_OOB=29=2E_Warn_ab?= =?utf-8?q?out_it_so_people?= =?utf-8?q?_may_start_suing_--skip-all-ffs_=2E_Signed-off-by=3A_Rafa=C3=85?= =?utf-8?q?=C2=82_Mi=C3=85=C2=82ecki_---_nand-utils/nandwrite=2Ec?= =?utf-8?q?_=7C_13_++++++++++++-_1_file_changed=2C_12_insertions=28+=29=2C_1_?= =?utf-8?q?deletion=28-=29_?= =?utf-8?q?_?= =?utf-8?q?_Content_analysis_details=3A___=280=2E1_points=2C_5=2E0_required?= =?utf-8?q?=29?= =?utf-8?q?_?= =?utf-8?q?_pts_rule_name______________description?= =?utf-8?q?_----_----------------------_-------------------------------------?= =?utf-8?q?-------------?= =?utf-8?q?_-0=2E0_RCVD=5FIN=5FDNSWL=5FNONE_____RBL=3A_Sender_listed_at_https?= =?utf-8?q?=3A//www=2Ednswl=2Eorg/=2C?= =?utf-8?q?_no_trust?= =?utf-8?b?IFsyYTAwOjE0NTA6NDg2NDoyMDowOjA6MDoxMmYgbGlzdGVkIGluXQ==?= =?utf-8?b?IFtsaXN0LmRuc3dsLm9yZ10=?= =?utf-8?q?_-0=2E0_SPF=5FPASS_______________SPF=3A_sender_matches_SPF_record?= =?utf-8?q?_0=2E0_SPF=5FHELO=5FNONE__________SPF=3A_HELO_does_not_publish_an_?= =?utf-8?q?SPF_Record?= =?utf-8?q?_0=2E0_FREEMAIL=5FFROM__________Sender_email_is_commonly_abused_en?= =?utf-8?q?duser_mail?= =?utf-8?q?_provider?= =?utf-8?q?_=5Bzajec5=5Bat=5Dgmail=2Ecom=5D?= =?utf-8?q?_0=2E2_FREEMAIL=5FENVFROM=5FEND=5FDIGIT_Envelope-from_freemail_use?= =?utf-8?q?rname_ends?= =?utf-8?q?_in_digit?= =?utf-8?q?_=5Bzajec5=5Bat=5Dgmail=2Ecom=5D?= =?utf-8?q?_-0=2E1_DKIM=5FVALID=5FAU__________Message_has_a_valid_DKIM_or_DK_?= =?utf-8?q?signature_from?= =?utf-8?q?_author=27s_domain?= =?utf-8?q?_-0=2E1_DKIM=5FVALID_____________Message_has_at_least_one_valid_DK?= =?utf-8?q?IM_or_DK_signature?= =?utf-8?q?_0=2E1_DKIM=5FSIGNED____________Message_has_a_DKIM_or_DK_signature?= =?utf-8?q?=2C_not_necessarily?= =?utf-8?q?_valid?= =?utf-8?q?_-0=2E1_DKIM=5FVALID=5FEF__________Message_has_a_valid_DKIM_or_DK_?= =?utf-8?q?signature_from?= =?utf-8?q?_envelope-from_domain?= X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-mtd" Errors-To: linux-mtd-bounces+patch=linaro.org@lists.infradead.org From: Rafał Miłecki Such blocks may be incorrectly treated as empty (even though they may have non-erase OOB). Warn about it so people may start suing --skip-all-ffs . Signed-off-by: Rafał Miłecki --- nand-utils/nandwrite.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/nand-utils/nandwrite.c b/nand-utils/nandwrite.c index e8a210c..cd53a17 100644 --- a/nand-utils/nandwrite.c +++ b/nand-utils/nandwrite.c @@ -280,6 +280,7 @@ int main(int argc, char * const argv[]) libmtd_t mtd_desc; int ebsize_aligned; uint8_t write_mode; + size_t all_ffs_cnt = 0; process_options(argc, argv); @@ -417,6 +418,8 @@ int main(int argc, char * const argv[]) */ while ((imglen > 0 || writebuf < filebuf + filebuf_len) && mtdoffset < mtd.size) { + bool allffs; + /* * New eraseblock, check for bad block(s) * Stay in the loop to be sure that, if mtdoffset changes because @@ -555,7 +558,8 @@ int main(int argc, char * const argv[]) } ret = 0; - if (!skipallffs || !buffer_check_pattern(writebuf, mtd.min_io_size, 0xff)) { + allffs = buffer_check_pattern(writebuf, mtd.min_io_size, 0xff); + if (!allffs || !skipallffs) { /* Write out data */ ret = mtd_write(mtd_desc, &mtd, fd, mtdoffset / mtd.eb_size, mtdoffset % mtd.eb_size, @@ -564,6 +568,8 @@ int main(int argc, char * const argv[]) writeoob ? oobbuf : NULL, writeoob ? mtd.oob_size : 0, write_mode); + if (!ret && allffs) + all_ffs_cnt++; } if (ret) { @@ -615,6 +621,11 @@ closeall: || (writebuf < filebuf + filebuf_len)) sys_errmsg_die("Data was only partially written due to error"); + if (all_ffs_cnt) { + fprintf(stderr, "Written %zu blocks containing only 0xff bytes\n", all_ffs_cnt); + fprintf(stderr, "Those block may be incorrectly treated as empty!\n"); + } + /* Return happy */ return EXIT_SUCCESS; }