[PATCH v2] keys: Protect the type name while describing a key
sashiko-bot at kernel.org
sashiko-bot at kernel.org
Fri Oct 9 05:26:26 UTC 2026
> keyctl_describe_key() must keep the key type's name alive until
> kasprintf() has consumed it. The retained key reference keeps the key
> and its description alive, but does not pin the module providing its
> type. The name is passed to kasprintf() without holding key->sem.
>
> kvasprintf() uses the saved name pointer in two formatting passes, with
> a GFP_KERNEL allocation between them. With AF_RXRPC=m, a task that
> passes View permission before type retirement can overlap a privileged
> module unload in this order:
>
> 1. KEYCTL_DESCRIBE looks up the key, saves key->type->name in the
> kasprintf() arguments and completes the first formatting pass.
> 2. While the formatter is delayed before its second pass,
> af_rxrpc_exit() calls unregister_key_type(), which removes the type
> from the registry and waits for key_gc_keytype().
> [ ... ]
> vsnprintf+0x330/0x1110
>
> Fixes: aa9d4437893f ("KEYS: Fix the size of the key description passed to/from userspace")
> Assisted-by: LLM
> Signed-off-by: Cen Zhang <zzzccc427 at gmail.com>
Sashiko has reviewed this patch and found no issues. It looks great!
--
Sashiko AI review · https://sashiko.dev/#/patchset/pm-key-management-objects-candidate-0009-v4-6b537c5732fd957c33fa@gmail.com?part=1
More information about the Linux-security-module-archive
mailing list