]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libblkid/minix: Sanity check superblock s_state for v 1 and 2
authorNate Clark <nate@neworld.us>
Wed, 4 Jan 2017 20:21:17 +0000 (15:21 -0500)
committerNate Clark <nate@neworld.us>
Wed, 4 Jan 2017 20:24:40 +0000 (15:24 -0500)
Swap devices with specific values in the uuid can look like minix
devices to blkid. Add an extra check to make sure the state of the
filesystem has valid state flags.

A couple of offending swap uuids include:
35f1f264-137f-471a-bc85-acc9f4bc04a3
35f1f264-7f13-471a-bc85-acc9f4bc04a3
35f1f264-138f-471a-bc85-acc9f4bc04a3
35f1f264-8f13-471a-bc85-acc9f4bc04a3

Without this change a swap device with any of those uuids would be
detected as minix and swap by blkid.

Signed-off-by: Nate Clark <nate@neworld.us>
libblkid/src/superblocks/minix.c

index 3e126e0ea38e5cf8568ba88d1db1d140475cd53f..feebc96adca8efb396ac713067d1e8b932534ffe 100644 (file)
@@ -94,6 +94,10 @@ static int probe_minix(blkid_probe pr,
        if (version <= 2) {
                struct minix_super_block *sb = (struct minix_super_block *) data;
 
+               uint16_t state = minix_swab16(swabme, sb->s_state);
+               if ((state & (MINIX_VALID_FS | MINIX_ERROR_FS)) != state)
+                       return 1;
+
                zones = version == 2 ? minix_swab32(swabme, sb->s_zones) :
                                       minix_swab16(swabme, sb->s_nzones);
                ninodes = minix_swab16(swabme, sb->s_ninodes);