Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933736AbcJUM7K (ORCPT ); Fri, 21 Oct 2016 08:59:10 -0400 Received: from mail.sigma-star.at ([95.130.255.111]:46007 "EHLO mail.sigma-star.at" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933164AbcJUMtR (ORCPT ); Fri, 21 Oct 2016 08:49:17 -0400 From: Richard Weinberger To: linux-mtd@lists.infradead.org Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, dedekind1@gmail.com, adrian.hunter@intel.com, tytso@mit.edu, jaegeuk@kernel.org, david@sigma-star.at, wd@denx.de, sbabic@denx.de, dengler@linutronix.de, Richard Weinberger Subject: [PATCH 11/26] ubifs: Preload crypto context in ->lookup() Date: Fri, 21 Oct 2016 14:48:26 +0200 Message-Id: <1477054121-10198-12-git-send-email-richard@nod.at> X-Mailer: git-send-email 2.7.3 In-Reply-To: <1477054121-10198-1-git-send-email-richard@nod.at> References: <1477054121-10198-1-git-send-email-richard@nod.at> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 948 Lines: 35 ...and mark the dentry as encrypted. Signed-off-by: Richard Weinberger --- fs/ubifs/dir.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c index a77edc5ca5c9..7ee32768ba19 100644 --- a/fs/ubifs/dir.c +++ b/fs/ubifs/dir.c @@ -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); -- 2.7.3