diff options
author | Christoph Hellwig <hch@tuxera.com> | 2011-02-16 03:34:17 -0500 |
---|---|---|
committer | Christoph Hellwig <hch@lst.de> | 2011-06-30 07:40:58 -0400 |
commit | bf1a1b31fa3ea24e3a90821d69a5c3da066f7d6c (patch) | |
tree | 32a751e5c58854fbb5aff9797fe73f6122e0b3ed /fs/hfsplus/extents.c | |
parent | 2b4f9ca8a575ce6d7ddb59d668e2be250bf86a8f (diff) |
hfsplus: fix overflow in hfsplus_get_block
For filesystems larger than 2TB the final sector number passed to
map_bh might overflow the range representable in a 32-bit data type.
Make sure we use a sector_t for it and the arithmetics calculating it.
Signed-off-by: Christoph Hellwig <hch@tuxera.com>
Diffstat (limited to 'fs/hfsplus/extents.c')
-rw-r--r-- | fs/hfsplus/extents.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/fs/hfsplus/extents.c b/fs/hfsplus/extents.c index b1991a2a08e0..b9c1a4b5ba89 100644 --- a/fs/hfsplus/extents.c +++ b/fs/hfsplus/extents.c | |||
@@ -209,6 +209,7 @@ int hfsplus_get_block(struct inode *inode, sector_t iblock, | |||
209 | struct hfsplus_inode_info *hip = HFSPLUS_I(inode); | 209 | struct hfsplus_inode_info *hip = HFSPLUS_I(inode); |
210 | int res = -EIO; | 210 | int res = -EIO; |
211 | u32 ablock, dblock, mask; | 211 | u32 ablock, dblock, mask; |
212 | sector_t sector; | ||
212 | int was_dirty = 0; | 213 | int was_dirty = 0; |
213 | int shift; | 214 | int shift; |
214 | 215 | ||
@@ -255,10 +256,12 @@ int hfsplus_get_block(struct inode *inode, sector_t iblock, | |||
255 | done: | 256 | done: |
256 | dprint(DBG_EXTENT, "get_block(%lu): %llu - %u\n", | 257 | dprint(DBG_EXTENT, "get_block(%lu): %llu - %u\n", |
257 | inode->i_ino, (long long)iblock, dblock); | 258 | inode->i_ino, (long long)iblock, dblock); |
259 | |||
258 | mask = (1 << sbi->fs_shift) - 1; | 260 | mask = (1 << sbi->fs_shift) - 1; |
259 | map_bh(bh_result, sb, | 261 | sector = ((sector_t)dblock << sbi->fs_shift) + |
260 | (dblock << sbi->fs_shift) + sbi->blockoffset + | 262 | sbi->blockoffset + (iblock & mask); |
261 | (iblock & mask)); | 263 | map_bh(bh_result, sb, sector); |
264 | |||
262 | if (create) { | 265 | if (create) { |
263 | set_buffer_new(bh_result); | 266 | set_buffer_new(bh_result); |
264 | hip->phys_size += sb->s_blocksize; | 267 | hip->phys_size += sb->s_blocksize; |