]> git.ipfire.org Git - thirdparty/util-linux.git/commit
libblkid: check for private DM device before open
authorZdenek Kabelac <zkabelac@redhat.com>
Sat, 14 Mar 2026 13:39:41 +0000 (14:39 +0100)
committerZdenek Kabelac <zkabelac@redhat.com>
Sat, 14 Mar 2026 13:39:41 +0000 (14:39 +0100)
commitd05a84b22e549527cbcbcc7d5efc6bad06668170
treecc45b3d9eb286351fbe1966253724fca0480ea55
parent9a9ce4074b2e3a9afe73f06e49ae12e593bf397d
libblkid: check for private DM device before open

blkid_new_probe_from_filename() opens the device before calling
blkid_probe_set_device(), which checks sysfs_devno_is_dm_private()
and sets BLKID_FL_NOSCAN_DEV.  But the open() itself bumps the
kernel open count, so a concurrent DM_DEVICE_REMOVE ioctl sees
EBUSY even though blkid never actually probes the device.

Move the private-device check before open() in
blkid_new_probe_from_filename().  The sysfs UUID is readable
without opening the block device, so this closes the race window
between udev-worker's blkid builtin and device-mapper remove.

Note: blkid_verify() in verify.c already does the check before
open() -- this patch makes the probe path consistent.

Signed-off-by: Zdenek Kabelac <zkabelac@redhat.com>
libblkid/src/probe.c