diff options
author | Milan Broz <mbroz@redhat.com> | 2009-01-06 03:05:02 +0000 |
---|---|---|
committer | Alasdair G Kergon <agk@redhat.com> | 2009-01-06 03:05:02 +0000 |
commit | ac1f0ac22c7be908fd33407273b9808bfaedada4 (patch) | |
tree | f6a867138918b591639464802744506f6b83ad14 | |
parent | 2045e88edb4e0c9ce62d317f77dc59d27d9c530e (diff) | |
download | op-kernel-dev-ac1f0ac22c7be908fd33407273b9808bfaedada4.zip op-kernel-dev-ac1f0ac22c7be908fd33407273b9808bfaedada4.tar.gz |
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>
-rw-r--r-- | drivers/md/dm-log.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/drivers/md/dm-log.c b/drivers/md/dm-log.c index 40ed70d..737961f 100644 --- a/drivers/md/dm-log.c +++ b/drivers/md/dm-log.c @@ -457,6 +457,14 @@ static int create_log_context(struct dm_dirty_log *log, struct dm_target *ti, */ buf_size = dm_round_up((LOG_OFFSET << SECTOR_SHIFT) + bitset_size, ti->limits.hardsect_size); + + if (buf_size > dev->bdev->bd_inode->i_size) { + DMWARN("log device %s too small: need %llu bytes", + dev->name, (unsigned long long)buf_size); + kfree(lc); + return -EINVAL; + } + lc->header_location.count = buf_size >> SECTOR_SHIFT; lc->io_req.mem.type = DM_IO_VMA; |