[dm-devel] [PATCH 08/31] kpartx: only recognize dasd part table on DASD

Martin Wilck mwilck at suse.com
Sat Sep 2 22:38:37 UTC 2017


The code for reading DASD partition tables is so generic
that it will pretend to find a partition even on a totally
zeroed disk. Prevent that by recognizing dasd partition tables
only on DASD disks. Such a check was already present for DM
mappings on DASD, but (strangely) not for DASD itself.

Without this, kpartx will (try to) create a partition mapping
on a loop device with no partition table.

Found this during testing because test-kpartx unexpectedly
succeeded without my "fix part deletion without partition table" fix
when run on a loop device. That was caused by this bug pretending an
existing partition table although there was none.

Signed-off-by: Martin Wilck <mwilck at suse.com>
---
 kpartx/dasd.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/kpartx/dasd.c b/kpartx/dasd.c
index f50c1bdb..e418d5ac 100644
--- a/kpartx/dasd.c
+++ b/kpartx/dasd.c
@@ -133,6 +133,9 @@ read_dasd_pt(int fd, struct slice all, struct slice *sp, int ns)
 			/* Couldn't open the device */
 			return -1;
 		}
+	} else if ((unsigned int)major(sbuf.st_rdev) != 94) {
+			/* Not a DASD */
+			return -1;
 	} else {
 		fd_dasd = fd;
 	}
-- 
2.14.0




More information about the dm-devel mailing list