History

fscrypt: Remove FSCRYPT_MODE_MAX

Now that the arrays of per-mode keys in struct fscrypt_master_key have been replaced by a linked list, the definition of FSCRYPT_MODE_MAX doesn't do anything useful. (Previously it was used to size these arrays.) Remove it.

Eric Biggers committed 4 months ago

Commit fa1517b1 parent 7ad19404 files · +0 −10Browse files

Unified · Split

4 files
  1. fs/crypto/fscrypt_private.h +0 −3
  2. fs/crypto/keysetup.c +0 −5
  3. include/uapi/linux/fscrypt.h +0 −1
  4. tools/include/uapi/linux/fscrypt.h +0 −1
fs/crypto/fscrypt_private.h+0−3
@@ -66,9 +66,6 @@ · 65 unmodified lines
6666 #define FSCRYPT_CONTEXT_V1 1
6767 #define FSCRYPT_CONTEXT_V2 2
6868
69−/* Keep this in sync with include/uapi/linux/fscrypt.h */
70−#define FSCRYPT_MODE_MAX FSCRYPT_MODE_AES_256_HCTR2
71−
7269 struct fscrypt_context_v1 {
7370 u8 version; /* FSCRYPT_CONTEXT_V1 */
7471 u8 contents_encryption_mode;
fs/crypto/keysetup.c+0−5
@@ -83,8 +83,6 @@ static struct fscrypt_mode * · 82 unmodified lines
8383 select_encryption_mode(const union fscrypt_policy *policy,
8484 const struct inode *inode)
8585 {
86− BUILD_BUG_ON(ARRAY_SIZE(fscrypt_modes) != FSCRYPT_MODE_MAX + 1);
87−
8886 if (S_ISREG(inode->i_mode))
8987 return &fscrypt_modes[fscrypt_policy_contents_mode(policy)];
9088
@@ -229,9 +227,6 @@ static int setup_per_mode_enc_key(struct fscrypt_inode_info *ci, · 138 unmodified lines
229227 bool use_hw_wrapped_key = false;
230228 int err;
231229
232− if (WARN_ON_ONCE(mode_num > FSCRYPT_MODE_MAX))
233− return -EINVAL;
234−
235230 if (mk->mk_secret.is_hw_wrapped && S_ISREG(inode->i_mode)) {
236231 /* Using a hardware-wrapped key for file contents encryption */
237232 if (!fscrypt_using_inline_encryption(ci)) {
include/uapi/linux/fscrypt.h+0−1
@@ -30,7 +30,6 @@ · 29 unmodified lines
3030 #define FSCRYPT_MODE_SM4_CTS 8
3131 #define FSCRYPT_MODE_ADIANTUM 9
3232 #define FSCRYPT_MODE_AES_256_HCTR2 10
33−/* If adding a mode number > 10, update FSCRYPT_MODE_MAX in fscrypt_private.h */
3433
3534 /*
3635 * Legacy policy version; ad-hoc KDF and no key verification.
tools/include/uapi/linux/fscrypt.h+0−1
@@ -30,7 +30,6 @@ · 29 unmodified lines
3030 #define FSCRYPT_MODE_SM4_CTS 8
3131 #define FSCRYPT_MODE_ADIANTUM 9
3232 #define FSCRYPT_MODE_AES_256_HCTR2 10
33−/* If adding a mode number > 10, update FSCRYPT_MODE_MAX in fscrypt_private.h */
3433
3534 /*
3635 * Legacy policy version; ad-hoc KDF and no key verification.