Allow GRUB to mount ext2/3/4 filesystems that have the encryption feature.
authorEric Biggers <ebiggers@google.com>
Thu, 29 Jun 2017 13:27:49 +0000 (13:27 +0000)
committerVladimir Serbinenko <phcoder@gmail.com>
Thu, 29 Jun 2017 13:29:53 +0000 (13:29 +0000)
commit734668238fcc0ef691a080839e04f33854fa133a
treeb1a640d8310f9deaeddb215f6cc8d18dfbb90a4f
parentf8679cedff703b437171f4708d46adbfcff80a65
Allow GRUB to mount ext2/3/4 filesystems that have the encryption feature.

On such a filesystem, inodes may have EXT4_ENCRYPT_FLAG set.
For a regular file, this means its contents are encrypted; for a
directory, this means the filenames in its directory entries are
encrypted; and for a symlink, this means its target is encrypted.  Since
GRUB cannot decrypt encrypted contents or filenames, just issue an error
if it would need to do so.  This is sufficient to allow unencrypted boot
files to co-exist with encrypted files elsewhere on the filesystem.

(Note that encrypted regular files and symlinks will not normally be
encountered outside an encrypted directory; however, it's possible via
hard links, so they still need to be handled.)

Tested by booting from an ext4 /boot partition on which I had run
'tune2fs -O encrypt'.  I also verified that the expected error messages
are printed when trying to access encrypted directories, files, and
symlinks from the GRUB command line.  Also ran 'sudo ./grub-fs-tester
ext4_encrypt'; note that this requires e2fsprogs v1.43+ and Linux v4.1+.

Signed-off-by: Eric Biggers <ebiggers@google.com>
grub-core/fs/ext2.c
tests/ext234_test.in
tests/util/grub-fs-tester.in