From: Kent Overstreet Date: Wed, 13 Oct 2021 17:45:46 +0000 (-0400) Subject: bcachefs: Don't allocate too-big bios X-Git-Tag: v6.7-rc1~201^2~1358 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=edeb986b017e9489add4daa7e61bc79cdbfb913c;p=thirdparty%2Fkernel%2Flinux.git bcachefs: Don't allocate too-big bios This fixes a null ptr deref in bio_alloc_bioset() -> biovec_slab() Signed-off-by: Kent Overstreet --- diff --git a/fs/bcachefs/io.c b/fs/bcachefs/io.c index 002fd35e6bfea..ea2adcc213d08 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);