Skip to content

Commit e0d1f70

Browse files
author
Phillip Lougher
committed
squashfs: fix potential buffer over-run on 4K block file systems
Sizing the buffer based on block size is incorrect, leading to a potential buffer over-run on 4K block size file systems (because the metadata block size is always 8K). This bug doesn't seem have triggered because 4K block size file systems are not default, and also because metadata blocks after compression tend to be less than 4K. Signed-off-by: Phillip Lougher <phillip@lougher.demon.co.uk>
1 parent 370ec3d commit e0d1f70

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

‎fs/squashfs/block.c‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,8 @@ int squashfs_read_data(struct super_block *sb, void **buffer, u64 index,
8787
u64 cur_index = index >> msblk->devblksize_log2;
8888
int bytes, compressed, b = 0, k = 0, page = 0, avail;
8989

90-
91-
bh = kcalloc((msblk->block_size >> msblk->devblksize_log2) + 1,
92-
sizeof(*bh), GFP_KERNEL);
90+
bh = kcalloc(((srclength + msblk->devblksize - 1)
91+
>> msblk->devblksize_log2) + 1, sizeof(*bh), GFP_KERNEL);
9392
if (bh == NULL)
9493
return -ENOMEM;
9594

0 commit comments

Comments
 (0)