security: Refactor declaration of LSM hooks
authorKP Singh <kpsingh@google.com>
Sun, 29 Mar 2020 00:43:50 +0000 (01:43 +0100)
committerDaniel Borkmann <daniel@iogearbox.net>
Sun, 29 Mar 2020 23:34:00 +0000 (01:34 +0200)
commit98e828a0650f348be85728c69875260cf78069e6
treefbac6bde4fc2450ccd4432346afc15770252865d
parentfc611f47f2188ade2b48ff6902d5cce8baac0c58
security: Refactor declaration of LSM hooks

The information about the different types of LSM hooks is scattered
in two locations i.e. union security_list_options and
struct security_hook_heads. Rather than duplicating this information
even further for BPF_PROG_TYPE_LSM, define all the hooks with the
LSM_HOOK macro in lsm_hook_defs.h which is then used to generate all
the data structures required by the LSM framework.

The LSM hooks are defined as:

  LSM_HOOK(<return_type>, <default_value>, <hook_name>, args...)

with <default_value> acccessible in security.c as:

  LSM_RET_DEFAULT(<hook_name>)

Signed-off-by: KP Singh <kpsingh@google.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Reviewed-by: Brendan Jackman <jackmanb@google.com>
Reviewed-by: Florent Revest <revest@google.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Casey Schaufler <casey@schaufler-ca.com>
Acked-by: James Morris <jamorris@linux.microsoft.com>
Link: https://lore.kernel.org/bpf/20200329004356.27286-3-kpsingh@chromium.org
include/linux/lsm_hook_defs.h [new file with mode: 0644]
include/linux/lsm_hooks.h
security/security.c