/dev/mapper/* -> /dev/dm-* symlink scheme breaks partman-crypto

Bug #126379 reported by Colin Watson
8
Affects Status Importance Assigned to Milestone
devmapper (Ubuntu)
Fix Released
Medium
Scott James Remnant (Canonical)

Bug Description

The temporary /dev/mapper/* -> /dev/dm-* symlinks confuse various bits of partman. I think some of these problems are just latent bugs (e.g. bug 126328) and I'll fix them. However, there's a problem in partman-crypto that's more difficult to fix.

Consider the case where you have an encrypted swap partition: let's say /dev/mapper/ubuntu-swap_1 -> /dev/dm-1 (example actually from an LVM installation attempt, but never mind that). If you do 'swapon /dev/mapper/ubuntu-swap_1', the kernel follows the symlink before exposing the name in /proc/swaps, so you get /dev/dm-1 from there. partman-crypto reads /proc/swaps and tries to detect unencrypted swap space. One bug is that it doesn't know to check for /dev/dm-*, and that could be changed easily enough; but worse, it then goes on to try 'dmsetup info -c' to see if the major/minor device numbers indicate an encrypted device, and that says:

  # dmsetup info -c /dev/dm-1
  dm_task_set_name: Device /dev/dm-1 not found
  Command failed

If this is only a temporary change, I don't propose to write messy code in partman-crypto to try to track down the corresponding /dev/mapper/* device. Instead, I think the right answer is to just milestone this bug for tribe-4 to indicate that this bug needs to be fixed before feature freeze, so I'm doing that.

Related branches

Revision history for this message
Colin Watson (cjwatson) wrote :

FWIW I've worked around this for d-i by turning these symlinks off in the libdevmapper udeb, but I'm leaving the bug open since things in the normal system might be affected too.

Revision history for this message
c.h. (wryfi) wrote :

This is considerably more serious for me than just encrypted swap/tmpfs.

It seriously compromises the security of my pam-mounted, luks-encrypted, lvm home partitions.

When a user logs in, everything mounts correctly. The encrypted volume is decrypted in /dev/mapper, and is also symlinked to, e.g., /dev/dm-7. /dev/dm-7 mounts as, e.g., /home/chris.

At logout, pam_mount calls umount.crypt to unmount the home partition and close the encrypted luks volume. The home partition umounts successfully, but umount.crypt fails to close the luks volume with the error:

Command failed: dm_task_set_name: Device /dev/dm-7 not found

Yet /dev/dm-7 certainly exists. My data is left unencrypted in /dev/mapper/_dev_mapper_chris symlinked to /dev/dm-7.

This is obviously bad from a security standpoint if multiple users share a machine. Furthermore, if I log out, and then attempt to log in again, pam_mount is unable to initialize the luks volume, because it was never closed during the log out. So I have go back to a console, log in as another user, and manually close the luks volume from the previous session before I can log in again. Argh!

Colin, can you explain your workaround a little more thoroughly? How do you turn the symlinks off in the libdevmapper udeb? That sounds a bit, uh, complicated. Any other workarounds, or ETA for a fix in the gutsy repos?

Revision history for this message
Henrik Nilsen Omma (henrik) wrote :

Moving milestone.

Changed in devmapper:
importance: Undecided → Medium
status: New → Confirmed
Changed in devmapper:
assignee: nobody → ubuntu-kernel-team
Revision history for this message
Chris Poupart (chris-poupart) wrote :

My problem is very similar to chris' above.

I rely on luks encrypted hard drives for regular backups to hard drives. The script mounts and unmounts the encrypted drive on demand.

I was going to move the service from a Debian Etch machine to a machine running Ubuntu, but this is a real show stopper for me since unmounting properly seems to be impossible.

Colin, can you go into more detail about your work around? I have never messed with udebs before, and I am not sure where to start.

Revision history for this message
Colin Watson (cjwatson) wrote :

My workaround is not relevant. The developer responsible knows exactly what to do here and just needs to do it. :-)

Revision history for this message
Chris Poupart (chris-poupart) wrote : Re: [Bug 126379] Re: /dev/mapper/* -> /dev/dm-* symlink scheme breaks partman-crypto

Well, "not relevant" so long as it gets done soon, but this bug has
been open for a month, and I need a solution sooner rather than later.

Truthfully, I am in the middle of setting up a Debian box right now
because I don't see am imminent solution for this.

Thanks anyway!

-- Chris

On 9/7/07, Colin Watson <email address hidden> wrote:
> My workaround is not relevant. The developer responsible knows exactly
> what to do here and just needs to do it. :-)
>
> --
> /dev/mapper/* -> /dev/dm-* symlink scheme breaks partman-crypto
> https://bugs.launchpad.net/bugs/126379
> You received this bug notification because you are a direct subscriber
> of the bug.
>

Revision history for this message
Colin Watson (cjwatson) wrote :

Chris: to apply the same workaround to your system, edit /etc/udev/rules.d/65-dmsetup.rules and follow the directions in the comment beginning "this is temporary".

Revision history for this message
Chris Poupart (chris-poupart) wrote :

Hi Colin: Thanks. I suspect that these are rules from Gusty?

It would seem that this bug is also in Feisty, and the dmsetup.rules under feisty don't have any obvious section to change. I will have a poke around Gusty and see if I can't puzzle it out. Thanks again.

Revision history for this message
Colin Watson (cjwatson) wrote :

The problem you're encountering in Feisty is not this bug; it's a difficult systemic problem in the process of being fixed in Gutsy (I believe). It's probably rather hard to backport the fixes.

Revision history for this message
Scott James Remnant (Canonical) (canonical-scott) wrote :

I'll fix this with a udev upload next week

Changed in devmapper:
assignee: ubuntu-kernel-team → keybuk
Revision history for this message
Henrik Nilsen Omma (henrik) wrote :

Moving milestone to beta.

Revision history for this message
Scott James Remnant (Canonical) (canonical-scott) wrote :

devmapper (2:1.02.20-1ubuntu4) gutsy; urgency=low

  * Make the device take the /dev/mapper name in all cases.
    LP: #126379, #144049.
  * Drop udeb patch since it's not needed.

 -- Scott James Remnant <email address hidden> Mon, 24 Sep 2007 13:37:29 +0100

Changed in devmapper:
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.