Message ID | 20231009094557.1398920-1-lizhi.xu@windriver.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | jfs: fix log->bdev_handle null ptr deref in lbmStartIO | expand |
On Mon 09-10-23 17:45:57, Lizhi Xu wrote: > 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> Ah, good catch. Who would think someone creates bios for NULL bdev only to release them shortly afterwards ;). Anyway the fix looks good. Feel free to add: Reviewed-by: Jan Kara <jack@suse.cz> Christian, please pick up this fixup into your tree. Thanks! Honza > --- > fs/jfs/jfs_logmgr.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/fs/jfs/jfs_logmgr.c b/fs/jfs/jfs_logmgr.c > index c911d838b8ec..c41a76164f84 100644 > --- a/fs/jfs/jfs_logmgr.c > +++ b/fs/jfs/jfs_logmgr.c > @@ -2110,10 +2110,14 @@ static void lbmStartIO(struct lbuf * bp) > { > struct bio *bio; > struct jfs_log *log = bp->l_log; > + struct block_device *bdev = NULL; > > jfs_info("lbmStartIO"); > > - bio = bio_alloc(log->bdev_handle->bdev, 1, REQ_OP_WRITE | REQ_SYNC, > + if (!log->no_integrity) > + bdev = log->bdev_handle->bdev; > + > + bio = bio_alloc(bdev, 1, REQ_OP_WRITE | REQ_SYNC, > GFP_NOFS); > bio->bi_iter.bi_sector = bp->l_blkno << (log->l2bsize - 9); > __bio_add_page(bio, bp->l_page, LOGPSIZE, bp->l_offset); > -- > 2.25.1 >
On Mon, 09 Oct 2023 17:45:57 +0800, Lizhi Xu wrote: > 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. > > Applied to the vfs.super branch of the vfs/vfs.git tree. Patches in the vfs.super branch should appear in linux-next soon. Please report any outstanding bugs that were missed during review in a new review to the original patch series allowing us to drop it. It's encouraged to provide Acked-bys and Reviewed-bys even though the patch has now been applied. If possible patch trailers will be updated. Note that commit hashes shown below are subject to change due to rebase, trailer updates or similar. If in doubt, please check the listed branch. tree: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git branch: vfs.super [1/1] jfs: fix log->bdev_handle null ptr deref in lbmStartIO https://git.kernel.org/vfs/vfs/c/dc869ef84f26
> Christian, please pick up this fixup into your tree. Thanks!
Done!
diff --git a/fs/jfs/jfs_logmgr.c b/fs/jfs/jfs_logmgr.c index c911d838b8ec..c41a76164f84 100644 --- a/fs/jfs/jfs_logmgr.c +++ b/fs/jfs/jfs_logmgr.c @@ -2110,10 +2110,14 @@ static void lbmStartIO(struct lbuf * bp) { struct bio *bio; struct jfs_log *log = bp->l_log; + struct block_device *bdev = NULL; jfs_info("lbmStartIO"); - bio = bio_alloc(log->bdev_handle->bdev, 1, REQ_OP_WRITE | REQ_SYNC, + if (!log->no_integrity) + bdev = log->bdev_handle->bdev; + + bio = bio_alloc(bdev, 1, REQ_OP_WRITE | REQ_SYNC, GFP_NOFS); bio->bi_iter.bi_sector = bp->l_blkno << (log->l2bsize - 9); __bio_add_page(bio, bp->l_page, LOGPSIZE, bp->l_offset);
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> --- fs/jfs/jfs_logmgr.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)