]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
fscrypt: remove reachable WARN in fscrypt_setup_iv_ino_lblk_32_key()
authorEric Biggers <ebiggers@google.com>
Sat, 31 Oct 2020 00:45:56 +0000 (17:45 -0700)
committerEric Biggers <ebiggers@google.com>
Fri, 6 Nov 2020 17:48:55 +0000 (09:48 -0800)
I_CREATING isn't actually set until the inode has been assigned an inode
number and inserted into the inode hash table.  So the WARN_ON() in
fscrypt_setup_iv_ino_lblk_32_key() is wrong, and it can trigger when
creating an encrypted file on ext4.  Remove it.

This was sometimes causing xfstest generic/602 to fail on ext4.  I
didn't notice it before because due to a separate oversight, new inodes
that haven't been assigned an inode number yet don't necessarily have
i_ino == 0 as I had thought, so by chance I never saw the test fail.

Fixes: a992b20cd4ee ("fscrypt: add fscrypt_prepare_new_inode() and fscrypt_set_context()")
Reported-by: Theodore Y. Ts'o <tytso@mit.edu>
Link: https://lore.kernel.org/r/20201031004556.87862-1-ebiggers@kernel.org
Signed-off-by: Eric Biggers <ebiggers@google.com>
fs/crypto/keysetup.c

index d3c3e5d9b41f74b63db8924d12990c4b11d712e9..d595abb8ef90da8e747ffd141c4ec090872cb41d 100644 (file)
@@ -269,9 +269,7 @@ unlock:
         * New inodes may not have an inode number assigned yet.
         * Hashing their inode number is delayed until later.
         */
-       if (ci->ci_inode->i_ino == 0)
-               WARN_ON(!(ci->ci_inode->i_state & I_CREATING));
-       else
+       if (ci->ci_inode->i_ino)
                fscrypt_hash_inode_number(ci, mk);
        return 0;
 }