[PATCH] keys: Avoid the owner account dereference in named keyring lookup
sashiko-bot at kernel.org
sashiko-bot at kernel.org
Thu Oct 8 06:44:27 UTC 2026
> Named keyring lookup must keep the storage containing the owner UID
> alive through the namespace mapping check. find_keyring_by_name()
> reads keyring->user->uid under keyring_name_lock, but that lock protects
> the keyring's name entry and allocation, not its separate key_user.
>
> A named session-keyring join can overlap a privileged KEYCTL_CHOWN on
> another CPU. If the keyring holds the last reference to its old dynamic
> key_user and the ownership transfer succeeds, the following ordering is
> possible:
>
> Named join Chown
> find_keyring_by_name() keyctl_chown_key()
> read_lock(keyring_name_lock) down_write(key->sem)
> load old keyring->user
> replace key->user and key->uid
> [ ... ]
> ==================================================================
>
> Fixes: 2ea190d0a006 ("keys: skip keys from another user namespace")
> 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-0002-v2-dd6c20a1d92928b33ab7@gmail.com?part=1
More information about the Linux-security-module-archive
mailing list