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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240125044826.1294268-1-xiubli@redhat.com>
Date: Thu, 25 Jan 2024 12:48:25 +0800
From: xiubli@...hat.com
To: linux-fscrypt@...r.kernel.org
Cc: ebiggers@...nel.org,
	tytso@....edu,
	jaegeuk@...nel.org,
	linux-kernel@...r.kernel.org,
	idryomov@...il.com,
	ceph-devel@...r.kernel.org,
	jlayton@...nel.org,
	vshankar@...hat.com,
	Xiubo Li <xiubli@...hat.com>
Subject: [PATCH] fscrypt: to make sure the inode->i_blkbits is correctly set

From: Xiubo Li <xiubli@...hat.com>

The inode->i_blkbits should be already set before calling
fscrypt_get_encryption_info() and it will be used this to setup the
ci_data_unit_bits.

Signed-off-by: Xiubo Li <xiubli@...hat.com>
---
 fs/crypto/keysetup.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/fs/crypto/keysetup.c b/fs/crypto/keysetup.c
index d71f7c799e79..909187e52bae 100644
--- a/fs/crypto/keysetup.c
+++ b/fs/crypto/keysetup.c
@@ -702,6 +702,9 @@ int fscrypt_get_encryption_info(struct inode *inode, bool allow_unsupported)
  * This doesn't persist the new inode's encryption context.  That still needs to
  * be done later by calling fscrypt_set_context().
  *
+ * Please note that the inode->i_blkbits should be already set before calling
+ * this and later it will be used to setup the ci_data_unit_bits.
+ *
  * Return: 0 on success, -ENOKEY if the encryption key is missing, or another
  *	   -errno code
  */
@@ -717,6 +720,9 @@ int fscrypt_prepare_new_inode(struct inode *dir, struct inode *inode,
 	if (IS_ERR(policy))
 		return PTR_ERR(policy);
 
+	if (WARN_ON_ONCE(inode->i_blkbits == 0))
+		return -EINVAL;
+
 	if (WARN_ON_ONCE(inode->i_mode == 0))
 		return -EINVAL;
 
-- 
2.43.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ