Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp3699452rdb; Wed, 27 Dec 2023 17:36:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IECFYihKq7SA2bXyjmVgdM6XtPIHESo+1cF+U17b4NZZj7vU29VD+HdyqpA93Pr3EL60IWd X-Received: by 2002:a05:6808:2204:b0:3b9:ce35:dc35 with SMTP id bd4-20020a056808220400b003b9ce35dc35mr12019977oib.29.1703727387372; Wed, 27 Dec 2023 17:36:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703727387; cv=none; d=google.com; s=arc-20160816; b=BZVL4RMXzNmJxHIviL9XUYNAMRE6arNKQqR1KHJwXR51JaAImomlrH2V/eNanB7f3x 4QLdeb4F/kWUMNo2A+FnQJj1BJKKbuOzoW5lqp3akAUoNhbUbCE5wJ/a2/5Q9NEpt71J WxxvgBV5VhbRim/mue0CyZCKFcS4Z8zgN3h/mKpzfkBAv28UAXfNFEFhEgj+BF/Dyimi VytTu4ozq62YdrR2lZUWvb5jerUBCukvr8chIrRTh3lSSujI8ZlbxvNKSwtEM8E1yoD1 8VdNwODcQfoY8Qu7K8ZHtQpqXoJ/COcHUOrcqfiko10JSzpcw4mqnYD/nGlyG19b96/7 RBxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=C5PDIm0UJdOB0z/OZQ1Yyc0zRsaIubJKG/LZC5/IYmU=; fh=3kaVOPShTC55oj708yh1yJALapWuogKx6Yvc3sQq9zY=; b=V11/IVuegh5oOLRNa+BfxqDqatA5LbE5bhaQgghJdXEefv6UQuP8TjNSjigZSo2uuN 2UMm9D6QHAvHrhk+c8BW+sPp/SJXPjK5CNfvurEo573sTckc7B6nSmSI1SXdoV3Er3Up R41NXcyoHrOXFHdpTyfrWrLTQ9ObD26lPo5Uh3pkLfIouCXrM4a+7xwv7c2k13Oljlrq xrBos+s5D3R0AWkMnCXivnbfDDUged7KRdoHm3UU0ekwFuL46mAELT7Y7wIc9sLoq+z0 dpWNqhmglcZAfMXoscRrKFWNWs4iTm2ogLxM3c4BMv9alt/UpmtVphF03ps8clFXJFpI RUEQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-12347-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-12347-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id b12-20020a0ccd0c000000b0067ec2d04818si15451340qvm.131.2023.12.27.17.36.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Dec 2023 17:36:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-12347-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-12347-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-12347-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 1108F1C20BC2 for ; Thu, 28 Dec 2023 01:36:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8D88423B7; Thu, 28 Dec 2023 01:35:25 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4AB571FAA for ; Thu, 28 Dec 2023 01:35:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.88.214]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4T0rZT4Fp9z1FGKj; Thu, 28 Dec 2023 09:31:29 +0800 (CST) Received: from kwepemm000013.china.huawei.com (unknown [7.193.23.81]) by mail.maildlp.com (Postfix) with ESMTPS id 7F2A81A0194; Thu, 28 Dec 2023 09:35:06 +0800 (CST) Received: from huawei.com (10.175.127.227) by kwepemm000013.china.huawei.com (7.193.23.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Thu, 28 Dec 2023 09:33:39 +0800 From: Zhihao Cheng To: , , , , CC: , Subject: [PATCH mtd-utils 11/11] tests: ubifs_repair: Add README Date: Thu, 28 Dec 2023 09:36:39 +0800 Message-ID: <20231228013639.2827205-12-chengzhihao1@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20231228013639.2827205-1-chengzhihao1@huawei.com> References: <20231228013639.2827205-1-chengzhihao1@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemm000013.china.huawei.com (7.193.23.81) Add document for ubifs_repair testcases, explain all testcases and how to run them. Signed-off-by: Zhihao Cheng --- tests/ubifs_repair-tests/README.txt | 233 ++++++++++++++++++++++++++++++++++++ 1 file changed, 233 insertions(+) create mode 100644 tests/ubifs_repair-tests/README.txt diff --git a/tests/ubifs_repair-tests/README.txt b/tests/ubifs_repair-tests/README.txt new file mode 100644 index 0000000..cb1ce98 --- /dev/null +++ b/tests/ubifs_repair-tests/README.txt @@ -0,0 +1,233 @@ + + ubifs_repair tests + ================== + + There are seven testcases for ubifs_repair on encryption/non-encryption + situations: + 1) authentication_refuse: Currently authenticated UBIFS image is not + supported for repairing, check whether ubifs_repair can refuse + authenticated UBIFS image. + 2) random_corrupted_repair: Inject random corruption on UBIFS image + by writting random data on kinds of mtd devices (eg. nand, nor), + check the consistency of UBIFS after repairing. + This testcase simulate random bad UBIFS image caused by hardware + exceptions(eg. ecc uncorrectable, unwritten), and makes sure that + ubifs_repair could make UBIFS be consistent after repairing UBIFS + image. + 3) cycle_corrupted_repair_fault_inject: Inject memory/io fault while + repairing corrupted UBIFS images. + This testcase mainly checks whether ubifs_repair has problems (eg. + memleak, UAF, null-ptr-def, etc.) in random error paths. Besides, + it provides a similar way to simulate powercut during repairing, + and checks whether ubifs_repair can fix an UBIFS image after many + repairing rounds interrupted by kinds of errors. + 4) cycle_powercut_mount_repair: Inject powercut while doing fsstress + on mounted UBIFS, check the consistency of UBIFS after repairing. + This testscase mainly makes sure that ubifs_repair can make UBIFS + image be consistent in common stress cases and powercut cases. + 5) powercut_repair_mount: Inject powercut while doing fsstress on + mounted UBIFS for kinds of flashes (eg. nand, nor). + This testcase mainly makes sure that ubifs_repair can make UBIFS + image be consistent on different flashes (eg. nand, nor). Because + the min_io_size of nor flash is 1, the UBIFS image on nor flash + will be different from nand flash after doing powercut, so we need + make sure ubifs_repair can handle these two types of flash. + 6) cycle_mount_repair_check: Do fsstress and repair ubifs image, make + sure all files(and their data) are not lost after repairing. + This testcase mainly checks whether ubifs_repair could corrupt + filesystem content in common case. + 7) repair_bad_image: For kinds of inconsistent UBIFS images(which + can simulate corruptions caused by some potentional UBIFS bug), check + repairing result. + This testcase mainly checks whether the behavior is in expected after + repairing specific inconsistent UBIFS image. There is no debugfs tools + (for example: debugfs[ext4], xfs_db) for UBIFS, so no way to inject + precise corruption into UBIFS image, we have to prepare inconsistent + UBIFS images in advance like e2fsprogs[1] does. (Goto [2] to see how to + generate inconsistent UBIFS images). Here's a descriptons of the various + test images: + + ========================================================================= + image | Description | expectancy + ------------------------------------------------------------------------- + good | good image contains | repair success, fs content is + | kinds of files. | not changed. + ------------------------------------------------------------------------- + sb_fanout | invalid fanout in | repair failed. + | superblock. | + ------------------------------------------------------------------------- + sb_fmt_version | invalid fmt_version | repair failed. + | in superblock. | + ------------------------------------------------------------------------- + sb_leb_size | invalid leb_size in | repair failed. + | superblock. | + ------------------------------------------------------------------------- + sb_log_lebs | invalid log lebs in | repair failed. + | superblock. | + ------------------------------------------------------------------------- + sb_min_io_size | invalid min_io_size | repair failed. + | in superblock. | + ------------------------------------------------------------------------- + master_highest_inum | invalid highest_inum| repair success, fs content is + | in master nodes. | not changed. + ------------------------------------------------------------------------- + master_lpt | bad lpt pos in | repair success, fs content is + | master nodes. | not changed. + ------------------------------------------------------------------------- + master_tnc | bad tnc pos in | repair success, fs content is + | master nodes. | not changed. + ------------------------------------------------------------------------- + master_total_dead | bad total_dead in | repair success, fs content is + | master nodes. | not changed. + ------------------------------------------------------------------------- + master_total_dirty | bad total_dirty in | repair success, fs content is + | master nodes. | not changed. + ------------------------------------------------------------------------- + master_total_free | bad total_free in | repair success, fs content is + | master nodes. | not changed. + ------------------------------------------------------------------------- + log | corrupted log area. | repair success, fs content is + | | not changed. + ------------------------------------------------------------------------- + lpt_dirty | bad dirty in pnode. | repair success, fs content is + | | not changed. + ------------------------------------------------------------------------- + lpt_flags | bad flags in pnode | repair success, fs content is + | (eg. index). | not changed. + ------------------------------------------------------------------------- + lpt_free | bad free in pnode. | repair success, fs content is + | | not changed. + ------------------------------------------------------------------------- + lpt_pos | bad pos in nnode. | repair success, fs content is + | | not changed. + ------------------------------------------------------------------------- + tnc_lv0_key | bad key in lv0 | repair success, fs content is + | znode. | not changed. + ------------------------------------------------------------------------- + tnc_lv0_len | bad len in lv0 | repair success, fs content is + | znode. | not changed. + ------------------------------------------------------------------------- + tnc_lv0_pos | bad pos in lv0 | repair success, fs content is + | znode. | not changed. + ------------------------------------------------------------------------- + tnc_noleaf_key | bad key in non-leaf | repair success, fs content is + | znode. | not changed. + ------------------------------------------------------------------------- + tnc_noleaf_len | bad len in non-leaf | repair success, fs content is + | znode. | not changed. + ------------------------------------------------------------------------- + tnc_noleaf_pos | bad pos in non-leaf | repair success, fs content is + | znode. | not changed. + ------------------------------------------------------------------------- + inode_data | bad data node. | repair success, file content + | | is changed, other files are + | | not changed. + ------------------------------------------------------------------------- + inode_mode | bad inode mode for | repair success, soft link + | solf link file. | file is dropped, other files + | | are not changed. + ------------------------------------------------------------------------- + inode_nlink | wrong nlink for | repair success, nlink is + | file. | corrected, fs content is not + | | changed. + ------------------------------------------------------------------------- + inode_size | wrong inode size | repair success, inode size is + | for file. | corrected, fs content is not + | | changed. + ------------------------------------------------------------------------- + inode_xcnt | wrong inode | repair success, xattr_cnt is + | xattr_cnt for file. | corrected, fs content is not + | | changed. + ------------------------------------------------------------------------- + soft_link_data_len | bad inode data_len | repair success, soft link + | for solt link file. | file is dropped, other files + | | are not changed. + ------------------------------------------------------------------------- + dentry_key | bad dentry key for | repair success, dentry is + | file. | removed, other files are + | | not changed. + ------------------------------------------------------------------------- + dentry_nlen | inconsistent nlen | repair success, dentry is + | and name in dentry | removed, other files are + | for file. | not changed. + ------------------------------------------------------------------------- + dentry_type | inconsistent type | repair success, dentry is + | between dentry and | removed, other files are + | inode for file. | not changed. + ------------------------------------------------------------------------- + xinode_flags | lost UBIFS_XATTR_FL | repair success, xattr is + | in xattr inode | removed, other files are + | flags for file. | not changed. + ------------------------------------------------------------------------- + xinode_key | bad xattr inode key | repair success, xattr is + | for file. | removed, other files are + | | not changed. + ------------------------------------------------------------------------- + xinode_mode | bad xattr inode | repair success, xattr is + | mode for file. | removed, other files are + | | not changed. + ------------------------------------------------------------------------- + xentry_key | bad xattr entry key | repair success, xattr is + | for file. | removed, other files are + | | not changed. + ------------------------------------------------------------------------- + xentry_nlen | inconsistent nlen | repair success, xattr is + | and name in xattr | removed, other files are + | entry for file. | not changed. + ------------------------------------------------------------------------- + xentry_type | inconsistent type | repair success, xattr is + | between xattr entry | removed, other files are + | and xattr inode for | not changed. + | file. | + ------------------------------------------------------------------------- + dir_lost | bad dentry for dir. | repair success, dir and files + | | under dir are removed, other + | | files are not changed. + ------------------------------------------------------------------------- + root_dir | bad '/'. | repair success, create new + | | root dir('/'). + ========================================================================= + + Dependence + ---------- + kernel configs: + CONFIG_MTD_NAND_NANDSIM=m + CONFIG_MTD_MTDRAM=m + CONFIG_MTD_UBI=m + CONFIG_MTD_UBI_FASTMAP=y + CONFIG_UBIFS_FS=m + CONFIG_UBIFS_FS_XATTR=y + CONFIG_UBIFS_FS_AUTHENTICATION=y + CONFIG_FS_ENCRYPTION=y + CONFIG_FAILSLAB=y + CONFIG_FAIL_PAGE_ALLOC=y + + CONFIG_DEBUG_KMEMLEAK=y // optional + + tools: + fsstress [3][4] + keyctl [5] + fscryptctl [6] + setfattr/getfattr [7] + + Running + ------- + + Please build and install mtd-utils first. + Run single case: + cd $INSTALL_DIR/libexec/mtd-utils + ./powercut_repair_mount.sh + ./random_corrupted_repair.sh + ./cycle_mount_repair_check.sh + Run all cases: sh $INSTALL_DIR/libexec/mtd-utils/ubifs_repair_run_all.sh + + References + ---------- + + [1] https://git.kernel.org/pub/scm/fs/ext2/e2fsprogs.git/tree/tests/README + [2] https://bugzilla.kernel.org/show_bug.cgi?id=218327 + [3] https://git.kernel.org/pub/scm/fs/xfs/xfstests-dev.git/tree/ltp/fsstress.c + [4] https://github.com/linux-test-project/ltp/blob/master/testcases/kernel/fs/fsstress/fsstress.c + [5] https://github.com/torvalds/linux/blob/master/security/keys/keyctl.c + [6] https://github.com/google/fscryptctl + [7] https://github.com/philips/attr/tree/master -- 2.13.6