<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">From: Milan Broz &lt;mbroz@redhat.com&gt;

Check that the log bitmap will fit within the log device.

Signed-off-by: Milan Broz &lt;mbroz@redhat.com&gt;
Signed-off-by: Alasdair G Kergon &lt;agk@redhat.com&gt;
---
 drivers/md/dm-log.c |    8 ++++++++
 1 files changed, 8 insertions(+)

Index: linux-2.6.28/drivers/md/dm-log.c
===================================================================
--- linux-2.6.28.orig/drivers/md/dm-log.c	2009-01-05 18:18:20.000000000 +0000
+++ linux-2.6.28/drivers/md/dm-log.c	2009-01-05 18:18:22.000000000 +0000
@@ -457,6 +457,14 @@ static int create_log_context(struct dm_
 		 */
 		buf_size = dm_round_up((LOG_OFFSET &lt;&lt; SECTOR_SHIFT) +
 				       bitset_size, ti-&gt;limits.hardsect_size);
+
+		if (buf_size &gt; dev-&gt;bdev-&gt;bd_inode-&gt;i_size) {
+			DMWARN("log device %s too small: need %llu bytes",
+				dev-&gt;name, (unsigned long long)buf_size);
+			kfree(lc);
+			return -EINVAL;
+		}
+
 		lc-&gt;header_location.count = buf_size &gt;&gt; SECTOR_SHIFT;
 
 		lc-&gt;io_req.mem.type = DM_IO_VMA;
</pre></body></html>