diff options
author | Ari Sundholm <ari@tuxera.com> | 2018-07-06 15:00:38 +0300 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2018-07-10 13:17:48 +0200 |
commit | ba814c82bbf0daf053c52dcdf0eb97b1f6ab0970 (patch) | |
tree | 3f80cf07acb7a82ed87340b1a71075a4194b96ce /block | |
parent | 7769eaa57859362a655b3d3a78d20df7774f16cf (diff) |
block/blklogwrites: Make sure the log sector size is not too small
The sector size needs to be large enough to accommodate the data
structures for the log super block and log write entries. This was
previously not properly checked, which made it possible to cause
QEMU to badly misbehave.
Signed-off-by: Ari Sundholm <ari@tuxera.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block')
-rw-r--r-- | block/blklogwrites.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/block/blklogwrites.c b/block/blklogwrites.c index 63bf6b34a9..efa2c7a66a 100644 --- a/block/blklogwrites.c +++ b/block/blklogwrites.c @@ -89,7 +89,10 @@ static inline uint32_t blk_log_writes_log2(uint32_t value) static inline bool blk_log_writes_sector_size_valid(uint32_t sector_size) { - return sector_size < (1ull << 24) && is_power_of_2(sector_size); + return is_power_of_2(sector_size) && + sector_size >= sizeof(struct log_write_super) && + sector_size >= sizeof(struct log_write_entry) && + sector_size < (1ull << 24); } static uint64_t blk_log_writes_find_cur_log_sector(BdrvChild *log, |