Skip to content

Commit

Permalink
Merge branch 'misc-evm-v7' into next-integrity
Browse files Browse the repository at this point in the history
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/[email protected]/
  • Loading branch information
mimizohar committed Jun 1, 2021
2 parents 49219d9 + ed1b472 commit 5a25d8c
Show file tree
Hide file tree
Showing 13 changed files with 355 additions and 51 deletions.
36 changes: 32 additions & 4 deletions Documentation/ABI/testing/evm
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Description:
1 Enable digital signature validation
2 Permit modification of EVM-protected metadata at
runtime. Not supported if HMAC validation and
creation is enabled.
creation is enabled (deprecated).
31 Disable further runtime modification of EVM policy
=== ==================================================

Expand All @@ -47,10 +47,38 @@ Description:

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

Note that once a key has been loaded, it will no longer be
possible to enable metadata modification.
echo 0x80000002 ><securityfs>/evm

as the outstanding issues that prevent the usage of EVM portable
signatures have been solved.

Echoing a value is additive, the new value is added to the
existing initialization flags.

For example, after::

echo 2 ><securityfs>/evm

another echo can be performed::

echo 1 ><securityfs>/evm

and the resulting value will be 3.

Note that once an HMAC key has been loaded, it will no longer
be possible to enable metadata modification. Signaling that an
HMAC key has been loaded will clear the corresponding flag.
For example, if the current value is 6 (2 and 4 set)::

echo 1 ><securityfs>/evm

will set the new value to 3 (4 cleared).

Loading an HMAC key is the only way to disable metadata
modification.

Until key loading has been signaled EVM can not create
or validate the 'security.evm' xattr, but returns
Expand Down
4 changes: 3 additions & 1 deletion Documentation/security/IMA-templates.rst
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,11 @@ descriptors by adding their identifier to the format string
prefix is shown only if the hash algorithm is not SHA1 or MD5);
- 'd-modsig': the digest of the event without the appended modsig;
- 'n-ng': the name of the event, without size limitations;
- 'sig': the file signature;
- 'sig': the file signature, or the EVM portable signature if the file
signature is not found;
- 'modsig' the appended file signature;
- 'buf': the buffer data that was used to generate the hash without size limitations;
- 'evmsig': the EVM portable signature;


Below, there is the list of defined template descriptors:
Expand Down
18 changes: 14 additions & 4 deletions include/linux/evm.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,21 @@ extern enum integrity_status evm_verifyxattr(struct dentry *dentry,
struct integrity_iint_cache *iint);
extern int evm_inode_setattr(struct dentry *dentry, struct iattr *attr);
extern void evm_inode_post_setattr(struct dentry *dentry, int ia_valid);
extern int evm_inode_setxattr(struct dentry *dentry, const char *name,
extern int evm_inode_setxattr(struct user_namespace *mnt_userns,
struct dentry *dentry, const char *name,
const void *value, size_t size);
extern void evm_inode_post_setxattr(struct dentry *dentry,
const char *xattr_name,
const void *xattr_value,
size_t xattr_value_len);
extern int evm_inode_removexattr(struct dentry *dentry, const char *xattr_name);
extern int evm_inode_removexattr(struct user_namespace *mnt_userns,
struct dentry *dentry, const char *xattr_name);
extern void evm_inode_post_removexattr(struct dentry *dentry,
const char *xattr_name);
extern int evm_inode_init_security(struct inode *inode,
const struct xattr *xattr_array,
struct xattr *evm);
extern bool evm_revalidate_status(const char *xattr_name);
#ifdef CONFIG_FS_POSIX_ACL
extern int posix_xattr_acl(const char *xattrname);
#else
Expand Down Expand Up @@ -71,7 +74,8 @@ static inline void evm_inode_post_setattr(struct dentry *dentry, int ia_valid)
return;
}

static inline int evm_inode_setxattr(struct dentry *dentry, const char *name,
static inline int evm_inode_setxattr(struct user_namespace *mnt_userns,
struct dentry *dentry, const char *name,
const void *value, size_t size)
{
return 0;
Expand All @@ -85,7 +89,8 @@ static inline void evm_inode_post_setxattr(struct dentry *dentry,
return;
}

static inline int evm_inode_removexattr(struct dentry *dentry,
static inline int evm_inode_removexattr(struct user_namespace *mnt_userns,
struct dentry *dentry,
const char *xattr_name)
{
return 0;
Expand All @@ -104,5 +109,10 @@ static inline int evm_inode_init_security(struct inode *inode,
return 0;
}

static inline bool evm_revalidate_status(const char *xattr_name)
{
return false;
}

#endif /* CONFIG_EVM */
#endif /* LINUX_EVM_H */
1 change: 1 addition & 0 deletions include/linux/integrity.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ enum integrity_status {
INTEGRITY_PASS = 0,
INTEGRITY_PASS_IMMUTABLE,
INTEGRITY_FAIL,
INTEGRITY_FAIL_IMMUTABLE,
INTEGRITY_NOLABEL,
INTEGRITY_NOXATTRS,
INTEGRITY_UNKNOWN,
Expand Down
Loading

0 comments on commit 5a25d8c

Please sign in to comment.