Skip to content

Commit 82854fb

Browse files
tytsogregkh
authored andcommitted
ext4: don't allow encrypted operations without keys
commit 173b8439e1ba362007315868928bf9d26e5cc5a6 upstream. While we allow deletes without the key, the following should not be permitted: # cd /vdc/encrypted-dir-without-key # ls -l 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 # mv uRJ5vJh9gE7vcomYMqTAyD 6,LKNRJsp209FbXoSvJWzB Signed-off-by: Theodore Ts'o <tytso@mit.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 4f22f07 commit 82854fb

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

fs/ext4/namei.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3506,6 +3506,12 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry,
35063506
int credits;
35073507
u8 old_file_type;
35083508

3509+
if ((ext4_encrypted_inode(old_dir) &&
3510+
!ext4_has_encryption_key(old_dir)) ||
3511+
(ext4_encrypted_inode(new_dir) &&
3512+
!ext4_has_encryption_key(new_dir)))
3513+
return -ENOKEY;
3514+
35093515
retval = dquot_initialize(old.dir);
35103516
if (retval)
35113517
return retval;
@@ -3706,6 +3712,12 @@ static int ext4_cross_rename(struct inode *old_dir, struct dentry *old_dentry,
37063712
u8 new_file_type;
37073713
int retval;
37083714

3715+
if ((ext4_encrypted_inode(old_dir) &&
3716+
!ext4_has_encryption_key(old_dir)) ||
3717+
(ext4_encrypted_inode(new_dir) &&
3718+
!ext4_has_encryption_key(new_dir)))
3719+
return -ENOKEY;
3720+
37093721
if ((ext4_encrypted_inode(old_dir) ||
37103722
ext4_encrypted_inode(new_dir)) &&
37113723
(old_dir != new_dir) &&

0 commit comments

Comments
 (0)