Skip to content

Commit cc293c8

Browse files
committed
ima: define an init_module critical data record
The init_module syscall loads an ELF image into kernel space without measuring the buffer containing the ELF image. To close this kernel module integrity gap, define a new critical-data record which includes the hash of the ELF image. Instead of including the buffer data in the IMA measurement list, include the hash of the buffer data to avoid large IMA measurement list records. The buffer data hash would be the same value as the finit_module syscall file hash. To enable measuring the init_module buffer and other critical data from boot, define "ima_policy=critical_data" on the boot command line. Since builtin policies are not persistent, a custom IMA policy must include the rule as well: measure func=CRITICAL_DATA label=modules To verify the template data hash value, first convert the buffer data hash to binary: grep "init_module" \ /sys/kernel/security/integrity/ima/ascii_runtime_measurements | \ tail -1 | cut -d' ' -f 6 | xxd -r -p | sha256sum Reported-by: Ken Goldman <[email protected]> Reviewed-by: Jarkko Sakkinen <[email protected]> Signed-off-by: Mimi Zohar <[email protected]>
1 parent be84f32 commit cc293c8

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

security/integrity/ima/ima_main.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -902,6 +902,13 @@ static int ima_post_load_data(char *buf, loff_t size,
902902
return 0;
903903
}
904904

905+
/*
906+
* Measure the init_module syscall buffer containing the ELF image.
907+
*/
908+
if (load_id == LOADING_MODULE)
909+
ima_measure_critical_data("modules", "init_module",
910+
buf, size, true, NULL, 0);
911+
905912
return 0;
906913
}
907914

0 commit comments

Comments
 (0)