Blame SOURCES/0110-libblkid-zfs-keep-bufferes-read-only.patch

64664a
From eeb629102da9a9a916d201bbd5f13ee7ad23844d Mon Sep 17 00:00:00 2001
64664a
From: Karel Zak <kzak@redhat.com>
64664a
Date: Tue, 22 Sep 2015 15:27:39 +0200
64664a
Subject: [PATCH 110/116] libblkid: (zfs) keep bufferes read-only
64664a
64664a
Upstream: https://github.com/karelzak/util-linux/commit/9325a8be9e55cc01d9f580e14dd2193829245183
64664a
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1392661
64664a
Signed-off-by: Karel Zak <kzak@redhat.com>
64664a
---
64664a
 libblkid/src/superblocks/zfs.c | 11 ++++++++---
64664a
 1 file changed, 8 insertions(+), 3 deletions(-)
64664a
64664a
diff --git a/libblkid/src/superblocks/zfs.c b/libblkid/src/superblocks/zfs.c
64664a
index 9b5601e..8e88b39 100644
64664a
--- a/libblkid/src/superblocks/zfs.c
64664a
+++ b/libblkid/src/superblocks/zfs.c
64664a
@@ -70,9 +70,10 @@ struct nvlist {
64664a
 
64664a
 static void zfs_extract_guid_name(blkid_probe pr, loff_t offset)
64664a
 {
64664a
+	unsigned char *p, buff[4096];
64664a
 	struct nvlist *nvl;
64664a
 	struct nvpair *nvp;
64664a
-	size_t left = 4096;
64664a
+	size_t left = sizeof(buff);
64664a
 	int found = 0;
64664a
 
64664a
 	offset = (offset & ~(VDEV_LABEL_SIZE - 1)) + VDEV_LABEL_NVPAIR;
64664a
@@ -81,10 +82,14 @@ static void zfs_extract_guid_name(blkid_probe pr, loff_t offset)
64664a
 	 * the first 4k (left) of the nvlist.  This is true for all pools
64664a
 	 * I've seen, and simplifies this code somewhat, because we don't
64664a
 	 * have to handle an nvpair crossing a buffer boundary. */
64664a
-	nvl = (struct nvlist *)blkid_probe_get_buffer(pr, offset, left);
64664a
-	if (nvl == NULL)
64664a
+	p = blkid_probe_get_buffer(pr, offset, left);
64664a
+	if (!p)
64664a
 		return;
64664a
 
64664a
+	/* libblkid buffers are strictly readonly, but the code below modifies nvpair etc. */
64664a
+	memcpy(buff, p, sizeof(buff));
64664a
+	nvl = (struct nvlist *) buff;
64664a
+
64664a
 	nvdebug("zfs_extract: nvlist offset %llu\n", offset);
64664a
 
64664a
 	nvp = &nvl->nvl_nvpair;
64664a
-- 
64664a
2.9.3
64664a