linux/fs/ocfs2
Julian Sun 5784d9fcfd ocfs2: fix null-ptr-deref when journal load failed.
During the mounting process, if journal_reset() fails because of too short
journal, then lead to jbd2_journal_load() fails with NULL j_sb_buffer. 
Subsequently, ocfs2_journal_shutdown() calls
jbd2_journal_flush()->jbd2_cleanup_journal_tail()->
__jbd2_update_log_tail()->jbd2_journal_update_sb_log_tail()
->lock_buffer(journal->j_sb_buffer), resulting in a null-pointer
dereference error.

To resolve this issue, we should check the JBD2_LOADED flag to ensure the
journal was properly loaded.  Additionally, use journal instead of
osb->journal directly to simplify the code.

Link: https://syzkaller.appspot.com/bug?extid=05b9b39d8bdfe1a0861f
Link: https://lkml.kernel.org/r/20240902030844.422725-1-sunjunchao2870@gmail.com
Fixes: f6f50e28f0 ("jbd2: Fail to load a journal if it is too short")
Signed-off-by: Julian Sun <sunjunchao2870@gmail.com>
Reported-by: syzbot+05b9b39d8bdfe1a0861f@syzkaller.appspotmail.com
Suggested-by: Joseph Qi <joseph.qi@linux.alibaba.com>
Reviewed-by: Joseph Qi <joseph.qi@linux.alibaba.com>
Cc: Mark Fasheh <mark@fasheh.com>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: Junxiao Bi <junxiao.bi@oracle.com>
Cc: Changwei Ge <gechangwei@live.cn>
Cc: Gang He <ghe@suse.com>
Cc: Jun Piao <piaojun@huawei.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2024-09-09 15:15:53 -07:00
..
cluster net: change proto and proto_ops accept type 2024-05-13 18:19:09 -06:00
dlm ocfs2: remove redundant assignment to variable status 2024-05-08 08:41:27 -07:00
dlmfs ocfs2: remove SLAB_MEM_SPREAD flag usage 2024-03-14 09:17:29 -07:00
acl.c ocfs2: convert to new timestamp accessors 2023-10-18 14:08:24 +02:00
acl.h fs: port ->set_acl() to pass mnt_idmap 2023-01-19 09:24:27 +01:00
alloc.c fs: convert block_write_full_page to block_write_full_folio 2023-12-29 11:58:35 -08:00
alloc.h
aops.c ocfs2: fix DIO failure due to insufficient transaction credits 2024-06-24 20:52:10 -07:00
aops.h
blockcheck.c
blockcheck.h
buffer_head_io.c ocfs2: fix a spelling typo in comment 2023-11-01 12:46:59 -07:00
buffer_head_io.h
dcache.c ocfs2_find_match(): there's no such thing as NULL or negative ->d_parent 2023-12-21 12:53:30 -05:00
dcache.h
dir.c ocfs2: add bounds checking to ocfs2_check_dir_entry() 2024-07-04 23:43:10 -07:00
dir.h
dlmglue.c ocfs2: constify struct ocfs2_lock_res_ops 2024-06-24 22:25:10 -07:00
dlmglue.h
export.c ocfs2: fix sparse warnings 2024-04-25 21:07:04 -07:00
export.h
extent_map.c
extent_map.h
file.c ocfs2: fix races between hole punching and AIO+DIO 2024-04-25 21:07:06 -07:00
file.h fs: port ->permission() to pass mnt_idmap 2023-01-19 09:24:28 +01:00
filecheck.c
filecheck.h
heartbeat.c
heartbeat.h
inode.c ocfs2: fix sparse warnings 2024-04-25 21:07:04 -07:00
inode.h quota: Properly annotate i_dquot arrays with __rcu 2024-02-08 12:04:59 +01:00
ioctl.c ocfs2: update inode ctime in ocfs2_fileattr_set 2024-04-25 21:07:01 -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-09-09 15:15:53 -07:00
journal.h ocfs2: fix DIO failure due to insufficient transaction credits 2024-06-24 20:52:10 -07:00
Kconfig fs: add CONFIG_BUFFER_HEAD 2023-08-02 09:13:09 -06:00
localalloc.c ocfs2: fix sparse warnings 2024-04-25 21:07:04 -07:00
localalloc.h
locks.c ocfs2: adapt to breakup of struct file_lock 2024-02-05 13:11:43 +01:00
locks.h
Makefile
mmap.c
mmap.h
move_extents.c ocfs2: improve write IO performance when fragmentation is high 2024-04-25 21:07:03 -07:00
move_extents.h
namei.c fs: add kernel-doc comments to ocfs2_prepare_orphan_dir() 2024-07-04 23:43:10 -07:00
namei.h
ocfs1_fs_compat.h
ocfs2_fs.h ocfs2: improve write IO performance when fragmentation is high 2024-04-25 21:07:03 -07:00
ocfs2_ioctl.h
ocfs2_lockid.h
ocfs2_lockingver.h
ocfs2_trace.h ocfs2: fix DIO failure due to insufficient transaction credits 2024-06-24 20:52:10 -07:00
ocfs2.h ocfs2: constify struct ocfs2_lock_res_ops 2024-06-24 22:25:10 -07:00
quota_global.c quota: Set nofs allocation context when acquiring dqio_sem 2024-01-23 19:21:11 +01:00
quota_local.c quota: Set nofs allocation context when acquiring dqio_sem 2024-01-23 19:21:11 +01:00
quota.h
refcounttree.c ocfs2: fix sparse warnings 2024-04-25 21:07:04 -07:00
refcounttree.h
reservations.c ocfs2: correctly use ocfs2_find_next_zero_bit() 2024-04-25 21:07:01 -07:00
reservations.h
resize.c ocfs2: improve write IO performance when fragmentation is high 2024-04-25 21:07:03 -07:00
resize.h
slot_map.c ocfs2: Annotate struct ocfs2_slot_info with __counted_by 2023-10-02 09:48:52 -07:00
slot_map.h
stack_o2cb.c ocfs2: constify struct ocfs2_stack_operations 2024-06-24 22:25:10 -07:00
stack_user.c ocfs2: constify struct ocfs2_stack_operations 2024-06-24 22:25:10 -07:00
stackglue.c fs: Remove the now superfluous sentinel elements from ctl_table array 2023-12-28 04:57:57 -08:00
stackglue.h ocfs2: constify struct ocfs2_stack_operations 2024-06-24 22:25:10 -07:00
suballoc.c ocfs2: speed up chain-list searching 2024-04-25 21:07:04 -07:00
suballoc.h ocfs2: improve write IO performance when fragmentation is high 2024-04-25 21:07:03 -07:00
super.c ocfs2: fix NULL pointer dereference in ocfs2_abort_trigger() 2024-06-15 10:43:04 -07:00
super.h
symlink.c
symlink.h
sysfile.c
sysfile.h
uptodate.c
uptodate.h
xattr.c ocfs2: strict bound check before memcmp in ocfs2_xattr_find_entry() 2024-06-24 22:24:55 -07:00
xattr.h ocfs2: move ocfs2_xattr_handlers and ocfs2_xattr_handler_map to .rodata 2023-10-09 16:24:20 +02:00