From edeb986b017e9489add4daa7e61bc79cdbfb913c Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Wed, 13 Oct 2021 13:45:46 -0400 Subject: bcachefs: Don't allocate too-big bios This fixes a null ptr deref in bio_alloc_bioset() -> biovec_slab() Signed-off-by: Kent Overstreet --- fs/bcachefs/io.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'fs/bcachefs/io.c') diff --git a/fs/bcachefs/io.c b/fs/bcachefs/io.c index 002fd35e6bfe..ea2adcc213d0 100644 --- a/fs/bcachefs/io.c +++ b/fs/bcachefs/io.c @@ -782,6 +782,8 @@ static struct bio *bch2_write_bio_alloc(struct bch_fs *c, ? ((unsigned long) buf & (PAGE_SIZE - 1)) : 0), PAGE_SIZE); + pages = min(pages, BIO_MAX_VECS); + bio = bio_alloc_bioset(NULL, pages, 0, GFP_NOIO, &c->bio_write); wbio = wbio_init(bio); -- cgit v1.2.3