Re: [PATCH v3] keys: Protect the update method check against type removalg
From: Jarkko Sakkinen
Date: Mon Nov 02 2026 - 02:28:12 EST
On Mon, Nov 02, 2026 at 09:00:03AM +0200, Jarkko Sakkinen wrote:
> 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@xxxxxxxxxx>
> >
> > 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@xxxxxxxxxx/
> as that is more substantial multi-subsystem change.
I would probably favor this idea but it would also change visible
semantics how key types behave with rmmod.
I.e. -EBUSY instead of immediate success. I'm only worried here
of user space relaying on how it works right now.
Br, Jarkko