linux-stable/fs/f2fs
Chao Yu 09beadf289 f2fs: fix to do sanity check on segment type in build_sit_entries()
As Wenqing Liu <wenqingliu0120@gmail.com> reported in bugzilla:

https://bugzilla.kernel.org/show_bug.cgi?id=216285

RIP: 0010:memcpy_erms+0x6/0x10
 f2fs_update_meta_page+0x84/0x570 [f2fs]
 change_curseg.constprop.0+0x159/0xbd0 [f2fs]
 f2fs_do_replace_block+0x5c7/0x18a0 [f2fs]
 f2fs_replace_block+0xeb/0x180 [f2fs]
 recover_data+0x1abd/0x6f50 [f2fs]
 f2fs_recover_fsync_data+0x12ce/0x3250 [f2fs]
 f2fs_fill_super+0x4459/0x6190 [f2fs]
 mount_bdev+0x2cf/0x3b0
 legacy_get_tree+0xed/0x1d0
 vfs_get_tree+0x81/0x2b0
 path_mount+0x47e/0x19d0
 do_mount+0xce/0xf0
 __x64_sys_mount+0x12c/0x1a0
 do_syscall_64+0x38/0x90
 entry_SYSCALL_64_after_hwframe+0x63/0xcd

The root cause is segment type is invalid, so in f2fs_do_replace_block(),
f2fs accesses f2fs_sm_info::curseg_array with out-of-range segment type,
result in accessing invalid curseg->sum_blk during memcpy in
f2fs_update_meta_page(). Fix this by adding sanity check on segment type
in build_sit_entries().

Reported-by: Wenqing Liu <wenqingliu0120@gmail.com>
Signed-off-by: Chao Yu <chao.yu@oppo.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2022-07-30 20:19:00 -07:00
..
acl.c f2fs: support idmapped mounts 2022-02-12 06:20:46 -08:00
acl.h vfs: add rcu argument to ->get_acl() callback 2021-08-18 22:08:24 +02:00
checkpoint.c f2fs-for-5.19 2022-05-31 16:52:59 -07:00
compress.c f2fs: initialize page_array_entry slab only if compression feature is on 2022-06-28 09:27:10 -07:00
data.c f2fs: introduce sysfs atomic write statistics 2022-07-30 20:17:07 -07:00
debug.c f2fs: adjust zone capacity when considering valid block count 2022-07-30 20:16:20 -07:00
dir.c f2fs: don't use casefolded comparison for "." and ".." 2022-05-17 11:19:23 -07:00
extent_cache.c f2fs: support fault injection for f2fs_kmem_cache_alloc() 2021-08-17 11:59:05 -07:00
f2fs.h f2fs: obsolete unused MAX_DISCARD_BLOCKS 2022-07-30 20:18:09 -07:00
file.c f2fs: fix to remove F2FS_COMPR_FL and tag F2FS_NOCOMP_FL at the same time 2022-07-30 20:17:07 -07:00
gc.c f2fs: don't bother wait_ms by foreground gc 2022-07-30 20:17:07 -07:00
gc.h f2fs: remove redundant code for gc condition 2022-07-30 20:16:20 -07:00
hash.c f2fs: don't use casefolded comparison for "." and ".." 2022-05-17 11:19:23 -07:00
inline.c f2fs: fix to do sanity check for inline inode 2022-05-18 15:36:11 -07:00
inode.c f2fs: replace F2FS_I(inode) and sbi by the local variable 2022-05-27 13:58:23 -07:00
iostat.c f2fs: fix iostat related lock protection 2022-06-19 15:16:12 -07:00
iostat.h f2fs: introduce periodic iostat io latency traces 2021-08-23 10:25:51 -07:00
Kconfig f2fs: introduce F2FS_UNFAIR_RWSEM to support unfair rwsem 2022-03-04 09:15:53 -08:00
Makefile f2fs: separate out iostat feature 2021-08-23 10:25:51 -07:00
namei.c f2fs: attach inline_data after setting compression 2022-06-19 15:16:10 -07:00
node.c f2fs: fix to avoid use f2fs_bug_on() in f2fs_new_node_page() 2022-07-30 20:17:57 -07:00
node.h f2fs: change the current atomic write way 2022-05-12 10:14:03 -07:00
recovery.c f2fs-for-5.18 2022-03-22 10:00:31 -07:00
segment.c f2fs: fix to do sanity check on segment type in build_sit_entries() 2022-07-30 20:19:00 -07:00
segment.h f2fs: adjust zone capacity when considering valid block count 2022-07-30 20:16:20 -07:00
shrinker.c f2fs: avoid race condition for shrinker count 2020-12-03 00:59:26 -08:00
super.c f2fs: introduce sysfs atomic write statistics 2022-07-30 20:17:07 -07:00
sysfs.c f2fs: introduce sysfs atomic write statistics 2022-07-30 20:17:07 -07:00
verity.c f2fs-for-5.19 2022-05-31 16:52:59 -07:00
xattr.c f2fs: move f2fs to use reader-unfair rwsems 2022-01-24 17:40:04 -08:00
xattr.h f2fs: code cleanup by removing ifdef macro surrounding 2020-05-26 18:56:10 -07:00