]> git.ipfire.org Git - thirdparty/grub.git/commit
cryptodisk: Add support for using detached header files
authorGlenn Washburn <development@efficientek.com>
Wed, 8 Jun 2022 15:34:03 +0000 (10:34 -0500)
committerDaniel Kiper <daniel.kiper@oracle.com>
Mon, 4 Jul 2022 12:43:25 +0000 (14:43 +0200)
commit1deb521452b288fe8256dcc7bc14228aa42b568e
treef2b9d65b3db0d1d6995fb2106652840f547bba6e
parentf5a92e6040266015bfccaafd1f89bf14d92ef013
cryptodisk: Add support for using detached header files

Using the disk read hook mechanism, setup a read hook on the source disk
which will read from the given header file during the scan and recovery
cryptodisk backend functions. Disk read hooks are executed after the data
has been read from the disk. This is okay, because the read hook is given
the read buffer before its sent back to the caller. In this case, the hook
can then overwrite the data read from the disk device with data from the
header file sent in as the read hook data. This is transparent to the
read caller. Since the callers of this function have just opened the
source disk, there are no current read hooks, so there's no need to
save/restore them nor consider if they should be called or not.

This hook assumes that the header is at the start of the volume, which
is not the case for some formats (e.g. GELI). So GELI will return an
error if a detached header is specified. It also can only be used
with formats where the detached header file can be written to the
first blocks of the volume and the volume could still be unlocked.
So the header file can not be formatted differently from the on-disk
header. If these assumpts are not met, detached header file processing
must be specially handled in the cryptodisk backend module.

The hook will be called potentially many times by a backend. This is fine
because of the assumptions mentioned and the read hook reads from absolute
offsets and is stateless.

Also add a --header (short -H) option to cryptomount which takes a file
argument.

Signed-off-by: Glenn Washburn <development@efficientek.com>
Reviewed-by: Patrick Steinhardt <ps@pks.im>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
grub-core/disk/cryptodisk.c
grub-core/disk/geli.c
include/grub/cryptodisk.h
include/grub/file.h