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-next>] [day] [month] [year] [list]
Message-ID: <20241204122317.3042137-1-wangzijie1@honor.com>
Date: Wed, 4 Dec 2024 20:23:17 +0800
From: wangzijie <wangzijie1@...or.com>
To: <jaegeuk@...nel.org>, <chao@...nel.org>
CC: <linux-f2fs-devel@...ts.sourceforge.net>, <linux-kernel@...r.kernel.org>,
	<bintian.wang@...or.com>, wangzijie <wangzijie1@...or.com>
Subject: [f2fs-dev] f2fs-tools: Check and fix inline xattr inplace

When we check inode which just has inline xattr data, we copy
inline xattr data from inode, check it(maybe fix it) and copy
it again to inode. We can check and fix xattr inplace for this
kind of inode to reduce memcpy times.

Signed-off-by: wangzijie <wangzijie1@...or.com>
---
 fsck/fsck.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/fsck/fsck.c b/fsck/fsck.c
index aa3fb97..fd8b082 100644
--- a/fsck/fsck.c
+++ b/fsck/fsck.c
@@ -840,11 +840,18 @@ int chk_extended_attributes(struct f2fs_sb_info *sbi, u32 nid,
 	struct f2fs_xattr_entry *ent;
 	__u32 xattr_size = XATTR_SIZE(&inode->i);
 	bool need_fix = false;
+	bool has_xattr_node = false;
+	nid_t xnid = le32_to_cpu(inode->i.i_xattr_nid);
 
 	if (xattr_size == 0)
 		return 0;
 
-	xattr = read_all_xattrs(sbi, inode, false);
+	if (xattr_size <= inline_xattr_size(&inode->i) && !xnid)
+		xattr = inline_xattr_addr(&inode->i);
+	else {
+		xattr = read_all_xattrs(sbi, inode, false);
+		has_xattr_node = true;
+	}
 	ASSERT(xattr);
 
 	last_base_addr = (void *)xattr + xattr_size;
@@ -867,12 +874,15 @@ int chk_extended_attributes(struct f2fs_sb_info *sbi, u32 nid,
 	}
 	if (need_fix && c.fix_on) {
 		memset(ent, 0, (u8 *)last_base_addr - (u8 *)ent);
-		write_all_xattrs(sbi, inode, xattr_size, xattr);
+		if (has_xattr_node) {
+			write_all_xattrs(sbi, inode, xattr_size, xattr);
+			free(xattr);
+		}
 		FIX_MSG("[0x%x] nullify wrong xattr entries", nid);
-		free(xattr);
 		return 1;
 	}
-	free(xattr);
+	if (has_xattr_node)
+		free(xattr);
 	return 0;
 }
 
-- 
2.25.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ