aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChao Yu <yuchao0@huawei.com>2020-11-01 20:53:31 +0800
committerJaegeuk Kim <jaegeuk@kernel.org>2020-12-07 09:25:14 -0800
commitc954e7cc4ba79a7fedef7dd66c8993381172d78e (patch)
tree4de20a56597c113e31daaadfdfd710076e1f3c98
parent1bfc17340d3276bd5ce050211cd25dad894485b3 (diff)
downloadf2fs-tools-c954e7cc4ba79a7fedef7dd66c8993381172d78e.tar.gz
fsck.f2fs: do xnid sanity check only during fsck
As Eric reported: Commit 7a22451bc2b4 ("fsck.f2fs: fix to check validation of i_xattr_nid") This commit caused a regression where 'dump.f2fs -i <inode> <device>' now segfaults if the inode has any extended attributes. It's because read_all_xattrs() now calls fsck_sanity_check_nid(), which eventually dereferences f2fs_fsck::main_area_bitmap, which is NULL. I'm not sure what was intended here. Here's the output from gdb: Program received signal SIGSEGV, Segmentation fault. 0x00007ffff7f750fa in f2fs_test_bit (nr=1024, p=0x0) at libf2fs.c:304 304 return (mask & *addr) != 0; (gdb) bt ntype=TYPE_XATTR, ni=0x7fffffffdd20) at fsck.c:449 ntype=TYPE_XATTR, ni=0x7fffffffdd20) at fsck.c:495 fsck_sanity_check_nid() should only called from fsck.f2fs context, rather than dump.f2fs, otherwise it may cause dereferencing structure fields of fsck incorrectly. Signed-off-by: Chao Yu <yuchao0@huawei.com>
-rw-r--r--fsck/xattr.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/fsck/xattr.c b/fsck/xattr.c
index e9dcb52..f0c5343 100644
--- a/fsck/xattr.c
+++ b/fsck/xattr.c
@@ -24,7 +24,7 @@ void *read_all_xattrs(struct f2fs_sb_info *sbi, struct f2fs_node *inode)
u64 inline_size = inline_xattr_size(&inode->i);
nid_t xnid = le32_to_cpu(inode->i.i_xattr_nid);
- if (xnid) {
+ if (c.func == FSCK && xnid) {
struct f2fs_node *node_blk = NULL;
struct node_info ni;
int ret;