linux/security/integrity
Gustavo A. R. Silva 68a8f64457 ima: Add __counted_by for struct modsig and use struct_size()
Prepare for the coming implementation by GCC and Clang of the __counted_by
attribute. Flexible array members annotated with __counted_by can have
their accesses bounds-checked at run-time via CONFIG_UBSAN_BOUNDS (for
array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family
functions).

Also, relocate `hdr->raw_pkcs7_len = sig_len;` so that the __counted_by
annotation has effect, and flex-array member `raw_pkcs7` can be properly
bounds-checked at run-time.

While there, use struct_size() helper, instead of the open-coded
version, to calculate the size for the allocation of the whole
flexible structure, including of course, the flexible-array member.

This code was found with the help of Coccinelle, and audited and
fixed manually.

Signed-off-by: "Gustavo A. R. Silva" <gustavoars@kernel.org>
Reviewed-by: Mimi Zohar <zohar@linux.ibm.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Link: https://lore.kernel.org/r/ZSRaDcJNARUUWUwS@work
Signed-off-by: Kees Cook <keescook@chromium.org>
2023-10-20 10:52:41 -07:00
..
evm lsm/stable-6.6 PR 20230829 2023-08-30 09:07:09 -07:00
ima ima: Add __counted_by for struct modsig and use struct_size() 2023-10-20 10:52:41 -07:00
platform_certs Hi, 2023-08-29 08:05:18 -07:00
digsig.c integrity: check whether imputed trust is enabled 2023-08-17 20:12:35 +00:00
digsig_asymmetric.c ima: fix reference leak in asymmetric_verify() 2022-01-24 18:37:36 -05:00
iint.c integrity: Fix possible multiple allocation in integrity_inode_get() 2023-06-01 07:25:04 -04:00
integrity.h integrity: check whether imputed trust is enabled 2023-08-17 20:12:35 +00:00
integrity_audit.c integrity: check the return value of audit_log_start() 2022-02-02 11:44:23 -05:00
Kconfig integrity: PowerVM machine keyring enablement 2023-08-17 20:12:35 +00:00
Makefile integrity: Introduce a Linux keyring called machine 2022-03-08 13:55:52 +02:00