aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/kernel-parameters.txt2
-rw-r--r--crypto/asymmetric_keys/x509_public_key.c9
-rw-r--r--include/linux/key.h1
-rw-r--r--kernel/system_keyring.c1
4 files changed, 9 insertions, 4 deletions
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index bdb193afe176..90c12c591168 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -569,7 +569,7 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
569 ca_keys= [KEYS] This parameter identifies a specific key(s) on 569 ca_keys= [KEYS] This parameter identifies a specific key(s) on
570 the system trusted keyring to be used for certificate 570 the system trusted keyring to be used for certificate
571 trust validation. 571 trust validation.
572 format: id:<keyid> 572 format: { id:<keyid> | builtin }
573 573
574 ccw_timeout_log [S390] 574 ccw_timeout_log [S390]
575 See Documentation/s390/CommonIO for details. 575 See Documentation/s390/CommonIO for details.
diff --git a/crypto/asymmetric_keys/x509_public_key.c b/crypto/asymmetric_keys/x509_public_key.c
index d376195e1d08..927ce755ff67 100644
--- a/crypto/asymmetric_keys/x509_public_key.c
+++ b/crypto/asymmetric_keys/x509_public_key.c
@@ -24,6 +24,7 @@
24#include "public_key.h" 24#include "public_key.h"
25#include "x509_parser.h" 25#include "x509_parser.h"
26 26
27static bool use_builtin_keys;
27static char *ca_keyid; 28static char *ca_keyid;
28 29
29#ifndef MODULE 30#ifndef MODULE
@@ -34,6 +35,8 @@ static int __init ca_keys_setup(char *str)
34 35
35 if (strncmp(str, "id:", 3) == 0) 36 if (strncmp(str, "id:", 3) == 0)
36 ca_keyid = str; /* owner key 'id:xxxxxx' */ 37 ca_keyid = str; /* owner key 'id:xxxxxx' */
38 else if (strcmp(str, "builtin") == 0)
39 use_builtin_keys = true;
37 40
38 return 1; 41 return 1;
39} 42}
@@ -180,7 +183,6 @@ EXPORT_SYMBOL_GPL(x509_check_signature);
180static int x509_validate_trust(struct x509_certificate *cert, 183static int x509_validate_trust(struct x509_certificate *cert,
181 struct key *trust_keyring) 184 struct key *trust_keyring)
182{ 185{
183 const struct public_key *pk;
184 struct key *key; 186 struct key *key;
185 int ret = 1; 187 int ret = 1;
186 188
@@ -195,8 +197,9 @@ static int x509_validate_trust(struct x509_certificate *cert,
195 cert->authority, 197 cert->authority,
196 strlen(cert->authority)); 198 strlen(cert->authority));
197 if (!IS_ERR(key)) { 199 if (!IS_ERR(key)) {
198 pk = key->payload.data; 200 if (!use_builtin_keys
199 ret = x509_check_signature(pk, cert); 201 || test_bit(KEY_FLAG_BUILTIN, &key->flags))
202 ret = x509_check_signature(key->payload.data, cert);
200 key_put(key); 203 key_put(key);
201 } 204 }
202 return ret; 205 return ret;
diff --git a/include/linux/key.h b/include/linux/key.h
index 017b0826642f..65316f7ae794 100644
--- a/include/linux/key.h
+++ b/include/linux/key.h
@@ -170,6 +170,7 @@ struct key {
170#define KEY_FLAG_INVALIDATED 7 /* set if key has been invalidated */ 170#define KEY_FLAG_INVALIDATED 7 /* set if key has been invalidated */
171#define KEY_FLAG_TRUSTED 8 /* set if key is trusted */ 171#define KEY_FLAG_TRUSTED 8 /* set if key is trusted */
172#define KEY_FLAG_TRUSTED_ONLY 9 /* set if keyring only accepts links to trusted keys */ 172#define KEY_FLAG_TRUSTED_ONLY 9 /* set if keyring only accepts links to trusted keys */
173#define KEY_FLAG_BUILTIN 10 /* set if key is builtin */
173 174
174 /* the key type and key description string 175 /* the key type and key description string
175 * - the desc is used to match a key against search criteria 176 * - the desc is used to match a key against search criteria
diff --git a/kernel/system_keyring.c b/kernel/system_keyring.c
index 52ebc70263f4..875f64e8935b 100644
--- a/kernel/system_keyring.c
+++ b/kernel/system_keyring.c
@@ -89,6 +89,7 @@ static __init int load_system_certificate_list(void)
89 pr_err("Problem loading in-kernel X.509 certificate (%ld)\n", 89 pr_err("Problem loading in-kernel X.509 certificate (%ld)\n",
90 PTR_ERR(key)); 90 PTR_ERR(key));
91 } else { 91 } else {
92 set_bit(KEY_FLAG_BUILTIN, &key_ref_to_ptr(key)->flags);
92 pr_notice("Loaded X.509 cert '%s'\n", 93 pr_notice("Loaded X.509 cert '%s'\n",
93 key_ref_to_ptr(key)->description); 94 key_ref_to_ptr(key)->description);
94 key_ref_put(key); 95 key_ref_put(key);