Skip to content

Commit 82bbd44

Browse files
stefanbergermimizohar
authored andcommitted
evm: Enforce signatures version 3 with new EVM policy 'bit 3'
Enable the configuration of EVM so that it requires that asymmetric signatures it accepts are of version 3 (sigv3). To enable this, introduce bit 3 (value 0x0008) that the user may write to EVM's securityfs policy configuration file 'evm' for sigv3 enforcement. Mention bit 3 in the documentation. Signed-off-by: Stefan Berger <stefanb@linux.ibm.com> Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
1 parent bab8e90 commit 82bbd44

3 files changed

Lines changed: 17 additions & 1 deletion

File tree

Documentation/ABI/testing/evm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Description:
2626
2 Permit modification of EVM-protected metadata at
2727
runtime. Not supported if HMAC validation and
2828
creation is enabled (deprecated).
29+
3 Require asymmetric signatures to be version 3
2930
31 Disable further runtime modification of EVM policy
3031
=== ==================================================
3132

security/integrity/evm/evm.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@
2020
#define EVM_INIT_HMAC 0x0001
2121
#define EVM_INIT_X509 0x0002
2222
#define EVM_ALLOW_METADATA_WRITES 0x0004
23+
#define EVM_SIGV3_REQUIRED 0x0008
2324
#define EVM_SETUP_COMPLETE 0x80000000 /* userland has signaled key load */
2425

2526
#define EVM_KEY_MASK (EVM_INIT_HMAC | EVM_INIT_X509)
2627
#define EVM_INIT_MASK (EVM_INIT_HMAC | EVM_INIT_X509 | EVM_SETUP_COMPLETE | \
27-
EVM_ALLOW_METADATA_WRITES)
28+
EVM_ALLOW_METADATA_WRITES | EVM_SIGV3_REQUIRED)
2829

2930
struct xattr_list {
3031
struct list_head list;

security/integrity/evm/evm_main.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,14 @@ static bool evm_hmac_disabled(void)
136136
return true;
137137
}
138138

139+
static bool evm_sigv3_required(void)
140+
{
141+
if (evm_initialized & EVM_SIGV3_REQUIRED)
142+
return true;
143+
144+
return false;
145+
}
146+
139147
static int evm_find_protected_xattrs(struct dentry *dentry)
140148
{
141149
struct inode *inode = d_backing_inode(dentry);
@@ -258,6 +266,12 @@ static enum integrity_status evm_verify_hmac(struct dentry *dentry,
258266
}
259267

260268
hdr = (struct signature_v2_hdr *)xattr_data;
269+
270+
if (evm_sigv3_required() && hdr->version != 3) {
271+
evm_status = INTEGRITY_FAIL;
272+
goto out;
273+
}
274+
261275
digest.hdr.algo = hdr->hash_algo;
262276
rc = evm_calc_hash(dentry, xattr_name, xattr_value,
263277
xattr_value_len, xattr_data->type, &digest,

0 commit comments

Comments
 (0)