.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * This contains encryption functions for per-file encryption. |
---|
3 | 4 | * |
---|
.. | .. |
---|
72 | 73 | * Generate the IV for the given logical block number within the given file. |
---|
73 | 74 | * For filenames encryption, lblk_num == 0. |
---|
74 | 75 | * |
---|
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() |
---|
76 | 77 | * needs to know about any IV generation methods where the low bits of IV don't |
---|
77 | 78 | * simply contain the lblk_num (e.g., IV_INO_LBLK_32). |
---|
78 | 79 | */ |
---|
.. | .. |
---|
91 | 92 | WARN_ON_ONCE(lblk_num > U32_MAX); |
---|
92 | 93 | lblk_num = (u32)(ci->ci_hashed_ino + lblk_num); |
---|
93 | 94 | } 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); |
---|
95 | 96 | } |
---|
96 | 97 | iv->lblk_num = cpu_to_le64(lblk_num); |
---|
97 | 98 | } |
---|
.. | .. |
---|
107 | 108 | DECLARE_CRYPTO_WAIT(wait); |
---|
108 | 109 | struct scatterlist dst, src; |
---|
109 | 110 | 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; |
---|
111 | 112 | int res = 0; |
---|
112 | 113 | |
---|
113 | 114 | if (WARN_ON_ONCE(len <= 0)) |
---|
.. | .. |
---|
350 | 351 | va_start(args, fmt); |
---|
351 | 352 | vaf.fmt = fmt; |
---|
352 | 353 | vaf.va = &args; |
---|
353 | | - if (inode) |
---|
| 354 | + if (inode && inode->i_ino) |
---|
354 | 355 | printk("%sfscrypt (%s, inode %lu): %pV\n", |
---|
355 | 356 | 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); |
---|
356 | 359 | else |
---|
357 | 360 | printk("%sfscrypt: %pV\n", level, &vaf); |
---|
358 | 361 | va_end(args); |
---|