Messages in this thread Patch in this message | | | From | Dmitry Kasatkin <> | Subject | [RFC v2 4/7] modsig: add integrity_module_check hook | Date | Wed, 15 Aug 2012 21:43:09 +0300 |
| |
IMA measures/appraises modules when modprobe or insmod opens and read them. Unfortunately, there are no guarantees between what is read by userspace and what is passed to the kernel via load_module system call. This patch adds a hook called integrity_module_check() to verify the integrity of the module being loaded.
Signed-off-by: Dmitry Kasatkin <dmitry.kasatkin@intel.com> --- include/linux/integrity.h | 10 ++++++++++ kernel/module.c | 9 +++++++++ 2 files changed, 19 insertions(+)
diff --git a/include/linux/integrity.h b/include/linux/integrity.h index 66c5fe9..a80ec06 100644 --- a/include/linux/integrity.h +++ b/include/linux/integrity.h @@ -37,4 +37,14 @@ static inline void integrity_inode_free(struct inode *inode) return; } #endif /* CONFIG_INTEGRITY_H */ + +#ifdef CONFIG_INTEGRITY_MODULES +int integrity_module_check(const void *hdr, const unsigned long len); +#else +static inline int integrity_module_check(const void *buf, unsigned long len) +{ + return 0; +} +#endif + #endif /* _LINUX_INTEGRITY_H */ diff --git a/kernel/module.c b/kernel/module.c index 4edbd9c..791da47 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -58,6 +58,7 @@ #include <linux/jump_label.h> #include <linux/pfn.h> #include <linux/bsearch.h> +#include <linux/integrity.h> #define CREATE_TRACE_POINTS #include <trace/events/module.h> @@ -2437,6 +2438,14 @@ static int copy_and_check(struct load_info *info, info->hdr = hdr; info->len = len; + + err = integrity_module_check(hdr, len); + if (err < 0) + goto free_hdr; + + /* cut signature tail */ + info->len = err; + return 0; free_hdr: -- 1.7.9.5
| |