4 of 5 IMA: module measurement patch
PATCH 1/1 4 of 5 IMA: module measurement patch
This patch applies against linux-2.6.12-rc6-mm1 and provides an additional measurement hook for measuring kernel modules before they are relocated and available. At this point, the modules are still an exact copy of the file on the disk and yield representative measurements.
This is a kernel patch because we could not find a fitting LSM-hook.
---
include/linux/ima_module.h +33 -0
@@ -0,0 +1,33 @@ +/* +* Copyright (C) 2005 IBM Corporation +* +* Authors: +* Reiner Sailer <[email protected]> +* +* Maintained by: Reiner Sailer <[email protected]> +* +* LSM IBM Integrity Measurement Architecture. +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License as +* published by the Free Software Foundation, version 2 of the +* License. +* +* File: ima_module.h +* define modules measurement hook (no LSM hook) to measure +* modules before they are relocated +*/ +#ifdef CONFIG_IMA_MEASURE +extern int ima_terminating; +extern void measure_kernel_module (void *start,unsigned long len,const char __user *uargs); + +static inline void ima_measure_module (void *start,unsigned long len,const char __user *uargs) +{ +if (!ima_terminating) +measure_kernel_module (start, len, uargs); +} +#else +static inline void ima_measure_module (void *start,unsigned long len,const char __user *uargs) +{ +} +#endif
kernel/module.c +3 -0
@@ -39,6 +39,7 @@#include <asm/uaccess.h> #include <asm/semaphore.h> #include <asm/cacheflush.h> +#include <linux/ima_module.h> #if 0 #define DEBUGP printk
@@ -1531,6 +1532,8 @@ static struct module *load_module(void _if (len < hdr->e_shoff + hdr->e_shnum *sizeof (Elf_Shdr)) goto truncated; +ima_measure_module ((void *)hdr, len, uargs); +/* Convenience variables */ sechdrs = (void *)hdr + hdr->e_shoff; secstrings = (void *)hdr + sechdrs[hdr->e_shstrndx].sh_offset;
include/linux/ima_module.h line 22
Quoted 2 lines · Reiner Sailer
include/linux/ima_module.h +2
-0+extern int ima_terminating; +extern void measure_kernel_module (void *start,unsigned long len,const char __user *uargs);
These belong in a .h file somewhere.
The later one is not a good global symbol name either.
So, from what I can see, you dropped your sysfs interfaces entirely?
thanks,
greg k-h
Quoted 5 lines · * Greg KH ([email protected]) wrote:
include/linux/ima_module.h line 22
Quoted 2 lines · Reiner Sailer
include/linux/ima_module.h +2
-0+extern int ima_terminating; +extern void measure_kernel_module (void *start,unsigned long len,const char __user *uargs);These belong in a .h file somewhere.
Well, I think they _are_ in a .h file (two of them, in fact), it's the extern keyword that can be and dup declaration that can be dropped. However, does this thing even compile w/ CONFIG_IMA_MEASURE=n? Looks quite broken w.r.t. CONFIG_IMA_MEASURE to me.
thanks,
-chris