Commit ac1f0ac22c7be908fd33407273b9808bfaedada4
Committed by
Alasdair G Kergon
1 parent
2045e88edb
Exists in
master
and in
4 other branches
dm log: ensure log bitmap fits on log device
Check that the log bitmap will fit within the log device. Signed-off-by: Milan Broz <mbroz@redhat.com> Signed-off-by: Alasdair G Kergon <agk@redhat.com>
Showing 1 changed file with 8 additions and 0 deletions Side-by-side Diff
drivers/md/dm-log.c
... | ... | @@ -457,6 +457,14 @@ |
457 | 457 | */ |
458 | 458 | buf_size = dm_round_up((LOG_OFFSET << SECTOR_SHIFT) + |
459 | 459 | bitset_size, ti->limits.hardsect_size); |
460 | + | |
461 | + if (buf_size > dev->bdev->bd_inode->i_size) { | |
462 | + DMWARN("log device %s too small: need %llu bytes", | |
463 | + dev->name, (unsigned long long)buf_size); | |
464 | + kfree(lc); | |
465 | + return -EINVAL; | |
466 | + } | |
467 | + | |
460 | 468 | lc->header_location.count = buf_size >> SECTOR_SHIFT; |
461 | 469 | |
462 | 470 | lc->io_req.mem.type = DM_IO_VMA; |