Skip to content

Commit cb268d8

Browse files
committed
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
2 parents ef4edb3 + ede0fa9 commit cb268d8

File tree

5 files changed

+5
-7
lines changed

5 files changed

+5
-7
lines changed

include/keys/user-type.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
struct user_key_payload {
3232
struct rcu_head rcu; /* RCU destructor */
3333
unsigned short datalen; /* length of this data */
34-
char data[0]; /* actual data */
34+
char data[0] __aligned(__alignof__(u64)); /* actual data */
3535
};
3636

3737
extern struct key_type key_type_user;

security/keys/keyring.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -661,9 +661,6 @@ static bool search_nested_keyrings(struct key *keyring,
661661
BUG_ON((ctx->flags & STATE_CHECKS) == 0 ||
662662
(ctx->flags & STATE_CHECKS) == STATE_CHECKS);
663663

664-
if (ctx->index_key.description)
665-
ctx->index_key.desc_len = strlen(ctx->index_key.description);
666-
667664
/* Check to see if this top-level keyring is what we are looking for
668665
* and whether it is valid or not.
669666
*/
@@ -914,6 +911,7 @@ key_ref_t keyring_search(key_ref_t keyring,
914911
struct keyring_search_context ctx = {
915912
.index_key.type = type,
916913
.index_key.description = description,
914+
.index_key.desc_len = strlen(description),
917915
.cred = current_cred(),
918916
.match_data.cmp = key_default_cmp,
919917
.match_data.raw_data = description,

security/keys/proc.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,7 @@ static int proc_keys_show(struct seq_file *m, void *v)
165165
int rc;
166166

167167
struct keyring_search_context ctx = {
168-
.index_key.type = key->type,
169-
.index_key.description = key->description,
168+
.index_key = key->index_key,
170169
.cred = m->file->f_cred,
171170
.match_data.cmp = lookup_user_key_possessed,
172171
.match_data.raw_data = key,

security/keys/request_key.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,7 @@ struct key *request_key_and_link(struct key_type *type,
531531
struct keyring_search_context ctx = {
532532
.index_key.type = type,
533533
.index_key.description = description,
534+
.index_key.desc_len = strlen(description),
534535
.cred = current_cred(),
535536
.match_data.cmp = key_default_cmp,
536537
.match_data.raw_data = description,

security/keys/request_key_auth.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ struct key *key_get_instantiation_authkey(key_serial_t target_id)
247247
struct key *authkey;
248248
key_ref_t authkey_ref;
249249

250-
sprintf(description, "%x", target_id);
250+
ctx.index_key.desc_len = sprintf(description, "%x", target_id);
251251

252252
authkey_ref = search_process_keyrings(&ctx);
253253

0 commit comments

Comments
 (0)