* [PATCH] fsck.f2fs: check validity of nid from journal
@ 2019-01-09 2:41 Chao Yu
0 siblings, 0 replies; only message in thread
From: Chao Yu @ 2019-01-09 2:41 UTC (permalink / raw)
To: linux-f2fs-devel, jaegeuk
As reported by Aravind:
I built f2fs tools from source (at tag v1.12.0) and was able to get this backtrace in gdb:
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7f8eb54 in f2fs_set_bit (nr=1041170432,
addr=0x7fffff621010 <error: Cannot access memory at address 0x7fffff621010>) at libf2fs.c:312
312 mask = 1 << (7 - (nr & 0x07));
(gdb) where
addr=0x7fffff621010 <error: Cannot access memory at address 0x7fffff621010>) at libf2fs.c:312
nid recorded in journal may be corrupted, let's do sanity check on them,
and skip loading invalid ones during build_node_manager().
Reported-by: Aravind R S <aravindet@gmail.com>
Signed-off-by: Chao Yu <yuchao0@huawei.com>
---
fsck/mount.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/fsck/mount.c b/fsck/mount.c
index ea70306b0895..e0d4db245a9e 100644
--- a/fsck/mount.c
+++ b/fsck/mount.c
@@ -1071,6 +1071,10 @@ static int f2fs_init_nid_bitmap(struct f2fs_sb_info *sbi)
addr = le32_to_cpu(nat_in_journal(journal, i).block_addr);
nid = le32_to_cpu(nid_in_journal(journal, i));
+ if (!IS_VALID_NID(sbi, nid)) {
+ MSG(0, "\tError: f2fs_init_nid_bitmap: nid(%u) is invalid!!!\n", nid);
+ continue;
+ }
if (addr != NULL_ADDR)
f2fs_set_bit(nid, nm_i->nid_bitmap);
}
--
2.18.0.rc1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2019-01-09 2:41 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-01-09 2:41 [PATCH] fsck.f2fs: check validity of nid from journal Chao Yu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).