hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/fs/crypto/crypto.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * This contains encryption functions for per-file encryption.
34 *
....@@ -72,7 +73,7 @@
7273 * Generate the IV for the given logical block number within the given file.
7374 * For filenames encryption, lblk_num == 0.
7475 *
75
- * Keep this in sync with fscrypt_limit_dio_pages(). fscrypt_limit_dio_pages()
76
+ * Keep this in sync with fscrypt_limit_io_blocks(). fscrypt_limit_io_blocks()
7677 * needs to know about any IV generation methods where the low bits of IV don't
7778 * simply contain the lblk_num (e.g., IV_INO_LBLK_32).
7879 */
....@@ -91,7 +92,7 @@
9192 WARN_ON_ONCE(lblk_num > U32_MAX);
9293 lblk_num = (u32)(ci->ci_hashed_ino + lblk_num);
9394 } else if (flags & FSCRYPT_POLICY_FLAG_DIRECT_KEY) {
94
- memcpy(iv->nonce, ci->ci_nonce, FS_KEY_DERIVATION_NONCE_SIZE);
95
+ memcpy(iv->nonce, ci->ci_nonce, FSCRYPT_FILE_NONCE_SIZE);
9596 }
9697 iv->lblk_num = cpu_to_le64(lblk_num);
9798 }
....@@ -107,7 +108,7 @@
107108 DECLARE_CRYPTO_WAIT(wait);
108109 struct scatterlist dst, src;
109110 struct fscrypt_info *ci = inode->i_crypt_info;
110
- struct crypto_skcipher *tfm = ci->ci_key.tfm;
111
+ struct crypto_skcipher *tfm = ci->ci_enc_key.tfm;
111112 int res = 0;
112113
113114 if (WARN_ON_ONCE(len <= 0))
....@@ -350,9 +351,11 @@
350351 va_start(args, fmt);
351352 vaf.fmt = fmt;
352353 vaf.va = &args;
353
- if (inode)
354
+ if (inode && inode->i_ino)
354355 printk("%sfscrypt (%s, inode %lu): %pV\n",
355356 level, inode->i_sb->s_id, inode->i_ino, &vaf);
357
+ else if (inode)
358
+ printk("%sfscrypt (%s): %pV\n", level, inode->i_sb->s_id, &vaf);
356359 else
357360 printk("%sfscrypt: %pV\n", level, &vaf);
358361 va_end(args);