Merge branch ‘fixes-v5.0-rc7’ of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security [Linux 5.0]

Merge branch ‘fixes-v5.0-rc7’ of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security [Linux 5.0]

This Linux kernel change "Merge branch ‘fixes-v5.0-rc7’ of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security" is included in the Linux 5.0 release. This change is authored by Linus Torvalds <torvalds [at] linux-foundation.org> on Fri Feb 22 17:48:50 2019 -0800. The commit for this change in Linux stable tree is cb268d8 (patch). Other info about this change: Merge: ef4edb3 ede0fa9

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

There is no are 0 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 security/keys/keyring.c          | 4 +---
 security/keys/proc.c             | 3 +--
 security/keys/request_key.c      | 1 +
 security/keys/request_key_auth.c | 2 +-
 4 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/security/keys/keyring.c b/security/keys/keyring.c
index eadebb92..f81372f 100644
--- a/security/keys/keyring.c
+++ b/security/keys/keyring.c
@@ -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.
     */
@@ -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,
diff --git a/security/keys/proc.c b/security/keys/proc.c
index d2b8020..78ac305 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)
    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,
diff --git a/security/keys/request_key.c b/security/keys/request_key.c
index 3f56a31..7a0c6b6 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,
    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,
diff --git a/security/keys/request_key_auth.c b/security/keys/request_key_auth.c
index afc304e..bda6201 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)
    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);

Leave a Reply

Your email address will not be published. Required fields are marked *