Skip to content

Commit

Permalink
Merge branch 'fixes-v5.0-rc7' of git://git.kernel.org/pub/scm/linux/k…
Browse files Browse the repository at this point in the history
…ernel/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
  • Loading branch information
Linus Torvalds committed Feb 23, 2019
2 parents ef4edb3 + ede0fa9 commit cb268d8
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion include/keys/user-type.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
struct user_key_payload {
struct rcu_head rcu; /* RCU destructor */
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;
Expand Down
4 changes: 1 addition & 3 deletions security/keys/keyring.c
Original file line number Diff line number Diff line change
Expand Up @@ -661,9 +661,6 @@ static bool search_nested_keyrings(struct key *keyring,
BUG_ON((ctx->flags & STATE_CHECKS) == 0 ||
(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
* and whether it is valid or not.
*/
Expand Down Expand Up @@ -914,6 +911,7 @@ key_ref_t keyring_search(key_ref_t keyring,
struct keyring_search_context ctx = {
.index_key.type = type,
.index_key.description = description,
.index_key.desc_len = strlen(description),
.cred = current_cred(),
.match_data.cmp = key_default_cmp,
.match_data.raw_data = description,
Expand Down
3 changes: 1 addition & 2 deletions security/keys/proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,7 @@ static int proc_keys_show(struct seq_file *m, void *v)
int rc;

struct keyring_search_context ctx = {
.index_key.type = key->type,
.index_key.description = key->description,
.index_key = key->index_key,
.cred = m->file->f_cred,
.match_data.cmp = lookup_user_key_possessed,
.match_data.raw_data = key,
Expand Down
1 change: 1 addition & 0 deletions security/keys/request_key.c
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,7 @@ struct key *request_key_and_link(struct key_type *type,
struct keyring_search_context ctx = {
.index_key.type = type,
.index_key.description = description,
.index_key.desc_len = strlen(description),
.cred = current_cred(),
.match_data.cmp = key_default_cmp,
.match_data.raw_data = description,
Expand Down
2 changes: 1 addition & 1 deletion security/keys/request_key_auth.c
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ struct key *key_get_instantiation_authkey(key_serial_t target_id)
struct key *authkey;
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);

Expand Down

0 comments on commit cb268d8

Please sign in to comment.