Blame SOURCES/0054-fdasd.c-Safeguard-against-geometry-misprobing.patch

fc4a62
From ef7c01a23e2cacecbf86c02e7657d8a9d6cc48dd Mon Sep 17 00:00:00 2001
fc4a62
From: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
fc4a62
Date: Fri, 5 Feb 2016 14:47:11 +0100
fc4a62
Subject: [PATCH 54/54] fdasd.c: Safeguard against geometry misprobing
fc4a62
fc4a62
Fixes an issue with parted print being run against a logical
fc4a62
volume realised by extents on a physical volume residing on
fc4a62
a DASD.
fc4a62
We must make sure that geometry, device blocksize and DASD
fc4a62
attributes are present before we start format verifications
fc4a62
If any of it is missing this is not a DASD.
fc4a62
fc4a62
Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
fc4a62
Signed-off-by: Brian C. Lane <bcl@redhat.com>
fc4a62
fc4a62
(cherry picked from commit 8c6de55e4375bd63ae0d0dc7dd7104a7c2290cac)
fc4a62
fc4a62
Related: rhbz#1676604
fc4a62
---
fc4a62
 libparted/labels/fdasd.c | 11 +++++++++--
fc4a62
 1 file changed, 9 insertions(+), 2 deletions(-)
fc4a62
fc4a62
diff --git a/libparted/labels/fdasd.c b/libparted/labels/fdasd.c
fc4a62
index 7e6a77a..968b332 100644
fc4a62
--- a/libparted/labels/fdasd.c
fc4a62
+++ b/libparted/labels/fdasd.c
fc4a62
@@ -1021,13 +1021,20 @@ fdasd_get_geometry (const PedDevice *dev, fdasd_anchor_t *anc, int f)
fc4a62
 			goto error;
fc4a62
 		}
fc4a62
 
fc4a62
-		if (ioctl(f, HDIO_GETGEO, &anc->geo) != 0)
fc4a62
+		if (ioctl(f, HDIO_GETGEO, &anc->geo) != 0 ||
fc4a62
+		        anc->geo.heads == 0 ||
fc4a62
+		        anc->geo.sectors == 0 ||
fc4a62
+		        anc->geo.cylinders == 0 ) {
fc4a62
 			fdasd_error(anc, unable_to_ioctl,
fc4a62
 			    _("Could not retrieve disk geometry information."));
fc4a62
+			goto error;
fc4a62
+		}
fc4a62
 
fc4a62
-		if (ioctl(f, BLKSSZGET, &blksize) != 0)
fc4a62
+		if (ioctl(f, BLKSSZGET, &blksize) != 0) {
fc4a62
 			fdasd_error(anc, unable_to_ioctl,
fc4a62
 			    _("Could not retrieve blocksize information."));
fc4a62
+			goto error;
fc4a62
+		}
fc4a62
 
fc4a62
 		/* get disk type */
fc4a62
 		if (ioctl(f, BIODASDINFO, &dasd_info) != 0) {
fc4a62
-- 
fc4a62
2.20.1
fc4a62