Commit cb268d80 authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'fixes-v5.0-rc7' of...

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
parents ef4edb3e ede0fa98
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
struct user_key_payload { struct user_key_payload {
struct rcu_head rcu; /* RCU destructor */ struct rcu_head rcu; /* RCU destructor */
unsigned short datalen; /* length of this data */ unsigned short datalen; /* length of this data */
char data[0]; /* actual data */ char data[0] __aligned(__alignof__(u64)); /* actual data */
}; };
extern struct key_type key_type_user; extern struct key_type key_type_user;
......
...@@ -661,9 +661,6 @@ static bool search_nested_keyrings(struct key *keyring, ...@@ -661,9 +661,6 @@ static bool search_nested_keyrings(struct key *keyring,
BUG_ON((ctx->flags & STATE_CHECKS) == 0 || BUG_ON((ctx->flags & STATE_CHECKS) == 0 ||
(ctx->flags & STATE_CHECKS) == STATE_CHECKS); (ctx->flags & STATE_CHECKS) == STATE_CHECKS);
if (ctx->index_key.description)
ctx->index_key.desc_len = strlen(ctx->index_key.description);
/* Check to see if this top-level keyring is what we are looking for /* Check to see if this top-level keyring is what we are looking for
* and whether it is valid or not. * and whether it is valid or not.
*/ */
...@@ -914,6 +911,7 @@ key_ref_t keyring_search(key_ref_t keyring, ...@@ -914,6 +911,7 @@ key_ref_t keyring_search(key_ref_t keyring,
struct keyring_search_context ctx = { struct keyring_search_context ctx = {
.index_key.type = type, .index_key.type = type,
.index_key.description = description, .index_key.description = description,
.index_key.desc_len = strlen(description),
.cred = current_cred(), .cred = current_cred(),
.match_data.cmp = key_default_cmp, .match_data.cmp = key_default_cmp,
.match_data.raw_data = description, .match_data.raw_data = description,
......
...@@ -165,8 +165,7 @@ static int proc_keys_show(struct seq_file *m, void *v) ...@@ -165,8 +165,7 @@ static int proc_keys_show(struct seq_file *m, void *v)
int rc; int rc;
struct keyring_search_context ctx = { struct keyring_search_context ctx = {
.index_key.type = key->type, .index_key = key->index_key,
.index_key.description = key->description,
.cred = m->file->f_cred, .cred = m->file->f_cred,
.match_data.cmp = lookup_user_key_possessed, .match_data.cmp = lookup_user_key_possessed,
.match_data.raw_data = key, .match_data.raw_data = key,
......
...@@ -531,6 +531,7 @@ struct key *request_key_and_link(struct key_type *type, ...@@ -531,6 +531,7 @@ struct key *request_key_and_link(struct key_type *type,
struct keyring_search_context ctx = { struct keyring_search_context ctx = {
.index_key.type = type, .index_key.type = type,
.index_key.description = description, .index_key.description = description,
.index_key.desc_len = strlen(description),
.cred = current_cred(), .cred = current_cred(),
.match_data.cmp = key_default_cmp, .match_data.cmp = key_default_cmp,
.match_data.raw_data = description, .match_data.raw_data = description,
......
...@@ -247,7 +247,7 @@ struct key *key_get_instantiation_authkey(key_serial_t target_id) ...@@ -247,7 +247,7 @@ struct key *key_get_instantiation_authkey(key_serial_t target_id)
struct key *authkey; struct key *authkey;
key_ref_t authkey_ref; key_ref_t authkey_ref;
sprintf(description, "%x", target_id); ctx.index_key.desc_len = sprintf(description, "%x", target_id);
authkey_ref = search_process_keyrings(&ctx); authkey_ref = search_process_keyrings(&ctx);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment