linux/fs/f2fs
Wenjie Qi c2034ef619 f2fs: fix NULL pointer dereference in f2fs_submit_page_write()
BUG: kernel NULL pointer dereference, address: 0000000000000014
RIP: 0010:f2fs_submit_page_write+0x6cf/0x780 [f2fs]
Call Trace:
<TASK>
? show_regs+0x6e/0x80
? __die+0x29/0x70
? page_fault_oops+0x154/0x4a0
? prb_read_valid+0x20/0x30
? __irq_work_queue_local+0x39/0xd0
? irq_work_queue+0x36/0x70
? do_user_addr_fault+0x314/0x6c0
? exc_page_fault+0x7d/0x190
? asm_exc_page_fault+0x2b/0x30
? f2fs_submit_page_write+0x6cf/0x780 [f2fs]
? f2fs_submit_page_write+0x736/0x780 [f2fs]
do_write_page+0x50/0x170 [f2fs]
f2fs_outplace_write_data+0x61/0xb0 [f2fs]
f2fs_do_write_data_page+0x3f8/0x660 [f2fs]
f2fs_write_single_data_page+0x5bb/0x7a0 [f2fs]
f2fs_write_cache_pages+0x3da/0xbe0 [f2fs]
...
It is possible that other threads have added this fio to io->bio
and submitted the io->bio before entering f2fs_submit_page_write().
At this point io->bio = NULL.
If is_end_zone_blkaddr(sbi, fio->new_blkaddr) of this fio is true,
then an NULL pointer dereference error occurs at bio_get(io->bio).
The original code for determining zone end was after "out:",
which would have missed some fio who is zone end. I've moved
 this code before "skip:" to make sure it's done for each fio.

Fixes: e067dc3c6b ("f2fs: maintain six open zones for zoned devices")
Signed-off-by: Wenjie Qi <qwjhust@gmail.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2024-02-05 18:58:40 -08:00
..
acl.c fs: port i_{g,u}id_into_vfs{g,u}id() to mnt_idmap 2023-01-19 09:24:29 +01:00
acl.h fs: port ->set_acl() to pass mnt_idmap 2023-01-19 09:24:27 +01:00
checkpoint.c f2fs: introduce FAULT_BLKADDR_CONSISTENCE 2024-02-05 18:58:39 -08:00
compress.c f2fs: compress: fix to cover normal cluster write with cp_rwsem 2024-02-05 18:58:38 -08:00
data.c f2fs: fix NULL pointer dereference in f2fs_submit_page_write() 2024-02-05 18:58:40 -08:00
debug.c f2fs: fix to account cp stats correctly 2023-08-14 13:42:05 -07:00
dir.c f2fs: convert to new timestamp accessors 2023-10-18 13:26:22 +02:00
extent_cache.c f2fs: split initial and dynamic conditions for extent_cache 2023-09-12 13:49:33 -07:00
f2fs.h f2fs: introduce FAULT_BLKADDR_CONSISTENCE 2024-02-05 18:58:39 -08:00
file.c f2fs: introduce FAULT_BLKADDR_CONSISTENCE 2024-02-05 18:58:39 -08:00
gc.c f2fs: Add error handling for negative returns from do_garbage_collect 2023-12-26 13:06:40 -08:00
gc.h f2fs: Fix system crash due to lack of free space in LFS 2023-04-10 10:58:45 -07:00
hash.c f2fs: don't use casefolded comparison for "." and ".." 2022-05-17 11:19:23 -07:00
inline.c f2fs: convert to new timestamp accessors 2023-10-18 13:26:22 +02:00
inode.c f2fs update for 6.8-rc1 2024-01-11 20:39:15 -08:00
iostat.c f2fs: add async reset zone command support 2023-06-12 13:04:09 -07:00
iostat.h f2fs: use iostat_lat_type directly as a parameter in the iostat_update_and_unbind_ctx() 2023-02-07 10:39:28 -08:00
Kconfig fs: add CONFIG_BUFFER_HEAD 2023-08-02 09:13:09 -06:00
Makefile f2fs: separate out iostat feature 2021-08-23 10:25:51 -07:00
namei.c f2fs: remove unnecessary f2fs_put_page in f2fs_rename 2024-02-05 18:58:38 -08:00
node.c f2fs: fix to check return value of f2fs_recover_xattr_data 2023-12-15 15:09:17 -08:00
node.h f2fs: fix compile warning in f2fs_destroy_node_manager() 2023-06-30 16:38:27 -07:00
recovery.c f2fs: fix write pointers on zoned device after roll forward 2023-12-04 17:18:00 -08:00
segment.c f2fs: compress: fix to avoid inconsistence bewteen i_blocks and dnode 2024-02-05 18:58:39 -08:00
segment.h f2fs: Clean up errors in segment.h 2023-10-16 12:51:37 -07:00
shrinker.c f2fs: add block_age-based extent cache 2022-12-12 14:53:56 -08:00
super.c f2fs: introduce FAULT_BLKADDR_CONSISTENCE 2024-02-05 18:58:39 -08:00
sysfs.c f2fs: show more discard status by sysfs 2023-12-26 13:07:26 -08:00
verity.c f2fs-for-6.3-rc1 2023-02-27 16:18:51 -08:00
xattr.c f2fs: fix to check return value of f2fs_recover_xattr_data 2023-12-15 15:09:17 -08:00
xattr.h f2fs: move f2fs_xattr_handlers and f2fs_xattr_handler_map to .rodata 2023-10-09 16:24:18 +02:00