Re: [syzbot] [block?] general protection fault in bio_first_folio

From: Hillf Danton
Date: Sat Dec 16 2023 - 02:01:37 EST


On Fri, 15 Dec 2023 21:20:22 -0800
> HEAD commit: abb240f7a2bd Add linux-next specific files for 20231212
> git tree: linux-next
> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=13274512e80000

#syz test https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git abb240f7a2bd

--- x/block/blk-map.c
+++ y/block/blk-map.c
@@ -269,6 +269,7 @@ static int bio_map_user_iov(struct reque
unsigned int max_sectors = queue_max_hw_sectors(rq->q);
unsigned int nr_vecs = iov_iter_npages(iter, BIO_MAX_VECS);
struct bio *bio;
+ int add_pg = 0;
int ret;
int j;

@@ -322,6 +323,7 @@ static int bio_map_user_iov(struct reque
bio_release_page(bio, page);
bytes -= n;
offs = 0;
+ add_pg = 1;
}
}
/*
@@ -344,7 +346,8 @@ static int bio_map_user_iov(struct reque
return 0;

out_unmap:
- bio_release_pages(bio, false);
+ if (add_pg)
+ bio_release_pages(bio, false);
blk_mq_map_bio_put(bio);
return ret;
}
--