Re: [PATCH] security: fix the key_permission LSM hook function type

From: Kees Cook
Date: Sun Jun 21 2020 - 01:55:10 EST


On Mon, Jun 15, 2020 at 11:12:32AM -0700, Sami Tolvanen wrote:
> Commit 8c0637e950d6 ("keys: Make the KEY_NEED_* perms an enum rather than
> a mask") changed the type of the key_permission callback functions, but
> didn't change the type of the hook, which trips indirect call checking with
> Control-Flow Integrity (CFI). This change fixes the issue by changing the
> hook type to match the functions.
>
> Fixes: 8c0637e950d6 ("keys: Make the KEY_NEED_* perms an enum rather than a mask")
> Signed-off-by: Sami Tolvanen <samitolvanen@xxxxxxxxxx>
> ---
> include/linux/lsm_hook_defs.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/linux/lsm_hook_defs.h b/include/linux/lsm_hook_defs.h
> index 6791813cd439..24f6683f1cfc 100644
> --- a/include/linux/lsm_hook_defs.h
> +++ b/include/linux/lsm_hook_defs.h
> @@ -360,7 +360,7 @@ LSM_HOOK(int, 0, key_alloc, struct key *key, const struct cred *cred,
> unsigned long flags)
> LSM_HOOK(void, LSM_RET_VOID, key_free, struct key *key)
> LSM_HOOK(int, 0, key_permission, key_ref_t key_ref, const struct cred *cred,
> - unsigned perm)
> + enum key_need_perm need_perm)
> LSM_HOOK(int, 0, key_getsecurity, struct key *key, char **_buffer)
> #endif /* CONFIG_KEYS */
>
>
> base-commit: b3a9e3b9622ae10064826dccb4f7a52bd88c7407

David, James? Can someone please take this?

--
Kees Cook