Skip to content

Commit 5312426

Browse files
robertosassugregkh
authored andcommitted
evm: Refuse EVM_ALLOW_METADATA_WRITES only if an HMAC key is loaded
commit 9acc89d upstream. EVM_ALLOW_METADATA_WRITES is an EVM initialization flag that can be set to temporarily disable metadata verification until all xattrs/attrs necessary to verify an EVM portable signature are copied to the file. This flag is cleared when EVM is initialized with an HMAC key, to avoid that the HMAC is calculated on unverified xattrs/attrs. Currently EVM unnecessarily denies setting this flag if EVM is initialized with a public key, which is not a concern as it cannot be used to trust xattrs/attrs updates. This patch removes this limitation. Fixes: ae1ba16 ("EVM: Allow userland to permit modification of EVM-protected metadata") Signed-off-by: Roberto Sassu <roberto.sassu@huawei.com> Cc: stable@vger.kernel.org # 4.16.x Signed-off-by: Mimi Zohar <zohar@linux.ibm.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 7b84c7d commit 5312426

2 files changed

Lines changed: 28 additions & 6 deletions

File tree

‎Documentation/ABI/testing/evm‎

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,30 @@ Description:
4949
modification of EVM-protected metadata and
5050
disable all further modification of policy
5151

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

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

‎security/integrity/evm/evm_secfs.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,12 @@ static ssize_t evm_write_key(struct file *file, const char __user *buf,
8080
if (!i || (i & ~EVM_INIT_MASK) != 0)
8181
return -EINVAL;
8282

83-
/* Don't allow a request to freshly enable metadata writes if
84-
* keys are loaded.
83+
/*
84+
* Don't allow a request to enable metadata writes if
85+
* an HMAC key is loaded.
8586
*/
8687
if ((i & EVM_ALLOW_METADATA_WRITES) &&
87-
((evm_initialized & EVM_KEY_MASK) != 0) &&
88-
!(evm_initialized & EVM_ALLOW_METADATA_WRITES))
88+
(evm_initialized & EVM_INIT_HMAC) != 0)
8989
return -EPERM;
9090

9191
if (i & EVM_INIT_HMAC) {

0 commit comments

Comments
 (0)