Commit 9d81ba6d authored by Edward Adam Davis's avatar Edward Adam Davis Committed by Miklos Szeredi
Browse files

fuse: Block access to folio overlimit



syz reported a slab-out-of-bounds Write in fuse_dev_do_write.

When the number of bytes to be retrieved is truncated to the upper limit
by fc->max_pages and there is an offset, the oob is triggered.

Add a loop termination condition to prevent overruns.

Fixes: 3568a956 ("fuse: support large folios for retrieves")
Reported-by: default avatar <syzbot+2d215d165f9354b9c4ea@syzkaller.appspotmail.com>
Closes: https://syzkaller.appspot.com/bug?extid=2d215d165f9354b9c4ea


Tested-by: default avatar <syzbot+2d215d165f9354b9c4ea@syzkaller.appspotmail.com>
Signed-off-by: default avatarEdward Adam Davis <eadavis@qq.com>
Reviewed-by: default avatarJoanne Koong <joannelkoong@gmail.com>
Signed-off-by: default avatarMiklos Szeredi <mszeredi@redhat.com>
parent bd24d210
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1893,7 +1893,7 @@ static int fuse_retrieve(struct fuse_mount *fm, struct inode *inode,

	index = outarg->offset >> PAGE_SHIFT;

	while (num) {
	while (num && ap->num_folios < num_pages) {
		struct folio *folio;
		unsigned int folio_offset;
		unsigned int nr_bytes;