[Bug 1713175] Re: fsck should check before running on an encrypted LUKS partition

2017-08-26 Thread asi
One day cryptsetup will link to liblkid, adding two "use friendly" things in 
luksFormat
- warn if it detects something on disk before destroying it
- run wipefs to really destroy all the magic strings there (as Teo suggested)

So valid feature request also on the cryptsetup side, with the same low-
priority though :-)

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1713175

Title:
  fsck should check before running on an encrypted LUKS partition

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/cryptsetup/+bug/1713175/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs


[Bug 1713175] Re: fsck should check before running on an encrypted LUKS partition

2017-08-26 Thread Theodore Ts'o
So what happened is the following.   There was a previous ext4 file
system on the disk.  You ran "cryptsetup luksFormat /dev/sda1" which
wiped out the primary superblock.

You then manually ran fsck.ext4 on the device.  It noticed the primary
superblock was non-existent, and then asked permission to modify the
file system.   So it would have required multiple sysadmin errors in
order get to this point.

If you want a process which is fool-proof against sysadmin errors, you
could run the following before you run cryptosetup:

dd if=/dev/zero of=/dev/callcc/scratch seek=32766 count=10 bs=4k

If you do this, then e2fsck won't find the backup superblock, and it
will print:

e2fsck 1.43.5 (04-Aug-2017)
ext2fs_open2: Bad magic number in super-block
e2fsck: Superblock invalid, trying backup blocks...
e2fsck: Bad magic number in super-block while trying to open /dev/callcc/scratch

The superblock could not be read or does not describe a valid ext2/ext3/ext4
filesystem.  If the device is valid and it really contains an ext2/ext3/ext4
filesystem (and not swap or ufs or something else), then the superblock
is corrupt, and you might try running e2fsck with an alternate superblock:
e2fsck -b 8193 
 or
e2fsck -b 32768 

/dev/callcc/scratch contains a crypto_LUKS file system


So we could try to do the "is there another file system or LUKS" check before 
falling back to the secondary superblock.  I'd call this a feature request.

It also should be the case that the wipefs program should have wiped
enough to get rid of the backup superblock (it's considered best
practice to run wipefs before running cryptsetup).

Furthermore, crypsetup should have run wipefs, or done its own wiping.
Mke2fs will wipe sectors at the beginning and the end of the superblock
(otherwise it's possible for the device to get misidentified as part of
a RAID array).

Fundamentally, trying to use in-band signalling is fraught with peril.
All tools need to do a better job of preventing this kind of mis-
identification, especially at file system or LUKS creation/format time.



** Also affects: util-linux (Ubuntu)
   Importance: Undecided
   Status: New

** Also affects: cryptsetup (Ubuntu)
   Importance: Undecided
   Status: New

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1713175

Title:
  fsck should check before running on an encrypted LUKS partition

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/cryptsetup/+bug/1713175/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs


[Bug 1713175] Re: fsck should check before running on an encrypted LUKS partition

2017-08-26 Thread Theodore Ts'o
Note: I think this should be a low-priority/wishlist/feature request.
But I can't edit the importance.It is a valid feature request
though, so I plan to treat it at that priority.

If someone else thinks it's higher priority, patches are welcome.   :-)


** Changed in: cryptsetup (Ubuntu)
   Status: New => Confirmed

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1713175

Title:
  fsck should check before running on an encrypted LUKS partition

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/cryptsetup/+bug/1713175/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs