android_kernel_oneplus_msm8998/fs/f2fs
Chao Yu c9aac2ca34 f2fs: fix to do sanity check on segment bitmap of LFS curseg
[ Upstream commit c854f4d681365498f53ba07843a16423625aa7e9 ]

As Jungyeon Reported in bugzilla:

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

- Reproduces
gcc poc_13.c
./run.sh f2fs

- Kernel messages
 F2FS-fs (sdb): Bitmap was wrongly set, blk:4608
 kernel BUG at fs/f2fs/segment.c:2133!
 RIP: 0010:update_sit_entry+0x35d/0x3e0
 Call Trace:
  f2fs_allocate_data_block+0x16c/0x5a0
  do_write_page+0x57/0x100
  f2fs_do_write_node_page+0x33/0xa0
  __write_node_page+0x270/0x4e0
  f2fs_sync_node_pages+0x5df/0x670
  f2fs_write_checkpoint+0x364/0x13a0
  f2fs_sync_fs+0xa3/0x130
  f2fs_do_sync_file+0x1a6/0x810
  do_fsync+0x33/0x60
  __x64_sys_fsync+0xb/0x10
  do_syscall_64+0x43/0x110
  entry_SYSCALL_64_after_hwframe+0x44/0xa9

The testcase fails because that, in fuzzed image, current segment was
allocated with LFS type, its .next_blkoff should point to an unused
block address, but actually, its bitmap shows it's not. So during
allocation, f2fs crash when setting bitmap.

Introducing sanity_check_curseg() to check such inconsistence of
current in-used segment.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2019-10-05 12:27:40 +02:00
..
acl.c f2fs: fix wrong return value of f2fs_acl_create 2019-02-20 10:13:06 +01:00
acl.h f2fs: avoid deadlock on init_inode_metadata 2014-11-03 16:07:33 -08:00
checkpoint.c f2fs: fix invalid memory access 2019-01-26 09:42:48 +01:00
crypto.c f2fs crypto: replace some BUG_ON()'s with error checks 2017-10-27 10:23:18 +02:00
crypto_fname.c f2fs crypto: replace some BUG_ON()'s with error checks 2017-10-27 10:23:18 +02:00
crypto_key.c fscrypt: fix dereference of NULL user_key_payload 2017-10-27 10:23:18 +02:00
crypto_policy.c fscrypt: don't set policy for a dead directory 2019-07-21 09:07:10 +02:00
data.c f2fs: fix to do sanity check with block address in main area v2 2019-01-26 09:42:48 +01:00
debug.c f2fs: set ->owner for debugfs status file's file_operations 2017-01-06 11:16:13 +01:00
dir.c f2fs: fix to convert inline directory correctly 2019-01-26 09:42:45 +01:00
extent_cache.c f2fs: fix a bug caused by NULL extent tree 2018-03-03 10:19:41 +01:00
f2fs.h f2fs: fix to do sanity check with block address in main area 2019-01-26 09:42:48 +01:00
f2fs_crypto.h fscrypt: remove broken support for detecting keyring key revocation 2017-03-31 09:49:54 +02:00
file.c f2fs: move dir data flush to write checkpoint process 2019-02-20 10:13:06 +01:00
gc.c f2fs: relax node version check for victim data in gc 2018-03-22 09:23:22 +01:00
gc.h f2fs: support synchronous gc in ioctl 2015-10-09 16:20:56 -07:00
hash.c f2fs: check entire encrypted bigname when finding a dentry 2017-05-25 14:30:11 +02:00
inline.c f2fs: fix to do sanity check with reserved blkaddr of inline inode 2019-01-26 09:42:48 +01:00
inode.c f2fs: fix to do sanity check with block address in main area v2 2019-01-26 09:42:48 +01:00
Kconfig f2fs: fix typo 2015-08-21 22:43:32 -07:00
Makefile f2fs: maintain extent cache in separated file 2015-08-04 14:09:58 -07:00
namei.c do d_instantiate/unlock_new_inode combinations safely 2018-05-30 07:48:52 +02:00
node.c f2fs: read page index before freeing 2019-02-06 19:43:05 +01:00
node.h f2fs: use crc and cp version to determine roll-forward recovery 2019-01-26 09:42:46 +01:00
recovery.c f2fs: fix to avoid panic in do_recover_data() 2019-06-22 08:18:19 +02:00
segment.c f2fs: fix to do sanity check on segment bitmap of LFS curseg 2019-10-05 12:27:40 +02:00
segment.h f2fs: fix to do sanity check on valid block count of segment 2019-06-22 08:18:19 +02:00
shrinker.c f2fs: shrink free_nids entries 2015-08-20 09:00:06 -07:00
super.c f2fs: check all the data segments against all node ones 2019-10-05 12:27:40 +02:00
trace.c f2fs: do not use mutex lock in atomic context 2019-04-27 09:33:49 +02:00
trace.h f2fs: add sbi and page pointer in f2fs_io_info 2015-05-28 15:41:32 -07:00
xattr.c f2fs: xattr simplifications 2015-11-13 20:34:34 -05:00
xattr.h f2fs crypto: add encryption xattr support 2015-05-28 15:41:47 -07:00