Skip to content

Commit

Permalink
block/blklogwrites: Make sure the log sector size is not too small
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
megari authored and kevmw committed Jul 10, 2018
1 parent 7769eaa commit ba814c8
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion block/blklogwrites.c
Expand Up @@ -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,
Expand Down

0 comments on commit ba814c8

Please sign in to comment.