Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

jfs: fix log->bdev_handle null ptr deref in lbmStartIO

When sbi->flag is JFS_NOINTEGRITY in lmLogOpen(), log->bdev_handle can't
be inited, so it value will be NULL.
Therefore, add the "log ->no_integrity=1" judgment in lbmStartIO() to avoid such
problems.

Reported-and-tested-by: syzbot+23bc20037854bb335d59@syzkaller.appspotmail.com
Signed-off-by: Lizhi Xu <lizhi.xu@windriver.com>
Link: https://lore.kernel.org/r/20231009094557.1398920-1-lizhi.xu@windriver.com
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Christian Brauner <brauner@kernel.org>

authored by

Lizhi Xu and committed by
Christian Brauner
6306ff39 b3856da7

+5 -1
+5 -1
fs/jfs/jfs_logmgr.c
··· 2110 2110 { 2111 2111 struct bio *bio; 2112 2112 struct jfs_log *log = bp->l_log; 2113 + struct block_device *bdev = NULL; 2113 2114 2114 2115 jfs_info("lbmStartIO"); 2115 2116 2116 - bio = bio_alloc(log->bdev_handle->bdev, 1, REQ_OP_WRITE | REQ_SYNC, 2117 + if (!log->no_integrity) 2118 + bdev = log->bdev_handle->bdev; 2119 + 2120 + bio = bio_alloc(bdev, 1, REQ_OP_WRITE | REQ_SYNC, 2117 2121 GFP_NOFS); 2118 2122 bio->bi_iter.bi_sector = bp->l_blkno << (log->l2bsize - 9); 2119 2123 __bio_add_page(bio, bp->l_page, LOGPSIZE, bp->l_offset);