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]
Date:	Tue, 12 May 2015 14:21:04 -0700
From:	Jaegeuk Kim <jaegeuk@...nel.org>
To:	linux-ext4@...r.kernel.org, Theodore Ts'o <tytso@....edu>
Cc:	Jaegeuk Kim <jaegeuk@...nel.org>
Subject: [PATCH 2/3] ext4 crypto: initialize crypto memory in early stage

Previously, crypto initialization was done at the first readpage time.
It'd need to avoid large memory allocation at run time.

Signed-off-by: Jaegeuk Kim <jaegeuk@...nel.org>
---
 fs/ext4/crypto.c     | 2 +-
 fs/ext4/crypto_key.c | 6 ------
 fs/ext4/ext4.h       | 4 ++--
 fs/ext4/super.c      | 8 ++++++++
 4 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/fs/ext4/crypto.c b/fs/ext4/crypto.c
index 04c620f..f265c08 100644
--- a/fs/ext4/crypto.c
+++ b/fs/ext4/crypto.c
@@ -256,7 +256,7 @@ void ext4_exit_crypto(void)
  *
  * Return: Zero on success, non-zero otherwise.
  */
-int ext4_init_crypto(void)
+int __init ext4_init_crypto(void)
 {
 	int i, res = -ENOMEM;
 
diff --git a/fs/ext4/crypto_key.c b/fs/ext4/crypto_key.c
index 858d7d6..fb957ab 100644
--- a/fs/ext4/crypto_key.c
+++ b/fs/ext4/crypto_key.c
@@ -113,12 +113,6 @@ int _ext4_get_encryption_info(struct inode *inode)
 	struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
 	int res;
 
-	if (!ext4_read_workqueue) {
-		res = ext4_init_crypto();
-		if (res)
-			return res;
-	}
-
 	if (ei->i_crypt_info) {
 		if (!ei->i_crypt_info->ci_keyring_key ||
 		    key_validate(ei->i_crypt_info->ci_keyring_key) == 0)
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index 505bc66..3b5dd12 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -2073,14 +2073,14 @@ int ext4_decrypt_one(struct inode *inode, struct page *page);
 int ext4_encrypted_zeroout(struct inode *inode, struct ext4_extent *ex);
 
 #ifdef CONFIG_EXT4_FS_ENCRYPTION
-int ext4_init_crypto(void);
+int __init ext4_init_crypto(void);
 void ext4_exit_crypto(void);
 static inline int ext4_sb_has_crypto(struct super_block *sb)
 {
 	return EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_ENCRYPT);
 }
 #else
-static inline int ext4_init_crypto(void) { return 0; }
+static inline int __init ext4_init_crypto(void) { return 0; }
 static inline void ext4_exit_crypto(void) { }
 static inline int ext4_sb_has_crypto(struct super_block *sb)
 {
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 79311e0..411a8a3 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -5611,6 +5611,11 @@ static int __init ext4_init_fs(void)
 	err = init_inodecache();
 	if (err)
 		goto out1;
+
+	err = ext4_init_crypto();
+	if (err)
+		goto out0;
+
 	register_as_ext3();
 	register_as_ext2();
 	err = register_filesystem(&ext4_fs_type);
@@ -5621,6 +5626,8 @@ static int __init ext4_init_fs(void)
 out:
 	unregister_as_ext2();
 	unregister_as_ext3();
+	ext4_exit_crypto();
+out0:
 	destroy_inodecache();
 out1:
 	ext4_mballoc_ready = 0;
@@ -5646,6 +5653,7 @@ static void __exit ext4_exit_fs(void)
 	ext4_destroy_lazyinit_thread();
 	unregister_as_ext2();
 	unregister_as_ext3();
+	ext4_exit_crypto();
 	unregister_filesystem(&ext4_fs_type);
 	destroy_inodecache();
 	ext4_exit_mballoc();
-- 
2.1.1

--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ