]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libblkid: Avoid OOB access on illegal ZFS superblocks
authorTobias Stoeckmann <tobias@stoeckmann.org>
Sun, 28 Aug 2016 19:15:59 +0000 (21:15 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 29 Aug 2016 11:22:24 +0000 (13:22 +0200)
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.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
libblkid/src/superblocks/zfs.c

index b6ffac537b2bcb89cae6f65eb8a431f4227b08f8..c41f769905b6e9e84a6239d3c0033d4e2ae4b56b 100644 (file)
@@ -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,