From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33711) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fbPhm-00028n-EI for qemu-devel@nongnu.org; Fri, 06 Jul 2018 08:19:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fbPhl-0007Hc-O2 for qemu-devel@nongnu.org; Fri, 06 Jul 2018 08:19:18 -0400 From: Ari Sundholm Date: Fri, 6 Jul 2018 15:00:38 +0300 Message-ID: <1530878438-16980-1-git-send-email-ari@tuxera.com> MIME-Version: 1.0 Content-Type: text/plain Subject: [Qemu-devel] [PATCH] block/blklogwrites: Make sure the log sector size is not too small List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Ari Sundholm , Kevin Wolf , Max Reitz , "open list:blklogwrites" 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 --- block/blklogwrites.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/block/blklogwrites.c b/block/blklogwrites.c index 63bf6b3..efa2c7a 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, -- 2.7.4