diff options
author | Mikulas Patocka <mpatocka@redhat.com> | 2017-09-13 16:17:57 +0300 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2017-09-25 17:56:05 +0300 |
commit | 02a4843618fb35f847cf8c31cd3893873aa0edde (patch) | |
tree | 07a8caec8d3ab5e68f42026f9bea8cad31a968ce /drivers/block/brd.c | |
parent | 820bf5c419e4b85298e5c3001bd1b5be46d60765 (diff) | |
download | linux-02a4843618fb35f847cf8c31cd3893873aa0edde.tar.xz |
brd: fix overflow in __brd_direct_access
The code in __brd_direct_access multiplies the pgoff variable by page size
and divides it by 512. It can cause overflow on 32-bit architectures. The
overflow happens if we create ramdisk larger than 4G and use it as a
sparse device.
This patch replaces multiplication and division with multiplication by the
number of sectors per page.
Reviewed-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Fixes: 1647b9b959c7 ("brd: add dax_operations support")
Cc: stable@vger.kernel.org # 4.12+
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'drivers/block/brd.c')
-rw-r--r-- | drivers/block/brd.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/block/brd.c b/drivers/block/brd.c index bbd0d186cfc0..2d7178f7754e 100644 --- a/drivers/block/brd.c +++ b/drivers/block/brd.c @@ -342,7 +342,7 @@ static long __brd_direct_access(struct brd_device *brd, pgoff_t pgoff, if (!brd) return -ENODEV; - page = brd_insert_page(brd, PFN_PHYS(pgoff) / 512); + page = brd_insert_page(brd, (sector_t)pgoff << PAGE_SECTORS_SHIFT); if (!page) return -ENOSPC; *kaddr = page_address(page); |