android_kernel_asus_sm8350/security/keys
David Howells 97674f4cd0 keys: Do not cache key in task struct if key is requested from kernel thread
[ Upstream commit 47f9e4c924025c5be87959d3335e66fcbb7f6b5c ]

The key which gets cached in task structure from a kernel thread does not
get invalidated even after expiry.  Due to which, a new key request from
kernel thread will be served with the cached key if it's present in task
struct irrespective of the key validity.  The change is to not cache key in
task_struct when key requested from kernel thread so that kernel thread
gets a valid key on every key request.

The problem has been seen with the cifs module doing DNS lookups from a
kernel thread and the results getting pinned by being attached to that
kernel thread's cache - and thus not something that can be easily got rid
of.  The cache would ordinarily be cleared by notify-resume, but kernel
threads don't do that.

This isn't seen with AFS because AFS is doing request_key() within the
kernel half of a user thread - which will do notify-resume.

Fixes: 7743c48e54 ("keys: Cache result of request_key*() temporarily in task_struct")
Signed-off-by: Bharath SM <bharathsm@microsoft.com>
Signed-off-by: David Howells <dhowells@redhat.com>
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
cc: Shyam Prasad N <nspmangalore@gmail.com>
cc: Steve French <smfrench@gmail.com>
cc: keyrings@vger.kernel.org
cc: linux-cifs@vger.kernel.org
cc: linux-fsdevel@vger.kernel.org
Link: https://lore.kernel.org/r/CAGypqWw951d=zYRbdgNR4snUDvJhWL=q3=WOyh7HhSJupjz2vA@mail.gmail.com/
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-04-05 11:16:37 +02:00
..
encrypted-keys KEYS: Don't write out to userspace while holding key semaphore 2020-04-23 10:36:45 +02:00
big_key.c KEYS: Don't write out to userspace while holding key semaphore 2020-04-23 10:36:45 +02:00
compat_dh.c
compat.c
dh.c
gc.c
internal.h mm: add kvfree_sensitive() for freeing sensitive data objects 2020-06-17 16:40:23 +02:00
Kconfig
key.c certs: Fix blacklist flag type confusion 2021-03-04 10:26:29 +01:00
keyctl_pkey.c KEYS: fix length validation in keyctl_pkey_params_get_2() 2022-04-15 14:17:58 +02:00
keyctl.c mm: add kvfree_sensitive() for freeing sensitive data objects 2020-06-17 16:40:23 +02:00
keyring.c KEYS: Don't write out to userspace while holding key semaphore 2020-04-23 10:36:45 +02:00
Makefile
permission.c
persistent.c
proc.c keys: Fix proc_keys_next to increase position index 2020-04-21 09:04:58 +02:00
process_keys.c
request_key_auth.c KEYS: Don't write out to userspace while holding key semaphore 2020-04-23 10:36:45 +02:00
request_key.c keys: Do not cache key in task struct if key is requested from kernel thread 2023-04-05 11:16:37 +02:00
sysctl.c
trusted.c KEYS: trusted: Fix migratable=1 failing 2021-03-04 10:26:44 +01:00
user_defined.c KEYS: Don't write out to userspace while holding key semaphore 2020-04-23 10:36:45 +02:00