fsck.f2fs: check validity of nid from journal
PATCH 1/1 fsck.f2fs: check validity of nid from journal
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:312nid 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 <[email protected]>
Signed-off-by Chao Yu <[email protected]>
--- fsck/mount.c | 4 ++++ 1 file changed, 4 insertions(+)
fsck/mount.c +4 -0
@@ -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); }
Signature · 1 line
2.18.0.rc1