aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/security/keys.txt2
-rw-r--r--kernel/Makefile2
-rw-r--r--scripts/asn1_compiler.c30
-rw-r--r--security/keys/Kconfig18
-rw-r--r--security/keys/proc.c8
5 files changed, 20 insertions, 40 deletions
diff --git a/Documentation/security/keys.txt b/Documentation/security/keys.txt
index 821c936e1a63..c9e7f4f223a5 100644
--- a/Documentation/security/keys.txt
+++ b/Documentation/security/keys.txt
@@ -323,8 +323,6 @@ about the status of the key service:
323 U Under construction by callback to userspace 323 U Under construction by callback to userspace
324 N Negative key 324 N Negative key
325 325
326 This file must be enabled at kernel configuration time as it allows anyone
327 to list the keys database.
328 326
329 (*) /proc/key-users 327 (*) /proc/key-users
330 328
diff --git a/kernel/Makefile b/kernel/Makefile
index a59481a3fa6c..23e17a7e7a63 100644
--- a/kernel/Makefile
+++ b/kernel/Makefile
@@ -142,7 +142,7 @@ endif
142kernel/system_certificates.o: $(obj)/x509_certificate_list 142kernel/system_certificates.o: $(obj)/x509_certificate_list
143 143
144quiet_cmd_x509certs = CERTS $@ 144quiet_cmd_x509certs = CERTS $@
145 cmd_x509certs = cat $(X509_CERTIFICATES) /dev/null >$@ $(foreach X509,$(X509_CERTIFICATES),; echo " - Including cert $(X509)") 145 cmd_x509certs = cat $(X509_CERTIFICATES) /dev/null >$@ $(foreach X509,$(X509_CERTIFICATES),; $(kecho) " - Including cert $(X509)")
146 146
147targets += $(obj)/x509_certificate_list 147targets += $(obj)/x509_certificate_list
148$(obj)/x509_certificate_list: $(X509_CERTIFICATES) $(obj)/.x509.list 148$(obj)/x509_certificate_list: $(X509_CERTIFICATES) $(obj)/.x509.list
diff --git a/scripts/asn1_compiler.c b/scripts/asn1_compiler.c
index 91c4117637ae..7750e9c31483 100644
--- a/scripts/asn1_compiler.c
+++ b/scripts/asn1_compiler.c
@@ -311,6 +311,9 @@ struct token {
311 311
312static struct token *token_list; 312static struct token *token_list;
313static unsigned nr_tokens; 313static unsigned nr_tokens;
314static _Bool verbose;
315
316#define debug(fmt, ...) do { if (verbose) printf(fmt, ## __VA_ARGS__); } while (0)
314 317
315static int directive_compare(const void *_key, const void *_pdir) 318static int directive_compare(const void *_key, const void *_pdir)
316{ 319{
@@ -322,21 +325,21 @@ static int directive_compare(const void *_key, const void *_pdir)
322 dlen = strlen(dir); 325 dlen = strlen(dir);
323 clen = (dlen < token->size) ? dlen : token->size; 326 clen = (dlen < token->size) ? dlen : token->size;
324 327
325 //printf("cmp(%*.*s,%s) = ", 328 //debug("cmp(%*.*s,%s) = ",
326 // (int)token->size, (int)token->size, token->value, 329 // (int)token->size, (int)token->size, token->value,
327 // dir); 330 // dir);
328 331
329 val = memcmp(token->value, dir, clen); 332 val = memcmp(token->value, dir, clen);
330 if (val != 0) { 333 if (val != 0) {
331 //printf("%d [cmp]\n", val); 334 //debug("%d [cmp]\n", val);
332 return val; 335 return val;
333 } 336 }
334 337
335 if (dlen == token->size) { 338 if (dlen == token->size) {
336 //printf("0\n"); 339 //debug("0\n");
337 return 0; 340 return 0;
338 } 341 }
339 //printf("%d\n", (int)dlen - (int)token->size); 342 //debug("%d\n", (int)dlen - (int)token->size);
340 return dlen - token->size; /* shorter -> negative */ 343 return dlen - token->size; /* shorter -> negative */
341} 344}
342 345
@@ -515,13 +518,13 @@ static void tokenise(char *buffer, char *end)
515 } 518 }
516 519
517 nr_tokens = tix; 520 nr_tokens = tix;
518 printf("Extracted %u tokens\n", nr_tokens); 521 debug("Extracted %u tokens\n", nr_tokens);
519 522
520#if 0 523#if 0
521 { 524 {
522 int n; 525 int n;
523 for (n = 0; n < nr_tokens; n++) 526 for (n = 0; n < nr_tokens; n++)
524 printf("Token %3u: '%*.*s'\n", 527 debug("Token %3u: '%*.*s'\n",
525 n, 528 n,
526 (int)token_list[n].size, (int)token_list[n].size, 529 (int)token_list[n].size, (int)token_list[n].size,
527 token_list[n].value); 530 token_list[n].value);
@@ -542,6 +545,7 @@ int main(int argc, char **argv)
542 ssize_t readlen; 545 ssize_t readlen;
543 FILE *out, *hdr; 546 FILE *out, *hdr;
544 char *buffer, *p; 547 char *buffer, *p;
548 char *kbuild_verbose;
545 int fd; 549 int fd;
546 550
547 if (argc != 4) { 551 if (argc != 4) {
@@ -550,6 +554,10 @@ int main(int argc, char **argv)
550 exit(2); 554 exit(2);
551 } 555 }
552 556
557 kbuild_verbose = getenv("KBUILD_VERBOSE");
558 if (kbuild_verbose)
559 verbose = atoi(kbuild_verbose);
560
553 filename = argv[1]; 561 filename = argv[1];
554 outputname = argv[2]; 562 outputname = argv[2];
555 headername = argv[3]; 563 headername = argv[3];
@@ -748,11 +756,11 @@ static void build_type_list(void)
748 756
749 qsort(type_index, nr, sizeof(type_index[0]), type_index_compare); 757 qsort(type_index, nr, sizeof(type_index[0]), type_index_compare);
750 758
751 printf("Extracted %u types\n", nr_types); 759 debug("Extracted %u types\n", nr_types);
752#if 0 760#if 0
753 for (n = 0; n < nr_types; n++) { 761 for (n = 0; n < nr_types; n++) {
754 struct type *type = type_index[n]; 762 struct type *type = type_index[n];
755 printf("- %*.*s\n", 763 debug("- %*.*s\n",
756 (int)type->name->size, 764 (int)type->name->size,
757 (int)type->name->size, 765 (int)type->name->size,
758 type->name->value); 766 type->name->value);
@@ -793,7 +801,7 @@ static void parse(void)
793 801
794 } while (type++, !(type->flags & TYPE_STOP_MARKER)); 802 } while (type++, !(type->flags & TYPE_STOP_MARKER));
795 803
796 printf("Extracted %u actions\n", nr_actions); 804 debug("Extracted %u actions\n", nr_actions);
797} 805}
798 806
799static struct element *element_list; 807static struct element *element_list;
@@ -1284,7 +1292,7 @@ static void render(FILE *out, FILE *hdr)
1284 } 1292 }
1285 1293
1286 /* We do two passes - the first one calculates all the offsets */ 1294 /* We do two passes - the first one calculates all the offsets */
1287 printf("Pass 1\n"); 1295 debug("Pass 1\n");
1288 nr_entries = 0; 1296 nr_entries = 0;
1289 root = &type_list[0]; 1297 root = &type_list[0];
1290 render_element(NULL, root->element, NULL); 1298 render_element(NULL, root->element, NULL);
@@ -1295,7 +1303,7 @@ static void render(FILE *out, FILE *hdr)
1295 e->flags &= ~ELEMENT_RENDERED; 1303 e->flags &= ~ELEMENT_RENDERED;
1296 1304
1297 /* And then we actually render */ 1305 /* And then we actually render */
1298 printf("Pass 2\n"); 1306 debug("Pass 2\n");
1299 fprintf(out, "\n"); 1307 fprintf(out, "\n");
1300 fprintf(out, "static const unsigned char %s_machine[] = {\n", 1308 fprintf(out, "static const unsigned char %s_machine[] = {\n",
1301 grammar_name); 1309 grammar_name);
diff --git a/security/keys/Kconfig b/security/keys/Kconfig
index a4f3f8c48d6e..72483b8f1be5 100644
--- a/security/keys/Kconfig
+++ b/security/keys/Kconfig
@@ -80,21 +80,3 @@ config ENCRYPTED_KEYS
80 Userspace only ever sees/stores encrypted blobs. 80 Userspace only ever sees/stores encrypted blobs.
81 81
82 If you are unsure as to whether this is required, answer N. 82 If you are unsure as to whether this is required, answer N.
83
84config KEYS_DEBUG_PROC_KEYS
85 bool "Enable the /proc/keys file by which keys may be viewed"
86 depends on KEYS
87 help
88 This option turns on support for the /proc/keys file - through which
89 can be listed all the keys on the system that are viewable by the
90 reading process.
91
92 The only keys included in the list are those that grant View
93 permission to the reading process whether or not it possesses them.
94 Note that LSM security checks are still performed, and may further
95 filter out keys that the current process is not authorised to view.
96
97 Only key attributes are listed here; key payloads are not included in
98 the resulting table.
99
100 If you are unsure as to whether this is required, answer N.
diff --git a/security/keys/proc.c b/security/keys/proc.c
index 972eeb336b81..f0611a6368cd 100644
--- a/security/keys/proc.c
+++ b/security/keys/proc.c
@@ -18,7 +18,6 @@
18#include <asm/errno.h> 18#include <asm/errno.h>
19#include "internal.h" 19#include "internal.h"
20 20
21#ifdef CONFIG_KEYS_DEBUG_PROC_KEYS
22static int proc_keys_open(struct inode *inode, struct file *file); 21static int proc_keys_open(struct inode *inode, struct file *file);
23static void *proc_keys_start(struct seq_file *p, loff_t *_pos); 22static void *proc_keys_start(struct seq_file *p, loff_t *_pos);
24static void *proc_keys_next(struct seq_file *p, void *v, loff_t *_pos); 23static void *proc_keys_next(struct seq_file *p, void *v, loff_t *_pos);
@@ -38,7 +37,6 @@ static const struct file_operations proc_keys_fops = {
38 .llseek = seq_lseek, 37 .llseek = seq_lseek,
39 .release = seq_release, 38 .release = seq_release,
40}; 39};
41#endif
42 40
43static int proc_key_users_open(struct inode *inode, struct file *file); 41static int proc_key_users_open(struct inode *inode, struct file *file);
44static void *proc_key_users_start(struct seq_file *p, loff_t *_pos); 42static void *proc_key_users_start(struct seq_file *p, loff_t *_pos);
@@ -67,11 +65,9 @@ static int __init key_proc_init(void)
67{ 65{
68 struct proc_dir_entry *p; 66 struct proc_dir_entry *p;
69 67
70#ifdef CONFIG_KEYS_DEBUG_PROC_KEYS
71 p = proc_create("keys", 0, NULL, &proc_keys_fops); 68 p = proc_create("keys", 0, NULL, &proc_keys_fops);
72 if (!p) 69 if (!p)
73 panic("Cannot create /proc/keys\n"); 70 panic("Cannot create /proc/keys\n");
74#endif
75 71
76 p = proc_create("key-users", 0, NULL, &proc_key_users_fops); 72 p = proc_create("key-users", 0, NULL, &proc_key_users_fops);
77 if (!p) 73 if (!p)
@@ -86,8 +82,6 @@ __initcall(key_proc_init);
86 * Implement "/proc/keys" to provide a list of the keys on the system that 82 * Implement "/proc/keys" to provide a list of the keys on the system that
87 * grant View permission to the caller. 83 * grant View permission to the caller.
88 */ 84 */
89#ifdef CONFIG_KEYS_DEBUG_PROC_KEYS
90
91static struct rb_node *key_serial_next(struct seq_file *p, struct rb_node *n) 85static struct rb_node *key_serial_next(struct seq_file *p, struct rb_node *n)
92{ 86{
93 struct user_namespace *user_ns = seq_user_ns(p); 87 struct user_namespace *user_ns = seq_user_ns(p);
@@ -275,8 +269,6 @@ static int proc_keys_show(struct seq_file *m, void *v)
275 return 0; 269 return 0;
276} 270}
277 271
278#endif /* CONFIG_KEYS_DEBUG_PROC_KEYS */
279
280static struct rb_node *__key_user_next(struct user_namespace *user_ns, struct rb_node *n) 272static struct rb_node *__key_user_next(struct user_namespace *user_ns, struct rb_node *n)
281{ 273{
282 while (n) { 274 while (n) {