Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ima: define kernel parameter 'ima_template=' to change configured default

This patch allows users to specify from the kernel command line the
template descriptor, among those defined, that will be used to generate
and display measurement entries. If an user specifies a wrong template,
IMA reverts to the template descriptor set in the kernel configuration.

Signed-off-by: Roberto Sassu <roberto.sassu@polito.it>
Signed-off-by: Mimi Zohar <zohar@linux.vnet.ibm.com>

authored by

Roberto Sassu and committed by
Mimi Zohar
9b9d4ce5 4286587d

+36
+5
Documentation/kernel-parameters.txt
··· 1190 1190 programs exec'd, files mmap'd for exec, and all files 1191 1191 opened for read by uid=0. 1192 1192 1193 + ima_template= [IMA] 1194 + Select one of defined IMA measurements template formats. 1195 + Formats: { "ima" | "ima-ng" } 1196 + Default: "ima-ng" 1197 + 1193 1198 init= [KNL] 1194 1199 Format: <full_path> 1195 1200 Run specified binary instead of /sbin/init as init
+31
security/integrity/ima/ima_template.c
··· 12 12 * File: ima_template.c 13 13 * Helpers to manage template descriptors. 14 14 */ 15 + #include <crypto/hash_info.h> 16 + 15 17 #include "ima.h" 16 18 #include "ima_template_lib.h" 17 19 ··· 34 32 }; 35 33 36 34 static struct ima_template_desc *ima_template; 35 + static struct ima_template_desc *lookup_template_desc(const char *name); 36 + 37 + static int __init ima_template_setup(char *str) 38 + { 39 + struct ima_template_desc *template_desc; 40 + int template_len = strlen(str); 41 + 42 + /* 43 + * Verify that a template with the supplied name exists. 44 + * If not, use CONFIG_IMA_DEFAULT_TEMPLATE. 45 + */ 46 + template_desc = lookup_template_desc(str); 47 + if (!template_desc) 48 + return 1; 49 + 50 + /* 51 + * Verify whether the current hash algorithm is supported 52 + * by the 'ima' template. 53 + */ 54 + if (template_len == 3 && strcmp(str, IMA_TEMPLATE_IMA_NAME) == 0 && 55 + ima_hash_algo != HASH_ALGO_SHA1 && ima_hash_algo != HASH_ALGO_MD5) { 56 + pr_err("IMA: template does not support hash alg\n"); 57 + return 1; 58 + } 59 + 60 + ima_template = template_desc; 61 + return 1; 62 + } 63 + __setup("ima_template=", ima_template_setup); 37 64 38 65 static struct ima_template_desc *lookup_template_desc(const char *name) 39 66 {