]> git.baikalelectronics.ru Git - kernel.git/commit
fscrypt: only set dentry_operations on ciphertext dentries
authorEric Biggers <ebiggers@google.com>
Wed, 20 Mar 2019 18:39:12 +0000 (11:39 -0700)
committerTheodore Ts'o <tytso@mit.edu>
Wed, 17 Apr 2019 14:06:32 +0000 (10:06 -0400)
commit6d615a275155a564a6b6a36924e8344ad2a956b4
tree5ff534692506594efb7fa3ec0f8e2f34b9808d8b
parent4e39533bb6021c74a01e0ae4f5208d7d9e064ca9
fscrypt: only set dentry_operations on ciphertext dentries

Plaintext dentries are always valid, so only set fscrypt_d_ops on
ciphertext dentries.

Besides marginally improved performance, this allows overlayfs to use an
fscrypt-encrypted upperdir, provided that all the following are true:

    (1) The fscrypt encryption key is placed in the keyring before
mounting overlayfs, and remains while the overlayfs is mounted.

    (2) The overlayfs workdir uses the same encryption policy.

    (3) No dentries for the ciphertext names of subdirectories have been
created in the upperdir or workdir yet.  (Since otherwise
d_splice_alias() will reuse the old dentry with ->d_op set.)

One potential use case is using an ephemeral encryption key to encrypt
all files created or changed by a container, so that they can be
securely erased ("crypto-shredded") after the container stops.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
fs/crypto/hooks.c