5.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Linus Torvalds commit 43a1e3744548e6fd85873e6fb43e293eb4010694 upstream. Nicholas Carlini reports that the keyring code calls assoc_array_find() in find_key_to_update() without holding the RCU read lock, while the assoc_array_gc() code really is designed around removing the node from the tree and then freeing it after an RCU grace-period. The regular key handling doesn't see this because holding the keyring semaphore hides any lifetime issues, but the persistent key handling uses a different model. Instead of extending the keyring locking, just do the simple RCU locking that the assoc_array was designed for. [ Moved the guard at the top of the function to solve a compilation issue ] Reported-by: Nicholas Carlini Cc: David Howells Cc: Jarkko Sakkinen Cc: Paul Moore Cc: James Morris James Morris Cc: Serge E. Hallyn Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman Signed-off-by: Miguel Gazquez (Schneider Electric) Signed-off-by: Sasha Levin --- security/keys/keyring.c | 1 + 1 file changed, 1 insertion(+) diff --git a/security/keys/keyring.c b/security/keys/keyring.c index 8b938e61ecd8d..241b96addcf38 100644 --- a/security/keys/keyring.c +++ b/security/keys/keyring.c @@ -1105,6 +1105,7 @@ key_ref_t find_key_to_update(key_ref_t keyring_ref, { struct key *keyring, *key; const void *object; + guard(rcu)(); keyring = key_ref_to_ptr(keyring_ref); -- 2.53.0