[PATCH v2] keys: Protect the read method check against type removal

sashiko-bot at kernel.org sashiko-bot at kernel.org
Mon Oct 19 16:10:15 UTC 2026


> keyctl_read_key() checks key->type->read without holding key->sem.
> A reference keeps the key alive, but does not pin the module containing
> its type. A surviving RxRPC key can therefore be read while AF_RXRPC
> is being unloaded:
> 
>   KEYCTL_READ task                    Module unload and key GC
>   ----------------                   ------------------------
>   lookup_user_key()
>   permission / possession checks
>   load key->type
>                                      af_rxrpc_exit()
>                                        unregister_key_type()
>                                          GC: down_write(key->sem)
>                                          GC: retype to key_type_dead
>                                          GC: up_write(key->sem)
> [ ... ]
> allocation and copying to userspace remain outside the semaphore.
> 
> Suggested-by: Jarkko Sakkinen <jarkko at kernel.org>
> Assisted-by: LLM
> Signed-off-by: Cen Zhang <zzzccc427 at gmail.com>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/pm-key-management-objects-candidate-0010-v7-fc85721ff5cfb9e33ac6@gmail.com?part=1




More information about the Linux-security-module-archive mailing list