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

Configure Feed

Select the types of activity you want to include in your feed.

block: fix bio_alloc_bioset slowpath GFP handling

bio_alloc_bioset() first strips __GFP_DIRECT_RECLAIM from the optimistic
fast allocation attempt with try_alloc_gfp(). If that fast path fails,
the slowpath checks saved_gfp to decide whether blocking allocation is
allowed, but then still calls mempool_alloc() with the stripped gfp mask.
That can lead to a NULL bio pointer being passed into bio_init().

Fix the slowpath by using saved_gfp for the bio and bvec mempool
allocations.

Fixes: b520c4eef83d ("block: split bio_alloc_bioset more clearly into a fast and slowpath")
Reported-by: syzbot+09ddb593eea76a158f42@syzkaller.appspotmail.com
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Link: https://patch.msgid.link/p01.gc6e9ad5845ad.ttca29g@ub.hpns
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Vasily Gorbik and committed by
Jens Axboe
67807fba 24d4c902

+2 -2
+2 -2
block/bio.c
··· 581 581 */ 582 582 opf &= ~REQ_ALLOC_CACHE; 583 583 584 - p = mempool_alloc(&bs->bio_pool, gfp); 584 + p = mempool_alloc(&bs->bio_pool, saved_gfp); 585 585 bio = p + bs->front_pad; 586 586 if (nr_vecs > BIO_INLINE_VECS) { 587 587 nr_vecs = BIO_MAX_VECS; 588 - bvecs = mempool_alloc(&bs->bvec_pool, gfp); 588 + bvecs = mempool_alloc(&bs->bvec_pool, saved_gfp); 589 589 } 590 590 } 591 591