hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/fs/ecryptfs/keystore.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /**
23 * eCryptfs: Linux filesystem encryption layer
34 * In-kernel key management code. Includes functions to parse and
....@@ -8,21 +9,6 @@
89 * Author(s): Michael A. Halcrow <mhalcrow@us.ibm.com>
910 * Michael C. Thompson <mcthomps@us.ibm.com>
1011 * Trevor S. Highland <trevor.highland@gmail.com>
11
- *
12
- * This program is free software; you can redistribute it and/or
13
- * modify it under the terms of the GNU General Public License as
14
- * published by the Free Software Foundation; either version 2 of the
15
- * License, or (at your option) any later version.
16
- *
17
- * This program is distributed in the hope that it will be useful, but
18
- * WITHOUT ANY WARRANTY; without even the implied warranty of
19
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20
- * General Public License for more details.
21
- *
22
- * You should have received a copy of the GNU General Public License
23
- * along with this program; if not, write to the Free Software
24
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
25
- * 02111-1307, USA.
2612 */
2713
2814 #include <crypto/hash.h>
....@@ -769,7 +755,6 @@
769755 }
770756
771757 s->hash_desc->tfm = s->hash_tfm;
772
- s->hash_desc->flags = CRYPTO_TFM_REQ_MAY_SLEEP;
773758
774759 rc = crypto_shash_digest(s->hash_desc,
775760 (u8 *)s->auth_tok->token.password.session_key_encryption_key,
....@@ -853,7 +838,7 @@
853838 out_release_free_unlock:
854839 crypto_free_shash(s->hash_tfm);
855840 out_free_unlock:
856
- kzfree(s->block_aligned_filename);
841
+ kfree_sensitive(s->block_aligned_filename);
857842 out_unlock:
858843 mutex_unlock(s->tfm_mutex);
859844 out:
....@@ -862,7 +847,7 @@
862847 key_put(auth_tok_key);
863848 }
864849 skcipher_request_free(s->skcipher_req);
865
- kzfree(s->hash_desc);
850
+ kfree_sensitive(s->hash_desc);
866851 kfree(s);
867852 return rc;
868853 }
....@@ -1063,8 +1048,9 @@
10631048 "rc = [%d]\n", __func__, rc);
10641049 goto out_free_unlock;
10651050 }
1066
- while (s->decrypted_filename[s->i] != '\0'
1067
- && s->i < s->block_aligned_filename_size)
1051
+
1052
+ while (s->i < s->block_aligned_filename_size &&
1053
+ s->decrypted_filename[s->i] != '\0')
10681054 s->i++;
10691055 if (s->i == s->block_aligned_filename_size) {
10701056 printk(KERN_WARNING "%s: Invalid tag 70 packet; could not "
....@@ -1626,9 +1612,9 @@
16261612 int rc = 0;
16271613
16281614 (*auth_tok_key) = request_key(&key_type_user, sig, NULL);
1629
- if (!(*auth_tok_key) || IS_ERR(*auth_tok_key)) {
1615
+ if (IS_ERR(*auth_tok_key)) {
16301616 (*auth_tok_key) = ecryptfs_get_encrypted_key(sig);
1631
- if (!(*auth_tok_key) || IS_ERR(*auth_tok_key)) {
1617
+ if (IS_ERR(*auth_tok_key)) {
16321618 printk(KERN_ERR "Could not find key with description: [%s]\n",
16331619 sig);
16341620 rc = process_request_key_err(PTR_ERR(*auth_tok_key));
....@@ -2218,9 +2204,9 @@
22182204 if (mount_crypt_stat->global_default_cipher_key_size == 0) {
22192205 printk(KERN_WARNING "No key size specified at mount; "
22202206 "defaulting to [%d]\n",
2221
- crypto_skcipher_default_keysize(tfm));
2207
+ crypto_skcipher_max_keysize(tfm));
22222208 mount_crypt_stat->global_default_cipher_key_size =
2223
- crypto_skcipher_default_keysize(tfm);
2209
+ crypto_skcipher_max_keysize(tfm);
22242210 }
22252211 if (crypt_stat->key_size == 0)
22262212 crypt_stat->key_size =