>From b44a0893388882efc2d030262ea0dbacc150cb35 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o <tytso@xxxxxxx> Date: Wed, 28 Dec 2016 00:22:52 -0500 Subject: [PATCH] ext4: don't allow encrypted operations without keys [ Upstream commit 173b8439e1ba362007315868928bf9d26e5cc5a6 ] While we allow deletes without the key, the following should not be permitted: total 4 -rw-r--r-- 1 root root 0 Dec 27 22:35 6,LKNRJsp209FbXoSvJWzB -rw-r--r-- 1 root root 286 Dec 27 22:35 uRJ5vJh9gE7vcomYMqTAyD This fixes a failure in xfstests generic/419. Signed-off-by: Theodore Ts'o <tytso@xxxxxxx> --- fs/ext4/namei.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c index 03482c01fb3e..f84884b7e381 100644 --- a/fs/ext4/namei.c +++ b/fs/ext4/namei.c @@ -3566,6 +3566,12 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry, int credits; u8 old_file_type; + if ((ext4_encrypted_inode(old_dir) && + !ext4_has_encryption_key(old_dir)) || + (ext4_encrypted_inode(new_dir) && + !ext4_has_encryption_key(new_dir))) + return -ENOKEY; + dquot_initialize(old.dir); dquot_initialize(new.dir); @@ -3759,6 +3765,12 @@ static int ext4_cross_rename(struct inode *old_dir, struct dentry *old_dentry, u8 new_file_type; int retval; + if ((ext4_encrypted_inode(old_dir) && + !ext4_has_encryption_key(old_dir)) || + (ext4_encrypted_inode(new_dir) && + !ext4_has_encryption_key(new_dir))) + return -ENOKEY; + dquot_initialize(old.dir); dquot_initialize(new.dir); -- 2.11.0.rc0.7.gbe5a750