• Theodore Ts'o's avatar
    ext4 crypto: enforce context consistency · d9cdc903
    Theodore Ts'o authored
    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: default avatarMichael Halcrow <mhalcrow@google.com>
    Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
    d9cdc903
namei.c 94.5 KB