diff options
author | Phillip Lougher <phillip@lougher.demon.co.uk> | 2010-04-22 21:32:02 -0400 |
---|---|---|
committer | Phillip Lougher <phillip@lougher.demon.co.uk> | 2010-04-24 21:09:05 -0400 |
commit | e0d1f70010dce062ccce1bbd940a661e60b82631 (patch) | |
tree | 1a0844867f6aa1600a07a8a5321325ddf016a6e6 /fs/squashfs | |
parent | 370ec3d1ed9d76ba992e5b9b7d7d10700014d436 (diff) |
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>
Diffstat (limited to 'fs/squashfs')
-rw-r--r-- | fs/squashfs/block.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/fs/squashfs/block.c b/fs/squashfs/block.c index 1cb0d81b164b..653c030eb840 100644 --- a/fs/squashfs/block.c +++ b/fs/squashfs/block.c | |||
@@ -87,9 +87,8 @@ int squashfs_read_data(struct super_block *sb, void **buffer, u64 index, | |||
87 | u64 cur_index = index >> msblk->devblksize_log2; | 87 | u64 cur_index = index >> msblk->devblksize_log2; |
88 | int bytes, compressed, b = 0, k = 0, page = 0, avail; | 88 | int bytes, compressed, b = 0, k = 0, page = 0, avail; |
89 | 89 | ||
90 | 90 | bh = kcalloc(((srclength + msblk->devblksize - 1) | |
91 | bh = kcalloc((msblk->block_size >> msblk->devblksize_log2) + 1, | 91 | >> msblk->devblksize_log2) + 1, sizeof(*bh), GFP_KERNEL); |
92 | sizeof(*bh), GFP_KERNEL); | ||
93 | if (bh == NULL) | 92 | if (bh == NULL) |
94 | return -ENOMEM; | 93 | return -ENOMEM; |
95 | 94 | ||