OSDN Git Service

ext4: don't call fscrypt_get_encryption_info() from dx_show_leaf()
authorEric Biggers <ebiggers@google.com>
Thu, 3 Dec 2020 02:20:36 +0000 (18:20 -0800)
committerEric Biggers <ebiggers@google.com>
Thu, 3 Dec 2020 02:25:01 +0000 (18:25 -0800)
The call to fscrypt_get_encryption_info() in dx_show_leaf() is too low
in the call tree; fscrypt_get_encryption_info() should have already been
called when starting the directory operation.  And indeed, it already
is.  Moreover, the encryption key is guaranteed to already be available
because dx_show_leaf() is only called when adding a new directory entry.

And even if the key wasn't available, dx_show_leaf() uses
fscrypt_fname_disk_to_usr() which knows how to create a no-key name.

So for the above reasons, and because it would be desirable to stop
exporting fscrypt_get_encryption_info() directly to filesystems, remove
the call to fscrypt_get_encryption_info() from dx_show_leaf().

Reviewed-by: Andreas Dilger <adilger@dilger.ca>
Link: https://lore.kernel.org/r/20201203022041.230976-5-ebiggers@kernel.org
Signed-off-by: Eric Biggers <ebiggers@google.com>
fs/ext4/namei.c

index 793fc7d..7b31aea 100644 (file)
@@ -643,13 +643,7 @@ static struct stats dx_show_leaf(struct inode *dir,
 
                                name  = de->name;
                                len = de->name_len;
-                               if (IS_ENCRYPTED(dir))
-                                       res = fscrypt_get_encryption_info(dir);
-                               if (res) {
-                                       printk(KERN_WARNING "Error setting up"
-                                              " fname crypto: %d\n", res);
-                               }
-                               if (!fscrypt_has_encryption_key(dir)) {
+                               if (!IS_ENCRYPTED(dir)) {
                                        /* Directory is not encrypted */
                                        ext4fs_dirhash(dir, de->name,
                                                de->name_len, &h);