Re: [syzbot] [PATCH] Test oob in squashfs readahead

From: syzbot
Date: Mon Nov 13 2023 - 20:04:59 EST


For archival purposes, forwarding an incoming command email to
linux-kernel@xxxxxxxxxxxxxxx.

***

Subject: [PATCH] Test oob in squashfs readahead
Author: eadavis@xxxxxx

please test squashfs readahead oob

#syz test https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 13d88ac54ddd

diff --git a/fs/squashfs/file.c b/fs/squashfs/file.c
index 8ba8c4c50770..0a586a7f470e 100644
--- a/fs/squashfs/file.c
+++ b/fs/squashfs/file.c
@@ -547,6 +547,9 @@ static void squashfs_readahead(struct readahead_control *ractl)
int i, file_end = i_size_read(inode) >> msblk->block_log;
unsigned int max_pages = 1UL << shift;

+ if (!file_end && !start)
+ return;
+
readahead_expand(ractl, start, (len | mask) + 1);

pages = kmalloc_array(max_pages, sizeof(void *), GFP_KERNEL);
diff --git a/fs/squashfs/file_direct.c b/fs/squashfs/file_direct.c
index f1ccad519e28..9c167df9248d 100644
--- a/fs/squashfs/file_direct.c
+++ b/fs/squashfs/file_direct.c
@@ -35,6 +35,9 @@ int squashfs_readpage_block(struct page *target_page, u64 block, int bsize,
struct squashfs_page_actor *actor;
void *pageaddr;

+ if (!file_end)
+ return -EINVAL;
+
if (end_index > file_end)
end_index = file_end;