lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 16 Oct 2023 15:37:43 +0800
From:   Chao Yu <chao@...nel.org>
To:     Zhiguo Niu <zhiguo.niu@...soc.com>, jaegeuk@...nel.org
Cc:     linux-f2fs-devel@...ts.sourceforge.net,
        linux-kernel@...r.kernel.org, niuzhiguo84@...il.com
Subject: Re: [PATCH] f2fs: fix error path of __f2fs_build_free_nids

On 2023/10/13 18:58, Zhiguo Niu wrote:
> SBI_NEED_FSCK should be set for fsck has a chance to
> repair in case of scan_nat_page fail in run time.
> 
> Signed-off-by: Zhiguo Niu <zhiguo.niu@...soc.com>

Hi Zhiguo,

Can you please check below update?

 From 9a3459d2d62a12f8708d72aa7808a1def9f9d92f Mon Sep 17 00:00:00 2001
From: Zhiguo Niu <zhiguo.niu@...soc.com>
Date: Fri, 13 Oct 2023 18:58:23 +0800
Subject: [PATCH] f2fs: fix error path of __f2fs_build_free_nids

If NAT is corrupted, let scan_nat_page() return EFSCORRUPTED, so that,
caller can set SBI_NEED_FSCK flag into checkpoint for later repair by
fsck.

Also, this patch introduces a new fscorrupted error flag, and in above
scenario, it will persist the error flag into superblock synchronously
to avoid it has no luck to trigger a checkpoint to record SBI_NEED_FSCK.

Signed-off-by: Zhiguo Niu <zhiguo.niu@...soc.com>
Signed-off-by: Chao Yu <chao@...nel.org>
---
  fs/f2fs/node.c          | 11 +++++++++--
  include/linux/f2fs_fs.h |  1 +
  2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index a2b2c6c7f66d..57d9dd3a43bc 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -2389,7 +2389,7 @@ static int scan_nat_page(struct f2fs_sb_info *sbi,
  		blk_addr = le32_to_cpu(nat_blk->entries[i].block_addr);

  		if (blk_addr == NEW_ADDR)
-			return -EINVAL;
+			return -EFSCORRUPTED;

  		if (blk_addr == NULL_ADDR) {
  			add_free_nid(sbi, start_nid, true, true);
@@ -2504,7 +2504,14 @@ static int __f2fs_build_free_nids(struct f2fs_sb_info *sbi,

  			if (ret) {
  				f2fs_up_read(&nm_i->nat_tree_lock);
-				f2fs_err(sbi, "NAT is corrupt, run fsck to fix it");
+
+				if (ret == -EFSCORRUPTED) {
+					f2fs_err(sbi, "NAT is corrupt, run fsck to fix it");
+					set_sbi_flag(sbi, SBI_NEED_FSCK);
+					f2fs_handle_error(sbi,
+							ERROR_INCONSISTENT_NAT);
+				}
+
  				return ret;
  			}
  		}
diff --git a/include/linux/f2fs_fs.h b/include/linux/f2fs_fs.h
index 07ed69c2840d..039fe0ce8d83 100644
--- a/include/linux/f2fs_fs.h
+++ b/include/linux/f2fs_fs.h
@@ -104,6 +104,7 @@ enum f2fs_error {
  	ERROR_CORRUPTED_VERITY_XATTR,
  	ERROR_CORRUPTED_XATTR,
  	ERROR_INVALID_NODE_REFERENCE,
+	ERROR_INCONSISTENT_NAT,
  	ERROR_MAX,
  };

-- 
2.40.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ