[PATCH v7] KEYS: Protect pkey method checks against type removal
sashiko-bot at kernel.org
sashiko-bot at kernel.org
Tue Nov 10 03:13:35 UTC 2026
> keyctl_pkey_query(), keyctl_pkey_e_d_s() and keyctl_pkey_verify() check
> that key->type has the ->asym_*() method they need and call it later,
> without holding key->sem. A reference keeps the key alive, but does not
> pin the module that provides its type.
>
> When that module is unloaded, unregister_key_type() waits for the key GC
> to process every remaining key of the type. For each such key, the GC
> takes key->sem for writing, switches key->type to key_type_dead, whose
> ->asym_*() methods are NULL, and destroys the payload. If that happens
> between the check and the call, the keyctl calls a NULL method; if it
> happens while the method runs, the method returns into freed module text.
> In-tree, turris-signing-key provides ->asym_query() and ->asym_eds_op()
> and can be built as a module.
>
> Take key->sem for reading around each method call, and check the method
> [ ... ]
> against type removal").
>
> Fixes: 00d60fd3b932 ("KEYS: Provide keyctls to drive the new key type ops for asymmetric keys [ver #2]")
> Cc: stable at vger.kernel.org
> Signed-off-by: Yuansheng Yang <0xbeac at gmail.com>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261110030252.9979-1-0xbeac@gmail.com?part=1
More information about the Linux-security-module-archive
mailing list