Skip to contentSkip to conversation

Avoid OOB access on illegal ZFS superblocks

PATCH Applied Tobias Stoeckmann 2 participants 2 messages Aug 28, 2016 – Aug 29, 2016 Util-Linux package

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Avoid OOB access on illegal ZFS superblocks

64 bit systems can trigger an out of boundary access while performing a ZFS superblock probe.

This happens due to a possible integer overflow while calculating the remaining available bytes. The variable is of type "int" and the string length is allowed to be larger than INT_MAX, which means that avail calculation can overflow, circumventing the "avail < 0" check and therefore accessing memory outside the "buff" array later on.

---
 libblkid/src/superblocks/zfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
libblkid/src/superblocks/zfs.c +1 -1
index b6ffac5..c41f769 100644
@@ -112,7 +112,7 @@ static void zfs_extract_guid_name(blkid_probe pr, loff_t offset)
 
 			nvs->nvs_type = be32_to_cpu(nvs->nvs_type);
 			nvs->nvs_strlen = be32_to_cpu(nvs->nvs_strlen);
-			if (nvs->nvs_strlen > UINT_MAX - sizeof(*nvs))
+			if (nvs->nvs_strlen > INT_MAX - sizeof(*nvs))
 				break;
 			avail -= nvs->nvs_strlen + sizeof(*nvs);
 			DBG(LOWPROBE, ul_debug("nvstring: type %u string %*s\n", nvs->nvs_type,
Signature · 1 line
2.9.3
maintainer Applied
#1 lore raw
Quoted 2 lines · Tobias Stoeckmann
 libblkid/src/superblocks/zfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Applied, thanks.

Signature · 2 lines
 Karel Zak  <[email protected]>
 http://karelzak.blogspot.com