mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-05 00:20:32 +00:00
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>
This commit is contained in:
parent
2b4f9ca8a5
commit
bf1a1b31fa
1 changed files with 6 additions and 3 deletions
|
@ -209,6 +209,7 @@ int hfsplus_get_block(struct inode *inode, sector_t iblock,
|
||||||
struct hfsplus_inode_info *hip = HFSPLUS_I(inode);
|
struct hfsplus_inode_info *hip = HFSPLUS_I(inode);
|
||||||
int res = -EIO;
|
int res = -EIO;
|
||||||
u32 ablock, dblock, mask;
|
u32 ablock, dblock, mask;
|
||||||
|
sector_t sector;
|
||||||
int was_dirty = 0;
|
int was_dirty = 0;
|
||||||
int shift;
|
int shift;
|
||||||
|
|
||||||
|
@ -255,10 +256,12 @@ int hfsplus_get_block(struct inode *inode, sector_t iblock,
|
||||||
done:
|
done:
|
||||||
dprint(DBG_EXTENT, "get_block(%lu): %llu - %u\n",
|
dprint(DBG_EXTENT, "get_block(%lu): %llu - %u\n",
|
||||||
inode->i_ino, (long long)iblock, dblock);
|
inode->i_ino, (long long)iblock, dblock);
|
||||||
|
|
||||||
mask = (1 << sbi->fs_shift) - 1;
|
mask = (1 << sbi->fs_shift) - 1;
|
||||||
map_bh(bh_result, sb,
|
sector = ((sector_t)dblock << sbi->fs_shift) +
|
||||||
(dblock << sbi->fs_shift) + sbi->blockoffset +
|
sbi->blockoffset + (iblock & mask);
|
||||||
(iblock & mask));
|
map_bh(bh_result, sb, sector);
|
||||||
|
|
||||||
if (create) {
|
if (create) {
|
||||||
set_buffer_new(bh_result);
|
set_buffer_new(bh_result);
|
||||||
hip->phys_size += sb->s_blocksize;
|
hip->phys_size += sb->s_blocksize;
|
||||||
|
|
Loading…
Reference in a new issue