Blame SOURCES/0114-libblkid-Avoid-OOB-access-on-illegal-ZFS-superblocks.patch

531551
From 7e1c9da4773237e368bdc0539ef91d55ef19806c Mon Sep 17 00:00:00 2001
531551
From: Tobias Stoeckmann <tobias@stoeckmann.org>
531551
Date: Sun, 28 Aug 2016 21:15:59 +0200
531551
Subject: [PATCH 114/116] libblkid: Avoid OOB access on illegal ZFS superblocks
531551
531551
64 bit systems can trigger an out of boundary access while performing
531551
a ZFS superblock probe.
531551
531551
This happens due to a possible integer overflow while calculating
531551
the remaining available bytes. The variable is of type "int" and the
531551
string length is allowed to be larger than INT_MAX, which means that
531551
avail calculation can overflow, circumventing the "avail < 0" check and
531551
therefore accessing memory outside the "buff" array later on.
531551
531551
[kzak@redhat.com (rhel7): - remove unused swab_magic]
531551
531551
Upstream: https://github.com/karelzak/util-linux/commit/8fa57ab0b5696031da800e243def32bc5265ff6d
531551
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1392661
531551
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
531551
Signed-off-by: Karel Zak <kzak@redhat.com>
531551
---
531551
 libblkid/src/superblocks/zfs.c | 3 +--
531551
 1 file changed, 1 insertion(+), 2 deletions(-)
531551
531551
diff --git a/libblkid/src/superblocks/zfs.c b/libblkid/src/superblocks/zfs.c
531551
index ff12fa6..2c7b4b7 100644
531551
--- a/libblkid/src/superblocks/zfs.c
531551
+++ b/libblkid/src/superblocks/zfs.c
531551
@@ -115,7 +115,7 @@ static void zfs_extract_guid_name(blkid_probe pr, loff_t offset)
531551
 
531551
 			nvs->nvs_type = be32_to_cpu(nvs->nvs_type);
531551
 			nvs->nvs_strlen = be32_to_cpu(nvs->nvs_strlen);
531551
-			if (nvs->nvs_strlen > UINT_MAX - sizeof(*nvs))
531551
+			if (nvs->nvs_strlen > INT_MAX - sizeof(*nvs))
531551
 				break;
531551
 			avail -= nvs->nvs_strlen + sizeof(*nvs);
531551
 			nvdebug("nvstring: type %u string %*s\n", nvs->nvs_type,
531551
@@ -201,7 +201,6 @@ static int find_uberblocks(const void *label, loff_t *ub_offset, int *swap_endia
531551
  * #4 (@ 132kB) is the first one written on a new filesystem. */
531551
 static int probe_zfs(blkid_probe pr, const struct blkid_idmag *mag)
531551
 {
531551
-	uint64_t swab_magic = swab64(UBERBLOCK_MAGIC);
531551
 	int swab_endian = 0;
531551
 	struct zfs_uberblock *ub;
531551
 	loff_t offset, ub_offset = 0;
531551
-- 
531551
2.9.3
531551