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

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