]> git.baikalelectronics.ru Git - kernel.git/commit
keys: Fix request_key() cache
authorDavid Howells <dhowells@redhat.com>
Tue, 14 Jan 2020 16:06:14 +0000 (16:06 +0000)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 14 Jan 2020 17:40:06 +0000 (09:40 -0800)
commit2687ace1645679106d152c1536e8ae7f9e445ab0
tree4a5c150198cfdde4c07e4cfe55995c5cd51830df
parentda51f7c940a97468f288729874efa036e4ae2815
keys: Fix request_key() cache

When the key cached by request_key() and co.  is cleaned up on exit(),
the code looks in the wrong task_struct, and so clears the wrong cache.
This leads to anomalies in key refcounting when doing, say, a kernel
build on an afs volume, that then trigger kasan to report a
use-after-free when the key is viewed in /proc/keys.

Fix this by making exit_creds() look in the passed-in task_struct rather
than in current (the task_struct cleanup code is deferred by RCU and
potentially run in another task).

Fixes: 63921fb53432 ("keys: Cache result of request_key*() temporarily in task_struct")
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
kernel/cred.c