aboutsummaryrefslogtreecommitdiffstats
path: root/security/integrity/digsig.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-12-14 23:36:37 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2014-12-14 23:36:37 -0500
commit67e2c3883828b39548cee2091b36656787775d95 (patch)
tree975a0f546a604beda30d4ede34f8e9cca9a88b71 /security/integrity/digsig.c
parent6ae840e7cc4be0be3aa40d9f67c35c75cfc67d83 (diff)
parentb2d1965dcea148100ffc4e7199470bf5fad13871 (diff)
Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security
Pull security layer updates from James Morris: "In terms of changes, there's general maintenance to the Smack, SELinux, and integrity code. The IMA code adds a new kconfig option, IMA_APPRAISE_SIGNED_INIT, which allows IMA appraisal to require signatures. Support for reading keys from rootfs before init is call is also added" * 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security: (23 commits) selinux: Remove security_ops extern security: smack: fix out-of-bounds access in smk_parse_smack() VFS: refactor vfs_read() ima: require signature based appraisal integrity: provide a hook to load keys when rootfs is ready ima: load x509 certificate from the kernel integrity: provide a function to load x509 certificate from the kernel integrity: define a new function integrity_read_file() Security: smack: replace kzalloc with kmem_cache for inode_smack Smack: Lock mode for the floor and hat labels ima: added support for new kernel cmdline parameter ima_template_fmt ima: allocate field pointers array on demand in template_desc_init_fields() ima: don't allocate a copy of template_fmt in template_desc_init_fields() ima: display template format in meas. list if template name length is zero ima: added error messages to template-related functions ima: use atomic bit operations to protect policy update interface ima: ignore empty and with whitespaces policy lines ima: no need to allocate entry for comment ima: report policy load status ima: use path names cache ...
Diffstat (limited to 'security/integrity/digsig.c')
-rw-r--r--security/integrity/digsig.c38
1 files changed, 36 insertions, 2 deletions
diff --git a/security/integrity/digsig.c b/security/integrity/digsig.c
index 8d4fbff8b87c..5e3bd72b299a 100644
--- a/security/integrity/digsig.c
+++ b/security/integrity/digsig.c
@@ -14,7 +14,7 @@
14 14
15#include <linux/err.h> 15#include <linux/err.h>
16#include <linux/sched.h> 16#include <linux/sched.h>
17#include <linux/rbtree.h> 17#include <linux/slab.h>
18#include <linux/cred.h> 18#include <linux/cred.h>
19#include <linux/key-type.h> 19#include <linux/key-type.h>
20#include <linux/digsig.h> 20#include <linux/digsig.h>
@@ -63,7 +63,7 @@ int integrity_digsig_verify(const unsigned int id, const char *sig, int siglen,
63 return -EOPNOTSUPP; 63 return -EOPNOTSUPP;
64} 64}
65 65
66int integrity_init_keyring(const unsigned int id) 66int __init integrity_init_keyring(const unsigned int id)
67{ 67{
68 const struct cred *cred = current_cred(); 68 const struct cred *cred = current_cred();
69 int err = 0; 69 int err = 0;
@@ -84,3 +84,37 @@ int integrity_init_keyring(const unsigned int id)
84 } 84 }
85 return err; 85 return err;
86} 86}
87
88int __init integrity_load_x509(const unsigned int id, char *path)
89{
90 key_ref_t key;
91 char *data;
92 int rc;
93
94 if (!keyring[id])
95 return -EINVAL;
96
97 rc = integrity_read_file(path, &data);
98 if (rc < 0)
99 return rc;
100
101 key = key_create_or_update(make_key_ref(keyring[id], 1),
102 "asymmetric",
103 NULL,
104 data,
105 rc,
106 ((KEY_POS_ALL & ~KEY_POS_SETATTR) |
107 KEY_USR_VIEW | KEY_USR_READ),
108 KEY_ALLOC_NOT_IN_QUOTA | KEY_ALLOC_TRUSTED);
109 if (IS_ERR(key)) {
110 rc = PTR_ERR(key);
111 pr_err("Problem loading X.509 certificate (%d): %s\n",
112 rc, path);
113 } else {
114 pr_notice("Loaded X.509 cert '%s': %s\n",
115 key_ref_to_ptr(key)->description, path);
116 key_ref_put(key);
117 }
118 kfree(data);
119 return 0;
120}