linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] fscrypt: remove reachable WARN in fscrypt_setup_iv_ino_lblk_32_key()
@ 2020-10-31  0:45 Eric Biggers
  2020-11-06 17:50 ` Eric Biggers
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Biggers @ 2020-10-31  0:45 UTC (permalink / raw)
  To: linux-fscrypt; +Cc: linux-fsdevel, linux-ext4, Theodore Y. Ts'o

From: Eric Biggers <ebiggers@google.com>

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>
Signed-off-by: Eric Biggers <ebiggers@google.com>
---
 fs/crypto/keysetup.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/fs/crypto/keysetup.c b/fs/crypto/keysetup.c
index d3c3e5d9b41f7..d595abb8ef90d 100644
--- a/fs/crypto/keysetup.c
+++ b/fs/crypto/keysetup.c
@@ -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
-- 
2.29.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] fscrypt: remove reachable WARN in fscrypt_setup_iv_ino_lblk_32_key()
  2020-10-31  0:45 [PATCH] fscrypt: remove reachable WARN in fscrypt_setup_iv_ino_lblk_32_key() Eric Biggers
@ 2020-11-06 17:50 ` Eric Biggers
  0 siblings, 0 replies; 2+ messages in thread
From: Eric Biggers @ 2020-11-06 17:50 UTC (permalink / raw)
  To: linux-fscrypt; +Cc: linux-fsdevel, linux-ext4, Theodore Y. Ts'o

On Fri, Oct 30, 2020 at 05:45:56PM -0700, Eric Biggers wrote:
> From: Eric Biggers <ebiggers@google.com>
> 
> 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>
> Signed-off-by: Eric Biggers <ebiggers@google.com>

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

- Eric

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-11-06 17:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-31  0:45 [PATCH] fscrypt: remove reachable WARN in fscrypt_setup_iv_ino_lblk_32_key() Eric Biggers
2020-11-06 17:50 ` Eric Biggers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).