[PATCH] KEYS: Prevent key type removal during key_instantiate_and_link()

Jarkko Sakkinen jarkko at kernel.org
Tue Nov 24 17:44:47 UTC 2026


On Tue, Nov 24, 2026 at 07:40:35PM +0200, Jarkko Sakkinen wrote:
> key_instantiate_and_link() accesses key->type outside key->sem, which can
> lead into null deref due that key types can be dropped at any possible
> time.
> 
> Address this by moving key_construction_mutex inside key->sem, and match
> that order in key_reject_and_link())
> 
> Cc: stable at vger.kernel.org
> Cc: keyrings at vger.kernel.org
> Cc: linux-kernel at vger.kernel.org
> Cc: linux-security-module at vger.kernel.org
> Cc: David Howells <dhowells at redhat.com>
> Cc: James Morris <jmorris at namei.org>
> Cc: Jarkko Sakkinen <jarkko at kernel.org>
> Cc: Paul Moore <paul at paul-moore.com>
> Cc: "Serge E. Hallyn" <serge at hallyn.com>
> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
> Reported-by: Guicai Ma <maguicai at kylinos.cn>
> Closes: https://lore.kernel.org/r/20261124091243.1019217-1-maguicai@kylinos.cn
> Signed-off-by: Jarkko Sakkinen <jarkko at kernel.org>

Can be better addressed later with this:
https://lore.kernel.org/keyrings/20261112040242.247168-1-jarkko@kernel.org/

In erases all key type drop type of issue. Thus, totally acceptable
bug fix.

Br, Jarkko



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