History

ima: Move to LSM infrastructure

Move hardcoded IMA function calls (not appraisal-specific functions) from various places in the kernel to the LSM infrastructure, by introducing a new LSM named 'ima' (at the end of the LSM list and always enabled like 'integrity'). Having IMA before EVM in the Makefile is sufficient to preserve the relative order of the new 'ima' LSM in respect to the upcoming 'evm' LSM, and thus the order of IMA and EVM function calls as when they were hardcoded. Make moved functions as static (except ima_post_key_create_or_update(), which is not in ima_main.c), and register them as implementation of the respective hooks in the new function init_ima_lsm(). Select CONFIG_SECURITY_PATH, to ensure that the path-based LSM hook path_post_mknod is always available and ima_post_path_mknod() is always executed to mark files as new, as before the move. A slight difference is that IMA and EVM functions registered for the inode_post_setattr, inode_post_removexattr, path_post_mknod, inode_post_create_tmpfile, inode_post_set_acl and inode_post_remove_acl won't be executed for private inodes. Since those inodes are supposed to be fs-internal, they should not be of interest to IMA or EVM. The S_PRIVATE flag is used for anonymous inodes, hugetlbfs, reiserfs xattrs, XFS scrub and kernel-internal tmpfs files. Conditionally register ima_post_key_create_or_update() if CONFIG_IMA_MEASURE_ASYMMETRIC_KEYS is enabled. Also, conditionally register ima_kernel_module_request() if CONFIG_INTEGRITY_ASYMMETRIC_KEYS is enabled. Finally, add the LSM_ID_IMA case in lsm_list_modules_test.c.

Roberto Sassu committed 2 years ago

Commit cd3cec01 parent 06cca5114 files · +83 −200Browse files

Showing the changes to include/uapi (1 of 14 files). Show all

Unified · Split

include/uapi/linux/lsm.h+1−0
@@ -62,6 +62,7 @@ struct lsm_ctx { · 61 unmodified lines
62#define LSM_ID_LOCKDOWN 10862#define LSM_ID_LOCKDOWN 108
63#define LSM_ID_BPF 10963#define LSM_ID_BPF 109
64#define LSM_ID_LANDLOCK 11064#define LSM_ID_LANDLOCK 110
65#define LSM_ID_IMA 111
65 66
66/*67/*
67 * LSM_ATTR_XXX definitions identify different LSM attributes68 * LSM_ATTR_XXX definitions identify different LSM attributes

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t