All of lore.kernel.org
 help / color / mirror / Atom feed
From: Guilhem Moulin <guilhem@fripost.org>
To: Dominic Raferd <dominic@timedicer.co.uk>
Cc: dm-crypt@saout.de
Subject: Re: [dm-crypt] LUKS + dm-crypt Debian/Ubuntu expanding encrypted root LV onto 2nd disk
Date: Wed, 29 May 2019 15:43:45 +0200	[thread overview]
Message-ID: <20190529134345.GA3251@fripost.org> (raw)
In-Reply-To: <CAF9Mo3KUNhvamN3111iJy+JoY9vWVz8c66TrohwR6S8YuOM31g@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2700 bytes --]

On Wed, 29 May 2019 at 12:26:12 +0100, Dominic Raferd wrote:
> Thanks but I am using the standard Debian recipe (via Ubuntu alternate
> installer which uses anaconda) for drive encryption (LUKS + dm-crypt, with
> LVM on top) and this does not give any chance (AFAIK) to specify a special
> parameter for cryptsetup.

That flag is to be passed to `open` (or `refresh`) at initramfs stage,
not `luksFormat` at d-i stage.  I suppose it doesn't change much though,
as --disable-keyring, and --token-* flags can't be specified to Debian's
crypttab(5) at the moment.

> The idea of reusing key from first crypt device when creating second crypt
> device is that once the first crypt device is decrypted in initramfs (by
> user entering password) then the second one can be decrypted using the key
> from the first.

You have a backup key slot on the device unlocked with decrypt_derived,
right?  Otherwise you'll loose both devices if the source is lost or
damaged.

As written in /usr/share/doc/cryptsetup-initramfs/README.initramfs.gz
decrypt_derived doesn't work with LUKS2 on Linux ≥4.10, because the
volume key of the source device is offloaded to the kernel keyring thus
not readable by userspace.  Since --disable-keyring can't be
persistently written into the LUKS header as of 2.1.0, nor can it be
toggled from crypttab(5), I guess that if you want to stick to
decrypt_derived your options are to use `luksFormat --type luks1` (or
`convert --type luks1`); or to write your own unlocking logic at
initramfs stage.

Alternatively, you could use decrypt_keyctl to temporarily cache the
passphrase into the kernel keyring.

    rootpv0_crypt $DEV_PV0 rootpv luks,keyscript=decrypt_keyctl
    rootpv1_crypt $DEV_PV1 rootpv luks,keyscript=decrypt_keyctl

(This also works for LUKS1 and non-LUKS devices, see our README.keyctl.)

For LUKS2 it's also possible to rely on cryptsetup's native
auto-activation support via token keyrings, see upstream's
‘docs/Keyring.txt’:

    cryptsetup token add --key-description cryptsetup:rootpv $DEV_PV1

In principle one could then use a “normal” crypttab entry and let
cryptsetup do the magic natively:

    rootpv1_crypt $DEV_PV1 none luks

But unfortunately this doesn't work well with the Debian initramfs
scripts right now (I believe the same goes for systemd), because the
password prompt is spawned first.  Entering an empty or dummy passphrase
works.  Using /dev/null as key file should work too, at the expense of
warnings regarding insecure permissions.  Once Buster is released I
guess we'll work on a better support for keyring tokens in the Debian
initramfs boot script.

-- 
Guilhem.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2019-05-29 13:43 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-22 11:41 [dm-crypt] LUKS + dm-crypt Debian/Ubuntu expanding encrypted root LV onto 2nd disk Dominic Raferd
2019-05-22 12:46 ` Arno Wagner
2019-05-22 12:53   ` Dominic Raferd
2019-05-22 13:15     ` Arno Wagner
2019-05-22 17:16     ` Guilhem Moulin
2019-05-29  9:56       ` Dominic Raferd
2019-05-29 11:06         ` Ondrej Kozina
2019-05-29 11:26           ` Dominic Raferd
2019-05-29 13:43             ` Guilhem Moulin [this message]
2019-06-07  8:56               ` Dominic Raferd
2019-06-07 10:52                 ` Guilhem Moulin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190529134345.GA3251@fripost.org \
    --to=guilhem@fripost.org \
    --cc=dm-crypt@saout.de \
    --cc=dominic@timedicer.co.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.