]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commit - fs/ext4/namei.c
ext4 crypto: enforce context consistency
authorTheodore Ts'o <tytso@mit.edu>
Sun, 12 Apr 2015 04:55:08 +0000 (00:55 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Sun, 12 Apr 2015 04:55:08 +0000 (00:55 -0400)
commitd9cdc903318171571f1cd1e5737fd0cab94186be
tree5baa3a2fbd4a544fcf7ac7e5546b4b6a2ea25587
parent88bd6ccdcdd638faa11e9746affc21d5f2fe2acf
ext4 crypto: enforce context consistency

Enforce the following inheritance policy:

1) An unencrypted directory may contain encrypted or unencrypted files
or directories.

2) All files or directories in a directory must be protected using the
same key as their containing directory.

As a result, assuming the following setup:

mke2fs -t ext4 -Fq -O encrypt /dev/vdc
mount -t ext4 /dev/vdc /vdc
mkdir /vdc/a /vdc/b /vdc/c
echo foo | e4crypt add_key /vdc/a
echo bar | e4crypt add_key /vdc/b
for i in a b c ; do cp /etc/motd /vdc/$i/motd-$i ; done

Then we will see the following results:

cd /vdc
mv a b # will fail; /vdc/a and /vdc/b have different keys
mv b/motd-b a # will fail, see above
ln a/motd-a b # will fail, see above
mv c a      # will fail; all inodes in an encrypted directory
       # must be encrypted
ln c/motd-c b # will fail, see above
mv a/motd-a c # will succeed
mv c/motd-a a # will succeed

Signed-off-by: Michael Halcrow <mhalcrow@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
fs/ext4/namei.c