Skip to content

Commit

Permalink
[PATCH] Destruction of failed keyring oopses
Browse files Browse the repository at this point in the history
The attached patch makes sure that a keyring that failed to instantiate
properly is destroyed without oopsing [CAN-2005-2099].

The problem occurs in three stages:

 (1) The key allocator initialises the type-specific data to all zeroes. In
     the case of a keyring, this will become a link in the keyring name list
     when the keyring is instantiated.

 (2) If a user (any user) attempts to add a keyring with anything other than
     an empty payload, the keyring instantiation function will fail with an
     error and won't add the keyring to the name list.

 (3) The keyring's destructor then sees that the keyring has a description
     (name) and tries to remove the keyring from the name list, which oopses
     because the link pointers are both zero.

This bug permits any user to take down a box trivially.

Signed-Off-By: David Howells <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
dhowells authored and Linus Torvalds committed Aug 4, 2005
1 parent bcf945d commit 94efe72
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion security/keys/keyring.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,11 @@ static void keyring_destroy(struct key *keyring)

if (keyring->description) {
write_lock(&keyring_name_lock);
list_del(&keyring->type_data.link);

if (keyring->type_data.link.next != NULL &&
!list_empty(&keyring->type_data.link))
list_del(&keyring->type_data.link);

write_unlock(&keyring_name_lock);
}

Expand Down

0 comments on commit 94efe72

Please sign in to comment.