Skip to content

Commit 5a25d8c

Browse files
committed
Merge branch 'misc-evm-v7' into next-integrity
From cover letter: EVM portable signatures are particularly suitable for the protection of metadata of immutable files where metadata is signed by a software vendor. They can be used for example in conjunction with an IMA policy that appraises only executed and memory mapped files. However, until now portable signatures can be properly installed only if the EVM_ALLOW_METADATA_WRITES initialization flag is also set, which disables metadata verification until an HMAC key is loaded. This will cause metadata writes to be allowed even in the situations where they shouldn't (metadata protected by a portable signature is immutable). The main reason why setting the flag is necessary is that the operations necessary to install portable signatures and protected metadata would be otherwise denied, despite being legitimate, due to the fact that the decision logic has to avoid an unsafe recalculation of the HMAC that would make the unsuccessfully verified metadata valid. However, the decision logic is too coarse, and does not fully take into account all the possible situations where metadata operations could be allowed. For example, if the HMAC key is not loaded and it cannot be loaded in the future due the EVM_SETUP_COMPLETE flag being set, it wouldn't be a problem to allow metadata operations, as they wouldn't result in an HMAC being recalculated. This patch set extends the decision logic and adds the necessary exceptions to use portable signatures without turning off metadata verification and deprecates the EVM_ALLOW_METADATA_WRITES flag. Link: https://lore.kernel.org/linux-integrity/20210514152753.982958-1-roberto.sassu@huawei.com/
2 parents 49219d9 + ed1b472 commit 5a25d8c

13 files changed

Lines changed: 355 additions & 51 deletions

File tree

Documentation/ABI/testing/evm

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Description:
2424
1 Enable digital signature validation
2525
2 Permit modification of EVM-protected metadata at
2626
runtime. Not supported if HMAC validation and
27-
creation is enabled.
27+
creation is enabled (deprecated).
2828
31 Disable further runtime modification of EVM policy
2929
=== ==================================================
3030

@@ -47,10 +47,38 @@ Description:
4747

4848
will enable digital signature validation, permit
4949
modification of EVM-protected metadata and
50-
disable all further modification of policy
50+
disable all further modification of policy. This option is now
51+
deprecated in favor of::
5152

52-
Note that once a key has been loaded, it will no longer be
53-
possible to enable metadata modification.
53+
echo 0x80000002 ><securityfs>/evm
54+
55+
as the outstanding issues that prevent the usage of EVM portable
56+
signatures have been solved.
57+
58+
Echoing a value is additive, the new value is added to the
59+
existing initialization flags.
60+
61+
For example, after::
62+
63+
echo 2 ><securityfs>/evm
64+
65+
another echo can be performed::
66+
67+
echo 1 ><securityfs>/evm
68+
69+
and the resulting value will be 3.
70+
71+
Note that once an HMAC key has been loaded, it will no longer
72+
be possible to enable metadata modification. Signaling that an
73+
HMAC key has been loaded will clear the corresponding flag.
74+
For example, if the current value is 6 (2 and 4 set)::
75+
76+
echo 1 ><securityfs>/evm
77+
78+
will set the new value to 3 (4 cleared).
79+
80+
Loading an HMAC key is the only way to disable metadata
81+
modification.
5482

5583
Until key loading has been signaled EVM can not create
5684
or validate the 'security.evm' xattr, but returns

Documentation/security/IMA-templates.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,11 @@ descriptors by adding their identifier to the format string
7070
prefix is shown only if the hash algorithm is not SHA1 or MD5);
7171
- 'd-modsig': the digest of the event without the appended modsig;
7272
- 'n-ng': the name of the event, without size limitations;
73-
- 'sig': the file signature;
73+
- 'sig': the file signature, or the EVM portable signature if the file
74+
signature is not found;
7475
- 'modsig' the appended file signature;
7576
- 'buf': the buffer data that was used to generate the hash without size limitations;
77+
- 'evmsig': the EVM portable signature;
7678

7779

7880
Below, there is the list of defined template descriptors:

include/linux/evm.h

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,21 @@ extern enum integrity_status evm_verifyxattr(struct dentry *dentry,
2323
struct integrity_iint_cache *iint);
2424
extern int evm_inode_setattr(struct dentry *dentry, struct iattr *attr);
2525
extern void evm_inode_post_setattr(struct dentry *dentry, int ia_valid);
26-
extern int evm_inode_setxattr(struct dentry *dentry, const char *name,
26+
extern int evm_inode_setxattr(struct user_namespace *mnt_userns,
27+
struct dentry *dentry, const char *name,
2728
const void *value, size_t size);
2829
extern void evm_inode_post_setxattr(struct dentry *dentry,
2930
const char *xattr_name,
3031
const void *xattr_value,
3132
size_t xattr_value_len);
32-
extern int evm_inode_removexattr(struct dentry *dentry, const char *xattr_name);
33+
extern int evm_inode_removexattr(struct user_namespace *mnt_userns,
34+
struct dentry *dentry, const char *xattr_name);
3335
extern void evm_inode_post_removexattr(struct dentry *dentry,
3436
const char *xattr_name);
3537
extern int evm_inode_init_security(struct inode *inode,
3638
const struct xattr *xattr_array,
3739
struct xattr *evm);
40+
extern bool evm_revalidate_status(const char *xattr_name);
3841
#ifdef CONFIG_FS_POSIX_ACL
3942
extern int posix_xattr_acl(const char *xattrname);
4043
#else
@@ -71,7 +74,8 @@ static inline void evm_inode_post_setattr(struct dentry *dentry, int ia_valid)
7174
return;
7275
}
7376

74-
static inline int evm_inode_setxattr(struct dentry *dentry, const char *name,
77+
static inline int evm_inode_setxattr(struct user_namespace *mnt_userns,
78+
struct dentry *dentry, const char *name,
7579
const void *value, size_t size)
7680
{
7781
return 0;
@@ -85,7 +89,8 @@ static inline void evm_inode_post_setxattr(struct dentry *dentry,
8589
return;
8690
}
8791

88-
static inline int evm_inode_removexattr(struct dentry *dentry,
92+
static inline int evm_inode_removexattr(struct user_namespace *mnt_userns,
93+
struct dentry *dentry,
8994
const char *xattr_name)
9095
{
9196
return 0;
@@ -104,5 +109,10 @@ static inline int evm_inode_init_security(struct inode *inode,
104109
return 0;
105110
}
106111

112+
static inline bool evm_revalidate_status(const char *xattr_name)
113+
{
114+
return false;
115+
}
116+
107117
#endif /* CONFIG_EVM */
108118
#endif /* LINUX_EVM_H */

include/linux/integrity.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ enum integrity_status {
1313
INTEGRITY_PASS = 0,
1414
INTEGRITY_PASS_IMMUTABLE,
1515
INTEGRITY_FAIL,
16+
INTEGRITY_FAIL_IMMUTABLE,
1617
INTEGRITY_NOLABEL,
1718
INTEGRITY_NOXATTRS,
1819
INTEGRITY_UNKNOWN,

0 commit comments

Comments
 (0)