[PATCH v3] keys: Protect the update method check against type removal
sashiko-bot at kernel.org
sashiko-bot at kernel.org
Sat Oct 31 09:33:22 UTC 2026
> key_update() reads key->type->update, ->def_datalen and ->preparse
> before it takes key->sem. A reference on the key does not pin the
> module that provides its type, so KEYCTL_UPDATE can race with the
> unloading of that module, for example dns_resolver:
>
> KEYCTL_UPDATE task Module unload and key GC
> ------------------ ------------------------
> keyctl_update_key()
> key_update()
> key_permission()
> load key->type
> exit_dns_resolver()
> unregister_key_type()
> GC: down_write(&key->sem)
> GC: retype to key_type_dead
> [ ... ]
> 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.
>
> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
> Signed-off-by: Cen Zhang <zzzccc427 at gmail.com>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/pm-keys-update-type-removal-20261029-v8-a0dbc48c588bf2b6a278@gmail.com?part=1
More information about the Linux-security-module-archive
mailing list