Skip to content

Commit 2fb1c9a

Browse files
author
Mimi Zohar
committed
evm: prohibit userspace writing 'security.evm' HMAC value
Calculating the 'security.evm' HMAC value requires access to the EVM encrypted key. Only the kernel should have access to it. This patch prevents userspace tools(eg. setfattr, cp --preserve=xattr) from setting/modifying the 'security.evm' HMAC value directly. Signed-off-by: Mimi Zohar <[email protected]> Cc: <[email protected]>
1 parent 14503eb commit 2fb1c9a

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

security/integrity/evm/evm_main.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,12 +300,20 @@ static int evm_protect_xattr(struct dentry *dentry, const char *xattr_name,
300300
* @xattr_value: pointer to the new extended attribute value
301301
* @xattr_value_len: pointer to the new extended attribute value length
302302
*
303-
* Updating 'security.evm' requires CAP_SYS_ADMIN privileges and that
304-
* the current value is valid.
303+
* Before allowing the 'security.evm' protected xattr to be updated,
304+
* verify the existing value is valid. As only the kernel should have
305+
* access to the EVM encrypted key needed to calculate the HMAC, prevent
306+
* userspace from writing HMAC value. Writing 'security.evm' requires
307+
* requires CAP_SYS_ADMIN privileges.
305308
*/
306309
int evm_inode_setxattr(struct dentry *dentry, const char *xattr_name,
307310
const void *xattr_value, size_t xattr_value_len)
308311
{
312+
const struct evm_ima_xattr_data *xattr_data = xattr_value;
313+
314+
if ((strcmp(xattr_name, XATTR_NAME_EVM) == 0)
315+
&& (xattr_data->type == EVM_XATTR_HMAC))
316+
return -EPERM;
309317
return evm_protect_xattr(dentry, xattr_name, xattr_value,
310318
xattr_value_len);
311319
}

0 commit comments

Comments
 (0)