aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2019-02-22 20:48:50 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2019-02-22 20:48:50 -0500
commitcb268d806972c76c34e5d74343fb6064cd722c7c (patch)
treeb51d3f5c0431da9b15c65736fe67f9d27e7aca93
parentef4edb3ed830cbbb443de9906b8cf16dc0653a74 (diff)
parentede0fa98a900e657d1fcd80b50920efc896c1a4c (diff)
Merge branch 'fixes-v5.0-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security
Pull keys fixes from James Morris: "Two fixes from Eric Biggers" * 'fixes-v5.0-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security: KEYS: always initialize keyring_index_key::desc_len KEYS: user: Align the payload buffer
-rw-r--r--include/keys/user-type.h2
-rw-r--r--security/keys/keyring.c4
-rw-r--r--security/keys/proc.c3
-rw-r--r--security/keys/request_key.c1
-rw-r--r--security/keys/request_key_auth.c2
5 files changed, 5 insertions, 7 deletions
diff --git a/include/keys/user-type.h b/include/keys/user-type.h
index e098cbe27db5..12babe991594 100644
--- a/include/keys/user-type.h
+++ b/include/keys/user-type.h
@@ -31,7 +31,7 @@
31struct user_key_payload { 31struct user_key_payload {
32 struct rcu_head rcu; /* RCU destructor */ 32 struct rcu_head rcu; /* RCU destructor */
33 unsigned short datalen; /* length of this data */ 33 unsigned short datalen; /* length of this data */
34 char data[0]; /* actual data */ 34 char data[0] __aligned(__alignof__(u64)); /* actual data */
35}; 35};
36 36
37extern struct key_type key_type_user; 37extern struct key_type key_type_user;
diff --git a/security/keys/keyring.c b/security/keys/keyring.c
index eadebb92986a..f81372f53dd7 100644
--- a/security/keys/keyring.c
+++ b/security/keys/keyring.c
@@ -661,9 +661,6 @@ static bool search_nested_keyrings(struct key *keyring,
661 BUG_ON((ctx->flags & STATE_CHECKS) == 0 || 661 BUG_ON((ctx->flags & STATE_CHECKS) == 0 ||
662 (ctx->flags & STATE_CHECKS) == STATE_CHECKS); 662 (ctx->flags & STATE_CHECKS) == STATE_CHECKS);
663 663
664 if (ctx->index_key.description)
665 ctx->index_key.desc_len = strlen(ctx->index_key.description);
666
667 /* Check to see if this top-level keyring is what we are looking for 664 /* Check to see if this top-level keyring is what we are looking for
668 * and whether it is valid or not. 665 * and whether it is valid or not.
669 */ 666 */
@@ -914,6 +911,7 @@ key_ref_t keyring_search(key_ref_t keyring,
914 struct keyring_search_context ctx = { 911 struct keyring_search_context ctx = {
915 .index_key.type = type, 912 .index_key.type = type,
916 .index_key.description = description, 913 .index_key.description = description,
914 .index_key.desc_len = strlen(description),
917 .cred = current_cred(), 915 .cred = current_cred(),
918 .match_data.cmp = key_default_cmp, 916 .match_data.cmp = key_default_cmp,
919 .match_data.raw_data = description, 917 .match_data.raw_data = description,
diff --git a/security/keys/proc.c b/security/keys/proc.c
index d2b802072693..78ac305d715e 100644
--- a/security/keys/proc.c
+++ b/security/keys/proc.c
@@ -165,8 +165,7 @@ static int proc_keys_show(struct seq_file *m, void *v)
165 int rc; 165 int rc;
166 166
167 struct keyring_search_context ctx = { 167 struct keyring_search_context ctx = {
168 .index_key.type = key->type, 168 .index_key = key->index_key,
169 .index_key.description = key->description,
170 .cred = m->file->f_cred, 169 .cred = m->file->f_cred,
171 .match_data.cmp = lookup_user_key_possessed, 170 .match_data.cmp = lookup_user_key_possessed,
172 .match_data.raw_data = key, 171 .match_data.raw_data = key,
diff --git a/security/keys/request_key.c b/security/keys/request_key.c
index 3f56a312dd35..7a0c6b666ff0 100644
--- a/security/keys/request_key.c
+++ b/security/keys/request_key.c
@@ -531,6 +531,7 @@ struct key *request_key_and_link(struct key_type *type,
531 struct keyring_search_context ctx = { 531 struct keyring_search_context ctx = {
532 .index_key.type = type, 532 .index_key.type = type,
533 .index_key.description = description, 533 .index_key.description = description,
534 .index_key.desc_len = strlen(description),
534 .cred = current_cred(), 535 .cred = current_cred(),
535 .match_data.cmp = key_default_cmp, 536 .match_data.cmp = key_default_cmp,
536 .match_data.raw_data = description, 537 .match_data.raw_data = description,
diff --git a/security/keys/request_key_auth.c b/security/keys/request_key_auth.c
index afc304e8b61e..bda6201c6c45 100644
--- a/security/keys/request_key_auth.c
+++ b/security/keys/request_key_auth.c
@@ -247,7 +247,7 @@ struct key *key_get_instantiation_authkey(key_serial_t target_id)
247 struct key *authkey; 247 struct key *authkey;
248 key_ref_t authkey_ref; 248 key_ref_t authkey_ref;
249 249
250 sprintf(description, "%x", target_id); 250 ctx.index_key.desc_len = sprintf(description, "%x", target_id);
251 251
252 authkey_ref = search_process_keyrings(&ctx); 252 authkey_ref = search_process_keyrings(&ctx);
253 253