lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 24 Apr 2017 23:46:21 +0200
From:   Richard Weinberger <richard@....at>
To:     linux-mtd@...ts.infradead.org
Cc:     linux-kernel@...r.kernel.org, linux-fscrypt@...r.kernel.org,
        david@...ma-star.at,
        David Oberhollenzer <david.oberhollenzer@...ma-star.at>,
        Richard Weinberger <richard@....at>
Subject: [PATCH] ubifs: Return -ENOKEY from rename if encryption keys are missing

From: David Oberhollenzer <david.oberhollenzer@...ma-star.at>

If either source or destination directory is encrypted and the
encryption key is unknown, make sure we return -ENOKEY instead
of -EPERM, similar to how this case is handled in ext4.

Signed-off-by: David Oberhollenzer <david.oberhollenzer@...ma-star.at>
Signed-off-by: Richard Weinberger <richard@....at>

diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c
index ff77a0aa2f2b..c342f23581d2 100644
--- a/fs/ubifs/dir.c
+++ b/fs/ubifs/dir.c
@@ -1340,6 +1340,12 @@ static int do_rename(struct inode *old_dir, struct dentry *old_dentry,
 	if (unlink)
 		ubifs_assert(inode_is_locked(new_inode));
 
+	if ((ubifs_crypt_is_encrypted(old_dir) &&
+	     !fscrypt_has_encryption_key(old_dir)) ||
+	    (ubifs_crypt_is_encrypted(new_dir) &&
+	     !fscrypt_has_encryption_key(new_dir)))
+		return -ENOKEY;
+
 	if (old_dir != new_dir) {
 		if (ubifs_crypt_is_encrypted(new_dir) &&
 		    !fscrypt_has_permitted_context(new_dir, old_inode))
@@ -1564,6 +1570,12 @@ static int ubifs_xrename(struct inode *old_dir, struct dentry *old_dentry,
 
 	ubifs_assert(fst_inode && snd_inode);
 
+	if ((ubifs_crypt_is_encrypted(old_dir) &&
+	     !fscrypt_has_encryption_key(old_dir)) ||
+	    (ubifs_crypt_is_encrypted(new_dir) &&
+	     !fscrypt_has_encryption_key(new_dir)))
+		return -ENOKEY;
+
 	if ((ubifs_crypt_is_encrypted(old_dir) ||
 	    ubifs_crypt_is_encrypted(new_dir)) &&
 	    (old_dir != new_dir) &&
-- 
2.7.3

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ