ubifs: Preload crypto context in ->lookup()
authorRichard Weinberger <richard@nod.at>
Thu, 29 Sep 2016 18:10:06 +0000 (20:10 +0200)
committerRichard Weinberger <richard@nod.at>
Mon, 12 Dec 2016 22:07:38 +0000 (23:07 +0100)
...and mark the dentry as encrypted.

Signed-off-by: Richard Weinberger <richard@nod.at>
fs/ubifs/dir.c

index bd0af4e9ca0b1dafa2469da1d56d0a494858d22b..9976a709b87555213c0edf6a82d2445421daddc7 100644 (file)
@@ -218,6 +218,21 @@ static struct dentry *ubifs_lookup(struct inode *dir, struct dentry *dentry,
 
        dbg_gen("'%pd' in dir ino %lu", dentry, dir->i_ino);
 
+       if (ubifs_crypt_is_encrypted(dir)) {
+               err = fscrypt_get_encryption_info(dir);
+
+               /*
+                * DCACHE_ENCRYPTED_WITH_KEY is set if the dentry is
+                * created while the directory was encrypted and we
+                * have access to the key.
+                */
+               if (fscrypt_has_encryption_key(dir))
+                       fscrypt_set_encrypted_dentry(dentry);
+               fscrypt_set_d_op(dentry);
+               if (err && err != -ENOKEY)
+                       return ERR_PTR(err);
+       }
+
        if (dentry->d_name.len > UBIFS_MAX_NLEN)
                return ERR_PTR(-ENAMETOOLONG);