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
66#define FSCRYPT_CONTEXT_V1 166#define FSCRYPT_CONTEXT_V1 1
67#define FSCRYPT_CONTEXT_V2 267#define FSCRYPT_CONTEXT_V2 2
68 68
69/* Keep this in sync with include/uapi/linux/fscrypt.h */
70#define FSCRYPT_MODE_MAX FSCRYPT_MODE_AES_256_HCTR2
71
72struct fscrypt_context_v1 {69struct fscrypt_context_v1 {
73 u8 version; /* FSCRYPT_CONTEXT_V1 */70 u8 version; /* FSCRYPT_CONTEXT_V1 */
74 u8 contents_encryption_mode;71 u8 contents_encryption_mode;
fs/crypto/keysetup.c+0−5
@@ -83,8 +83,6 @@ static struct fscrypt_mode * · 82 unmodified lines
83select_encryption_mode(const union fscrypt_policy *policy,83select_encryption_mode(const union fscrypt_policy *policy,
84 const struct inode *inode)84 const struct inode *inode)
85{85{
86 BUILD_BUG_ON(ARRAY_SIZE(fscrypt_modes) != FSCRYPT_MODE_MAX + 1);
87
88 if (S_ISREG(inode->i_mode))86 if (S_ISREG(inode->i_mode))
89 return &fscrypt_modes[fscrypt_policy_contents_mode(policy)];87 return &fscrypt_modes[fscrypt_policy_contents_mode(policy)];
90 88
@@ -229,9 +227,6 @@ static int setup_per_mode_enc_key(struct fscrypt_inode_info *ci, · 138 unmodified lines
229 bool use_hw_wrapped_key = false;227 bool use_hw_wrapped_key = false;
230 int err;228 int err;
231 229
232 if (WARN_ON_ONCE(mode_num > FSCRYPT_MODE_MAX))
233 return -EINVAL;
234
235 if (mk->mk_secret.is_hw_wrapped && S_ISREG(inode->i_mode)) {230 if (mk->mk_secret.is_hw_wrapped && S_ISREG(inode->i_mode)) {
236 /* Using a hardware-wrapped key for file contents encryption */231 /* Using a hardware-wrapped key for file contents encryption */
237 if (!fscrypt_using_inline_encryption(ci)) {232 if (!fscrypt_using_inline_encryption(ci)) {
include/uapi/linux/fscrypt.h+0−1
@@ -30,7 +30,6 @@ · 29 unmodified lines
30#define FSCRYPT_MODE_SM4_CTS 830#define FSCRYPT_MODE_SM4_CTS 8
31#define FSCRYPT_MODE_ADIANTUM 931#define FSCRYPT_MODE_ADIANTUM 9
32#define FSCRYPT_MODE_AES_256_HCTR2 1032#define FSCRYPT_MODE_AES_256_HCTR2 10
33/* If adding a mode number > 10, update FSCRYPT_MODE_MAX in fscrypt_private.h */
34 33
35/*34/*
36 * Legacy policy version; ad-hoc KDF and no key verification.35 * 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
30#define FSCRYPT_MODE_SM4_CTS 830#define FSCRYPT_MODE_SM4_CTS 8
31#define FSCRYPT_MODE_ADIANTUM 931#define FSCRYPT_MODE_ADIANTUM 9
32#define FSCRYPT_MODE_AES_256_HCTR2 1032#define FSCRYPT_MODE_AES_256_HCTR2 10
33/* If adding a mode number > 10, update FSCRYPT_MODE_MAX in fscrypt_private.h */
34 33
35/*34/*
36 * Legacy policy version; ad-hoc KDF and no key verification.35 * Legacy policy version; ad-hoc KDF and no key verification.