summaryrefslogtreecommitdiffstats
path: root/fs/squashfs/file_direct.c
diff options
context:
space:
mode:
authorPhillip Lougher <phillip@squashfs.org.uk>2023-11-13 16:09:01 +0000
committerAndrew Morton <akpm@linux-foundation.org>2023-12-10 17:21:26 -0800
commit12427de9439d68b8e96ba6f50b601ef15f437612 (patch)
treeff3571cb2a307d3c05c9d58653e2e64ba7e6f55a /fs/squashfs/file_direct.c
parent44e3876d268be49ee810481ee3c95d8d650bf22e (diff)
downloadlinux-12427de9439d68b8e96ba6f50b601ef15f437612.tar.gz
linux-12427de9439d68b8e96ba6f50b601ef15f437612.tar.bz2
linux-12427de9439d68b8e96ba6f50b601ef15f437612.zip
Squashfs: fix variable overflow triggered by sysbot
Sysbot reports a slab out of bounds write in squashfs_readahead(). This is ultimately caused by a file reporting an (infeasibly) large file size (1407374883553280 bytes) with the minimum block size of 4K. This causes variable overflow. Link: https://lkml.kernel.org/r/20231113160901.6444-1-phillip@squashfs.org.uk Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk> Reported-by: syzbot+604424eb051c2f696163@syzkaller.appspotmail.com Closes: https://lore.kernel.org/all/000000000000b1fda20609ede0d1@google.com/ Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'fs/squashfs/file_direct.c')
-rw-r--r--fs/squashfs/file_direct.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/fs/squashfs/file_direct.c b/fs/squashfs/file_direct.c
index f1ccad519e28..763a3f7a75f6 100644
--- a/fs/squashfs/file_direct.c
+++ b/fs/squashfs/file_direct.c
@@ -26,10 +26,10 @@ int squashfs_readpage_block(struct page *target_page, u64 block, int bsize,
struct inode *inode = target_page->mapping->host;
struct squashfs_sb_info *msblk = inode->i_sb->s_fs_info;
- int file_end = (i_size_read(inode) - 1) >> PAGE_SHIFT;
+ loff_t file_end = (i_size_read(inode) - 1) >> PAGE_SHIFT;
int mask = (1 << (msblk->block_log - PAGE_SHIFT)) - 1;
- int start_index = target_page->index & ~mask;
- int end_index = start_index | mask;
+ loff_t start_index = target_page->index & ~mask;
+ loff_t end_index = start_index | mask;
int i, n, pages, bytes, res = -ENOMEM;
struct page **page;
struct squashfs_page_actor *actor;