Commit 4ba2d5fdcfd19de0dedf394ddc48db2f219fa89a

Authored by Christoph Hellwig
Committed by Christoph Hellwig
1 parent bf1a1b31fa

hfsplus: fix overflow in hfsplus_read_wrapper

For partitions larger than 2TB or at such an offset the hfs wrapper code
in hfsplus might overflow the range representable in a 32-bit
data type. Make sure we use a sector_t for the arithmetics leading to it.

I'm not sure this code can be readed at all as hfs itself never supported
such large volumes.

Signed-off-by: Christoph Hellwig <hch@tuxera.com>

Showing 1 changed file with 3 additions and 2 deletions Side-by-side Diff

fs/hfsplus/wrapper.c
... ... @@ -172,8 +172,9 @@
172 172 if (!hfsplus_read_mdb(sbi->s_vhdr, &wd))
173 173 goto out_free_backup_vhdr;
174 174 wd.ablk_size >>= HFSPLUS_SECTOR_SHIFT;
175   - part_start += wd.ablk_start + wd.embed_start * wd.ablk_size;
176   - part_size = wd.embed_count * wd.ablk_size;
  175 + part_start += (sector_t)wd.ablk_start +
  176 + (sector_t)wd.embed_start * wd.ablk_size;
  177 + part_size = (sector_t)wd.embed_count * wd.ablk_size;
177 178 goto reread;
178 179 default:
179 180 /*