Skip to content

LUKS device with parentheses in label causes udisks2 to misreport mounted state and create duplicate mountpoints #1415

@eduardosm

Description

@eduardosm

Steps to reproduce:

  1. Format a USB flash drive with a LUKS-encrypted BTRFS partition.
  2. Set the label of both the partition and the LUKS header to "Test (1)".
  3. Eject and reattach the flash drive.
  4. Unlock the encrypted device
  5. Attempt to mount it (multiple times)

Most steps can be done with gnome-disk-utility, except setting the label in the LUKS header, which can be done with cryptsetup config --label=<label> <device>.

After attempting to mount it, udisks2 will report the partition as unmounted. However, mount will show one mount point for each attempt:

/dev/mapper/Test_\x281\x29 on /run/media/<user>/Test (1) type btrfs
/dev/mapper/Test_\x281\x29 on /run/media/<user>/Test (1)1 type btrfs
/dev/mapper/Test_\x281\x29 on /run/media/<user>/Test (1)2 type btrfs
...

Attempting to eject the device or lock the encrypted partition will fail with "Device or resource busy" unless I manually unmount each mount point.

Example with udisksctl once the partition has been prepared:

$ udisksctl unlock -b /dev/sda1 
Passphrase: 
Unlocked /dev/sda1 as /dev/dm-1.
$ udisksctl mount -b /dev/dm-1 
Mounted /dev/dm-1 at /run/media/<user>/Test (1)
$ udisksctl info -b /dev/dm-1 
...
  org.freedesktop.UDisks2.Filesystem:
    MountPoints:  (empty)
$ udisksctl unmount -b /dev/dm-1
Error unmounting /dev/dm-1: GDBus.Error:org.freedesktop.UDisks2.Error.NotMounted: Device `/dev/dm-1' is not mounted
$ udisksctl mount -b /dev/dm-1  
Mounted /dev/dm-1 at /run/media/<user>/Test (1)1
$ udisksctl mount -b /dev/dm-1
Mounted /dev/dm-1 at /run/media/<user>/Test (1)2
$ udisksctl unmount -b /dev/dm-1
Error unmounting /dev/dm-1: GDBus.Error:org.freedesktop.UDisks2.Error.NotMounted: Device `/dev/dm-1' is not mounted
$ udisksctl lock -b /dev/sda1 
Error locking /dev/sda1: GDBus.Error:org.freedesktop.UDisks2.Error.Failed: Error locking /dev/dm-1 (/dev/sda1): Failed to deactivate device: Device or resource busy

Logs show:

Unlocked device /dev/sda1 as /dev/dm-1
Error statting /dev/mapper/Test_\134x281\134x29: No such file or directory
Cleaning up mount point /run/media/<user>/Test (1) (device 252:1 is not mounted)
Error cleaning up mount point /run/media/<user>/Test (1): Error removing directory: Device or resource busy
Cleaning up mount point /run/media/<user>/Test (1) (device 252:1 is not mounted)
Error cleaning up mount point /run/media/<user>/Test (1): Error removing directory: Device or resource busy
Cleaning up mount point /run/media/<user>/Test (1) (device 252:1 is not mounted)
Error cleaning up mount point /run/media/<user>/Test (1): Error removing directory: Device or resource busy
Error statting /dev/mapper/Test_\134x281\134x29: No such file or directory
Error statting /dev/mapper/Test_\134x281\134x29: No such file or directory
Cleaning up mount point /run/media/<user>/Test (1) (device 252:1 is not mounted)
Error cleaning up mount point /run/media/<user>/Test (1): Error removing directory: Device or resource busy
Cleaning up mount point /run/media/<user>/Test (1)1 (device 252:1 is not mounted)
Error cleaning up mount point /run/media/<user>/Test (1)1: Error removing directory: Device or resource busy
Cleaning up mount point /run/media/<user>/Test (1) (device 252:1 is not mounted)
Error cleaning up mount point /run/media/<user>/Test (1): Error removing directory: Device or resource busy
Cleaning up mount point /run/media/<user>/Test (1)1 (device 252:1 is not mounted)
Error cleaning up mount point /run/media/<user>/Test (1)1: Error removing directory: Device or resource busy
Cleaning up mount point /run/media/<user>/Test (1) (device 252:1 is not mounted)
Error cleaning up mount point /run/media/<user>/Test (1): Error removing directory: Device or resource busy
Cleaning up mount point /run/media/<user>/Test (1)1 (device 252:1 is not mounted)
...

Things get worse if mounting is attempted through KDE Dolphin, which will cause it to indefinitely create mount points.

I am using udisks2 2.10.91 in Fedora 42 (udisks2-2.10.91-1.fc42.x86_64).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions