OSDN Git Service

KEYS: reset parent each time before searching key_user_tree
authorEric Biggers <ebiggers@google.com>
Mon, 18 Sep 2017 18:37:39 +0000 (11:37 -0700)
committerDavid Howells <dhowells@redhat.com>
Mon, 25 Sep 2017 14:19:57 +0000 (15:19 +0100)
commit8f674565d405a8c0b36ee531849df87f43e72ed5
tree70918506b36dfac48aaab5800f09c3581ffc4581
parent37863c43b2c6464f252862bf2e9768264e961678
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>
security/keys/key.c