Skip to content

Commit 81e366f

Browse files
chaseyuJaegeuk Kim
authored andcommitted
f2fs: check name_len of dir entry to prevent from deadloop
We assume that modification of some special application could result in zeroed name_len, or it is consciously made by somebody. We will deadloop in find_in_block when name_len of dir entry is zero. This patch is added for preventing deadloop in above scenario. change log from v1: o use f2fs_bug_on rather than break out from searching dir entry suggested by Jaegeuk Kim. Jaegeuk describe: "Well, IMO, it would be good to add f2fs_bug_on() here with a specific comment. In the current phase of f2fs, it is more important to investigate the file system bugs, rather than workarounds for any corrupted images. And, definitely it needs to stop the kernel if any corrupted image was mounted, so that we can figure out where the bugs are occurred." Suggested-by: Jaegeuk Kim <jaegeuk@kernel.org> Signed-off-by: Chao Yu <chao2.yu@samsung.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
1 parent 6b2920a commit 81e366f

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

‎fs/f2fs/dir.c‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,13 @@ static struct f2fs_dir_entry *find_in_block(struct page *dentry_page,
121121
*max_slots = max_len;
122122
max_len = 0;
123123
}
124+
125+
/*
126+
* For the most part, it should be a bug when name_len is zero.
127+
* We stop here for figuring out where the bugs are occurred.
128+
*/
129+
f2fs_bug_on(!de->name_len);
130+
124131
bit_pos += GET_DENTRY_SLOTS(le16_to_cpu(de->name_len));
125132
}
126133

0 commit comments

Comments
 (0)