linux/security/integrity/ima
Kees Cook b64fcae74b LSM: Introduce kernel_post_load_data() hook
There are a few places in the kernel where LSMs would like to have
visibility into the contents of a kernel buffer that has been loaded or
read. While security_kernel_post_read_file() (which includes the
buffer) exists as a pairing for security_kernel_read_file(), no such
hook exists to pair with security_kernel_load_data().

Earlier proposals for just using security_kernel_post_read_file() with a
NULL file argument were rejected (i.e. "file" should always be valid for
the security_..._file hooks, but it appears at least one case was
left in the kernel during earlier refactoring. (This will be fixed in
a subsequent patch.)

Since not all cases of security_kernel_load_data() can have a single
contiguous buffer made available to the LSM hook (e.g. kexec image
segments are separately loaded), there needs to be a way for the LSM to
reason about its expectations of the hook coverage. In order to handle
this, add a "contents" argument to the "kernel_load_data" hook that
indicates if the newly added "kernel_post_load_data" hook will be called
with the full contents once loaded. That way, LSMs requiring full contents
can choose to unilaterally reject "kernel_load_data" with contents=false
(which is effectively the existing hook coverage), but when contents=true
they can allow it and later evaluate the "kernel_post_load_data" hook
once the buffer is loaded.

With this change, LSMs can gain coverage over non-file-backed data loads
(e.g. init_module(2) and firmware userspace helper), which will happen
in subsequent patches.

Additionally prepare IMA to start processing these cases.

Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-by: KP Singh <kpsingh@google.com>
Link: https://lore.kernel.org/r/20201002173828.2099543-9-keescook@chromium.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-10-05 13:37:03 +02:00
..
ima_api.c ima: Support additional conditionals in the KEXEC_CMDLINE hook function 2020-07-20 13:28:16 -04:00
ima_appraise.c treewide: Use fallthrough pseudo-keyword 2020-08-23 17:36:59 -05:00
ima_asymmetric_keys.c ima: Support additional conditionals in the KEXEC_CMDLINE hook function 2020-07-20 13:28:16 -04:00
ima_crypto.c ima: extend boot_aggregate with kernel measurements 2020-06-24 20:47:24 -04:00
ima_fs.c fs/kernel_read_file: Add file_size output argument 2020-10-05 13:37:03 +02:00
ima_init.c ima: Call ima_calc_boot_aggregate() in ima_eventdigest_init() 2020-06-03 17:20:43 -04:00
ima_kexec.c integrity: Remove duplicate pr_fmt definitions 2020-02-28 14:32:58 -05:00
ima_main.c LSM: Introduce kernel_post_load_data() hook 2020-10-05 13:37:03 +02:00
ima_modsig.c ima: Move comprehensive rule validation checks out of the token parser 2020-07-20 13:28:15 -04:00
ima_mok.c Revert "Merge tag 'keys-acl-20190703' of git://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs" 2019-07-10 18:43:43 -07:00
ima_policy.c fs/kernel_read_file: Split into separate include file 2020-10-05 13:34:18 +02:00
ima_queue_keys.c ima: Support additional conditionals in the KEXEC_CMDLINE hook function 2020-07-20 13:28:16 -04:00
ima_queue.c ima: Use ima_hash_algo for collision detection in the measurement list 2020-04-19 22:03:39 -04:00
ima_template_lib.c treewide: Use fallthrough pseudo-keyword 2020-08-23 17:36:59 -05:00
ima_template_lib.h Replace HTTP links with HTTPS ones: security 2020-08-06 12:00:05 -07:00
ima_template.c Minor fixes for v5.9. 2020-08-11 14:30:36 -07:00
ima.h ima: Rename internal filter rule functions 2020-07-20 18:18:23 -04:00
Kconfig Minor fixes for v5.9. 2020-08-11 14:30:36 -07:00
Makefile IMA: Update KBUILD_MODNAME for IMA files to ima 2020-02-28 14:32:58 -05:00