Skip to contentSkip to conversation

fscrypt: remove reachable WARN in fscrypt_setup_iv_ino_lblk_32_key()

PATCH Applied Eric Biggers 1 participant 2 messages Oct 31, 2020 – Nov 6, 2020

Subsystems (2)
lore
Share & tools
lore

Eric Biggers

author maintainer
#0 lore raw

PATCH 1/1 fscrypt: remove reachable WARN in fscrypt_setup_iv_ino_lblk_32_key()

From: Eric Biggers <[email protected]>

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()")
---
 fs/crypto/keysetup.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
fs/crypto/keysetup.c +1 -3
index d3c3e5d9b41f7..d595abb8ef90d 100644
@@ -269,9 +269,7 @@ static int fscrypt_setup_iv_ino_lblk_32_key(struct fscrypt_info *ci,
 	 * 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;
 }

base-commit: 5fc6b075e165f641fbc366b58b578055762d5f8c

Signature · 1 line
2.29.1
author maintainer Applied
#1 lore raw
Quoted 7 lines · Eric Biggers

From: Eric Biggers <[email protected]>

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.

Quoted 8 lines

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()")

Applied to fscrypt.git#for-stable for 5.10.

- Eric