Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e0d1f700 authored by Phillip Lougher's avatar Phillip Lougher
Browse files

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: default avatarPhillip Lougher <phillip@lougher.demon.co.uk>
parent 370ec3d1
Loading
Loading
Loading
Loading
+2 −3
Original line number Original line Diff line number Diff line
@@ -87,9 +87,8 @@ int squashfs_read_data(struct super_block *sb, void **buffer, u64 index,
	u64 cur_index = index >> msblk->devblksize_log2;
	u64 cur_index = index >> msblk->devblksize_log2;
	int bytes, compressed, b = 0, k = 0, page = 0, avail;
	int bytes, compressed, b = 0, k = 0, page = 0, avail;



	bh = kcalloc(((srclength + msblk->devblksize - 1)
	bh = kcalloc((msblk->block_size >> msblk->devblksize_log2) + 1,
		>> msblk->devblksize_log2) + 1, sizeof(*bh), GFP_KERNEL);
				sizeof(*bh), GFP_KERNEL);
	if (bh == NULL)
	if (bh == NULL)
		return -ENOMEM;
		return -ENOMEM;