Skip to content

Commit 8f67456

Browse files
ebiggersdhowells
authored andcommitted
KEYS: reset parent each time before searching key_user_tree
In key_user_lookup(), if there is no key_user for the given uid, we drop key_user_lock, allocate a new key_user, and search the tree again. But we failed to set 'parent' to NULL at the beginning of the second search. If the tree were to be empty for the second search, the insertion would be done with an invalid 'parent', scribbling over freed memory. Fortunately this can't actually happen currently because the tree always contains at least the root_key_user. But it still should be fixed to make the code more robust. Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: David Howells <dhowells@redhat.com>
1 parent 37863c4 commit 8f67456

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎security/keys/key.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ void __key_check(const struct key *key)
5454
struct key_user *key_user_lookup(kuid_t uid)
5555
{
5656
struct key_user *candidate = NULL, *user;
57-
struct rb_node *parent = NULL;
58-
struct rb_node **p;
57+
struct rb_node *parent, **p;
5958

6059
try_again:
60+
parent = NULL;
6161
p = &key_user_tree.rb_node;
6262
spin_lock(&key_user_lock);
6363

0 commit comments

Comments
 (0)