aboutsummaryrefslogtreecommitdiffstats
path: root/security/integrity/evm/evm_secfs.c
diff options
context:
space:
mode:
authorDmitry Kasatkin <dmitry.kasatkin@huawei.com>2015-10-22 21:26:32 +0300
committerMimi Zohar <zohar@linux.vnet.ibm.com>2015-12-15 08:53:36 -0500
commit7626676320f398980a6bb4490fd58e924c888f6a (patch)
treebb852548419b70be34dc7f32765d70bd94cd8bbb /security/integrity/evm/evm_secfs.c
parentevm: enable EVM when X509 certificate is loaded (diff)
downloadlinux-dev-7626676320f398980a6bb4490fd58e924c888f6a.tar.xz
linux-dev-7626676320f398980a6bb4490fd58e924c888f6a.zip
evm: provide a function to set the EVM key from the kernel
A crypto HW kernel module can possibly initialize the EVM key from the kernel __init code to enable EVM before calling the 'init' process. This patch provides a function evm_set_key() to set the EVM key directly without using the KEY subsystem. Changes in v4: * kernel-doc style for evm_set_key Changes in v3: * error reporting moved to evm_set_key * EVM_INIT_HMAC moved to evm_set_key * added bitop to prevent key setting race Changes in v2: * use size_t for key size instead of signed int * provide EVM_MAX_KEY_SIZE macro in <linux/evm.h> * provide EVM_MIN_KEY_SIZE macro in <linux/evm.h> Signed-off-by: Dmitry Kasatkin <dmitry.kasatkin@huawei.com> Signed-off-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
Diffstat (limited to '')
-rw-r--r--security/integrity/evm/evm_secfs.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/security/integrity/evm/evm_secfs.c b/security/integrity/evm/evm_secfs.c
index 3f775dfea868..c8dccd54d501 100644
--- a/security/integrity/evm/evm_secfs.c
+++ b/security/integrity/evm/evm_secfs.c
@@ -62,7 +62,7 @@ static ssize_t evm_write_key(struct file *file, const char __user *buf,
size_t count, loff_t *ppos)
{
char temp[80];
- int i, error;
+ int i;
if (!capable(CAP_SYS_ADMIN) || (evm_initialized & EVM_INIT_HMAC))
return -EPERM;
@@ -78,12 +78,8 @@ static ssize_t evm_write_key(struct file *file, const char __user *buf,
if ((sscanf(temp, "%d", &i) != 1) || (i != 1))
return -EINVAL;
- error = evm_init_key();
- if (!error) {
- evm_initialized |= EVM_INIT_HMAC;
- pr_info("initialized\n");
- } else
- pr_err("initialization failed\n");
+ evm_init_key();
+
return count;
}