Skip to content

Commit

Permalink
Merge branch 'keys-fixes' of git://git.kernel.org/pub/scm/linux/kerne…
Browse files Browse the repository at this point in the history
…l/git/dhowells/linux-fs

Pull key handling fixes from David Howells:
 "Here are two patches, the first of which at least should go upstream
  immediately:

  (1) Prevent a user-triggerable crash in the keyrings destructor when a
      negatively instantiated keyring is garbage collected.  I have also
      seen this triggered for user type keys.

  (2) Prevent the user from using requesting that a keyring be created
      and instantiated through an upcall.  Doing so is probably safe
      since the keyring type ignores the arguments to its instantiation
      function - but we probably shouldn't let keyrings be created in
      this manner"

* 'keys-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs:
  KEYS: Don't permit request_key() to construct a new keyring
  KEYS: Fix crash when attempt to garbage collect an uninstantiated keyring
  • Loading branch information
Linus Torvalds committed Oct 20, 2015
2 parents 1099f86 + 911b79c commit ce1fad2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 4 additions & 2 deletions security/keys/gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,10 @@ static noinline void key_gc_unused_keys(struct list_head *keys)
kdebug("- %u", key->serial);
key_check(key);

/* Throw away the key data */
if (key->type->destroy)
/* Throw away the key data if the key is instantiated */
if (test_bit(KEY_FLAG_INSTANTIATED, &key->flags) &&
!test_bit(KEY_FLAG_NEGATIVE, &key->flags) &&
key->type->destroy)
key->type->destroy(key);

security_key_free(key);
Expand Down
3 changes: 3 additions & 0 deletions security/keys/request_key.c
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,9 @@ static struct key *construct_key_and_link(struct keyring_search_context *ctx,

kenter("");

if (ctx->index_key.type == &key_type_keyring)
return ERR_PTR(-EPERM);

user = key_user_lookup(current_fsuid());
if (!user)
return ERR_PTR(-ENOMEM);
Expand Down

0 comments on commit ce1fad2

Please sign in to comment.