From: Vasily Gorbik <gor@linux.ibm.com>
To: Jens Axboe <axboe@kernel.dk>
Cc: Christoph Hellwig <hch@lst.de>,
Chaitanya Kulkarni <kch@nvidia.com>,
"Martin K. Petersen" <martin.petersen@oracle.com>,
linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
syzkaller-bugs@googlegroups.com,
syzbot <syzbot+09ddb593eea76a158f42@syzkaller.appspotmail.com>
Subject: [PATCH] block: fix bio_alloc_bioset slowpath GFP handling
Date: Sun, 22 Mar 2026 03:35:10 +0100 [thread overview]
Message-ID: <p01.gc6e9ad5845ad.ttca29g@ub.hpns> (raw)
In-Reply-To: <69bdcdcd.050a0220.3bf4de.002f.GAE@google.com>
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>
---
If this looks fine, feel free to squash it into the offending commit or
pick it up separately.
block/bio.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/block/bio.c b/block/bio.c
index 5057047194c4..77067fa346d3 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -581,11 +581,11 @@ struct bio *bio_alloc_bioset(struct block_device *bdev, unsigned short nr_vecs,
*/
opf &= ~REQ_ALLOC_CACHE;
- p = mempool_alloc(&bs->bio_pool, gfp);
+ p = mempool_alloc(&bs->bio_pool, saved_gfp);
bio = p + bs->front_pad;
if (nr_vecs > BIO_INLINE_VECS) {
nr_vecs = BIO_MAX_VECS;
- bvecs = mempool_alloc(&bs->bvec_pool, gfp);
+ bvecs = mempool_alloc(&bs->bvec_pool, saved_gfp);
}
}
--
2.53.0
next prev parent reply other threads:[~2026-03-22 2:35 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-20 22:44 [syzbot] [block?] general protection fault in bio_alloc_bioset syzbot
2026-03-21 8:36 ` [PATCH next] block: mempool alloc fail due to insufficient memory Edward Adam Davis
2026-03-21 14:17 ` Jens Axboe
2026-03-21 22:52 ` [syzbot] [block?] general protection fault in bio_alloc_bioset Vasily Gorbik
2026-03-22 0:18 ` syzbot
2026-03-22 2:23 ` Vasily Gorbik
2026-03-22 2:35 ` Vasily Gorbik [this message]
2026-03-23 6:44 ` [PATCH] block: fix bio_alloc_bioset slowpath GFP handling Christoph Hellwig
2026-03-23 13:58 ` Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=p01.gc6e9ad5845ad.ttca29g@ub.hpns \
--to=gor@linux.ibm.com \
--cc=axboe@kernel.dk \
--cc=hch@lst.de \
--cc=kch@nvidia.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=syzbot+09ddb593eea76a158f42@syzkaller.appspotmail.com \
--cc=syzkaller-bugs@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox