Blame SOURCES/0071-libblkid-check-UBI-char-device-name.patch

25f9c8
From 7ce318610afcbb793e438332687c2f09844a86c2 Mon Sep 17 00:00:00 2001
25f9c8
From: Karel Zak <kzak@redhat.com>
25f9c8
Date: Thu, 25 Nov 2021 11:54:11 +0100
25f9c8
Subject: [PATCH 71/74] libblkid: check UBI char device name
25f9c8
25f9c8
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2026511
25f9c8
Upstream: http://github.com/util-linux/util-linux/commit/7eb6d9ce4526b968e30f7e538cbbbdf9938e5891
25f9c8
Signed-off-by: Karel Zak <kzak@redhat.com>
25f9c8
---
25f9c8
 libblkid/src/probe.c | 12 ++++++++++--
25f9c8
 1 file changed, 10 insertions(+), 2 deletions(-)
25f9c8
25f9c8
diff --git a/libblkid/src/probe.c b/libblkid/src/probe.c
25f9c8
index a6dc8416a..49a62c47f 100644
25f9c8
--- a/libblkid/src/probe.c
25f9c8
+++ b/libblkid/src/probe.c
25f9c8
@@ -915,9 +915,17 @@ int blkid_probe_set_device(blkid_probe pr, int fd,
25f9c8
 			DBG(LOWPROBE, ul_debug("failed to get device size"));
25f9c8
 			goto err;
25f9c8
 		}
25f9c8
-	} else if (S_ISCHR(sb.st_mode))
25f9c8
+	} else if (S_ISCHR(sb.st_mode)) {
25f9c8
+		char buf[PATH_MAX];
25f9c8
+
25f9c8
+		if (!sysfs_chrdev_devno_to_devname(sb.st_rdev, buf, sizeof(buf))
25f9c8
+		    || strncmp(buf, "ubi", 3) != 0) {
25f9c8
+			DBG(LOWPROBE, ul_debug("no UBI char device"));
25f9c8
+			errno = EINVAL;
25f9c8
+			goto err;
25f9c8
+		}
25f9c8
 		devsiz = 1;		/* UBI devices are char... */
25f9c8
-	else if (S_ISREG(sb.st_mode))
25f9c8
+	} else if (S_ISREG(sb.st_mode))
25f9c8
 		devsiz = sb.st_size;	/* regular file */
25f9c8
 
25f9c8
 	pr->size = size ? (uint64_t)size : devsiz;
25f9c8
-- 
25f9c8
2.31.1
25f9c8