OpenCloudOS-Kernel/fs/ocfs2
Dmitry Antipov 8e0de82ed1 ocfs2: fix uninitialized value in ocfs2_file_read_iter()
[ Upstream commit adc77b19f62d7e80f98400b2fca9d700d2afdd6f ]

Syzbot has reported the following KMSAN splat:

BUG: KMSAN: uninit-value in ocfs2_file_read_iter+0x9a4/0xf80
 ocfs2_file_read_iter+0x9a4/0xf80
 __io_read+0x8d4/0x20f0
 io_read+0x3e/0xf0
 io_issue_sqe+0x42b/0x22c0
 io_wq_submit_work+0xaf9/0xdc0
 io_worker_handle_work+0xd13/0x2110
 io_wq_worker+0x447/0x1410
 ret_from_fork+0x6f/0x90
 ret_from_fork_asm+0x1a/0x30

Uninit was created at:
 __alloc_pages_noprof+0x9a7/0xe00
 alloc_pages_mpol_noprof+0x299/0x990
 alloc_pages_noprof+0x1bf/0x1e0
 allocate_slab+0x33a/0x1250
 ___slab_alloc+0x12ef/0x35e0
 kmem_cache_alloc_bulk_noprof+0x486/0x1330
 __io_alloc_req_refill+0x84/0x560
 io_submit_sqes+0x172f/0x2f30
 __se_sys_io_uring_enter+0x406/0x41c0
 __x64_sys_io_uring_enter+0x11f/0x1a0
 x64_sys_call+0x2b54/0x3ba0
 do_syscall_64+0xcd/0x1e0
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

Since an instance of 'struct kiocb' may be passed from the block layer
with 'private' field uninitialized, introduce 'ocfs2_iocb_init_rw_locked()'
and use it from where 'ocfs2_dio_end_io()' might take care, i.e. in
'ocfs2_file_read_iter()' and 'ocfs2_file_write_iter()'.

Link: https://lkml.kernel.org/r/20241029091736.1501946-1-dmantipov@yandex.ru
Fixes: 7cdfc3a1c3 ("ocfs2: Remember rw lock level during direct io")
Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
Reported-by: syzbot+a73e253cca4f0230a5a5@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=a73e253cca4f0230a5a5
Cc: Mark Fasheh <mark@fasheh.com>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: Junxiao Bi <junxiao.bi@oracle.com>
Cc: Joseph Qi <jiangqi903@gmail.com>
Cc: Changwei Ge <gechangwei@live.cn>
Cc: Jun Piao <piaojun@huawei.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-12-09 10:32:20 +01:00
..
cluster ocfs2: cluster: fix potential deadlock on &o2net_debug_lock 2023-08-18 10:18:59 -07:00
dlm ocfs2/dlm: use bitmap API instead of hand-writing it 2022-11-18 13:55:06 -08:00
dlmfs ocfs2: convert to new timestamp accessors 2024-06-27 13:49:14 +02:00
Kconfig fs: add CONFIG_BUFFER_HEAD 2023-08-02 09:13:09 -06:00
Makefile
acl.c ocfs2: convert to new timestamp accessors 2024-06-27 13:49:14 +02:00
acl.h fs: port ->set_acl() to pass mnt_idmap 2023-01-19 09:24:27 +01:00
alloc.c ocfs2: convert to new timestamp accessors 2024-06-27 13:49:14 +02:00
alloc.h
aops.c ocfs2: fix uninit-value in ocfs2_get_block() 2024-10-10 11:57:51 +02:00
aops.h ocfs2: fix uninitialized value in ocfs2_file_read_iter() 2024-12-09 10:32:20 +01:00
blockcheck.c
blockcheck.h
buffer_head_io.c ocfs2: fix possible null-ptr-deref in ocfs2_set_buffer_uptodate 2024-10-10 11:57:51 +02:00
buffer_head_io.h
dcache.c
dcache.h
dir.c ocfs2: add bounds checking to ocfs2_check_dir_entry() 2024-07-27 11:34:08 +02:00
dir.h
dlmglue.c ocfs2: convert to new timestamp accessors 2024-06-27 13:49:14 +02:00
dlmglue.h
export.c
export.h
extent_map.c
extent_map.h
file.c ocfs2: fix uninitialized value in ocfs2_file_read_iter() 2024-12-09 10:32:20 +01:00
file.h fs: port ->permission() to pass mnt_idmap 2023-01-19 09:24:28 +01:00
filecheck.c
filecheck.h
heartbeat.c ocfs2: fix a typo in a comment 2022-07-29 18:12:36 -07:00
heartbeat.h
inode.c ocfs2: convert to new timestamp accessors 2024-06-27 13:49:14 +02:00
inode.h quota: Properly annotate i_dquot arrays with __rcu 2024-03-26 18:19:46 -04:00
ioctl.c ocfs2: reduce ioctl stack usage 2023-04-21 14:54:34 -07:00
ioctl.h fs: port ->fileattr_set() to pass mnt_idmap 2023-01-19 09:24:27 +01:00
journal.c ocfs2: fix null-ptr-deref when journal load failed. 2024-10-10 11:57:51 +02:00
journal.h ocfs2: fix DIO failure due to insufficient transaction credits 2024-07-05 09:33:54 +02:00
localalloc.c ocfs2: fix the la space leak when unmounting an ocfs2 volume 2024-10-10 11:57:50 +02:00
localalloc.h
locks.c filelock: move file locking definitions to separate header file 2023-01-11 06:52:32 -05:00
locks.h
mmap.c
mmap.h
move_extents.c ocfs2: convert to new timestamp accessors 2024-06-27 13:49:14 +02:00
move_extents.h
namei.c ocfs2: update inode fsync transaction id in ocfs2_unlink and ocfs2_link 2024-06-27 13:49:14 +02:00
namei.h
ocfs1_fs_compat.h
ocfs2.h ocfs2: fix NULL pointer dereference in ocfs2_abort_trigger() 2024-06-27 13:49:12 +02:00
ocfs2_fs.h ocfs2: replace zero-length arrays with DECLARE_FLEX_ARRAY() helper 2022-10-03 14:21:42 -07:00
ocfs2_ioctl.h
ocfs2_lockid.h
ocfs2_lockingver.h
ocfs2_trace.h ocfs2: fix DIO failure due to insufficient transaction credits 2024-07-05 09:33:54 +02:00
quota.h
quota_global.c fs/ocfs2: Fix spelling typo in comment 2022-07-17 17:31:43 -07:00
quota_local.c ocfs2: cancel dqi_sync_work before freeing oinfo 2024-10-10 11:57:51 +02:00
refcounttree.c ocfs2: reserve space for inline xattr before attaching reflink tree 2024-10-10 11:57:51 +02:00
refcounttree.h
reservations.c ocfs2: change return type of ocfs2_resmap_init 2022-04-29 14:37:58 -07:00
reservations.h ocfs2: change return type of ocfs2_resmap_init 2022-04-29 14:37:58 -07:00
resize.c ocfs2: uncache inode which has failed entering the group 2024-11-22 15:38:33 +01:00
resize.h
slot_map.c Revert "ocfs2: mount shared volume without ha stack" 2022-07-18 15:09:15 -07:00
slot_map.h
stack_o2cb.c ocfs2: use bitmap API in fill_node_map 2022-11-18 13:55:06 -08:00
stack_user.c fs: dlm: fix F_CANCELLK to cancel pending request 2023-07-20 17:25:04 -05:00
stackglue.c ocfs2: fix memory leak in ocfs2_stack_glue_init() 2022-11-18 13:55:09 -08:00
stackglue.h
suballoc.c
suballoc.h fs/ocfs2/suballoc.h: fix spelling typo in comment 2022-10-03 14:21:42 -07:00
super.c ocfs2: fix UBSAN warning in ocfs2_verify_volume() 2024-11-22 15:38:34 +01:00
super.h
symlink.c ocfs2: Convert ocfs2 to read_folio 2022-05-09 16:21:46 -04:00
symlink.h
sysfile.c
sysfile.h
uptodate.c
uptodate.h
xattr.c ocfs2: remove entry once instead of null-ptr-dereference in ocfs2_xa_remove() 2024-11-14 13:19:40 +01:00
xattr.h