Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Phillip Lougher and committed by
Andrew Morton
12427de9 44e3876d

+5 -4
+2 -1
fs/squashfs/file.c
··· 544 544 struct squashfs_page_actor *actor; 545 545 unsigned int nr_pages = 0; 546 546 struct page **pages; 547 - int i, file_end = i_size_read(inode) >> msblk->block_log; 547 + int i; 548 + loff_t file_end = i_size_read(inode) >> msblk->block_log; 548 549 unsigned int max_pages = 1UL << shift; 549 550 550 551 readahead_expand(ractl, start, (len | mask) + 1);
+3 -3
fs/squashfs/file_direct.c
··· 26 26 struct inode *inode = target_page->mapping->host; 27 27 struct squashfs_sb_info *msblk = inode->i_sb->s_fs_info; 28 28 29 - int file_end = (i_size_read(inode) - 1) >> PAGE_SHIFT; 29 + loff_t file_end = (i_size_read(inode) - 1) >> PAGE_SHIFT; 30 30 int mask = (1 << (msblk->block_log - PAGE_SHIFT)) - 1; 31 - int start_index = target_page->index & ~mask; 32 - int end_index = start_index | mask; 31 + loff_t start_index = target_page->index & ~mask; 32 + loff_t end_index = start_index | mask; 33 33 int i, n, pages, bytes, res = -ENOMEM; 34 34 struct page **page; 35 35 struct squashfs_page_actor *actor;