[PATCH v3] keys: Protect the update method check against type removalg

Jarkko Sakkinen jarkko at kernel.org
Mon Nov 2 06:59:59 UTC 2026


On Sun, Nov 01, 2026 at 02:15:19PM -0800, Eric Biggers wrote:
> On Sat, Oct 31, 2026 at 05:26:36PM +0800, Cen Zhang wrote:
> > Take key->sem before the first access to key->type and hold it until
> > the preparsed payload has been freed. Once a key exists, only the GC
> > changes key->type, and it does so with key->sem held for writing.
> 
> Reviewed-by: Eric Biggers <ebiggers at kernel.org>
> 
> But it seems broken that a key type can be removed while keys of that
> type still exist.

It might sense add ->owner and use try_module_get(). That would lead
into removal of key_type_dead.

I'd think that is doable but I would first consider applying
https://lore.kernel.org/keyrings/20261030205412.3138975-1-jarkko@kernel.org/
as that is more substantial multi-subsystem change.

> 
> - Eric

Br, Jarkko



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