Function report |
Source Code:security\integrity\ima\ima_policy.c |
Create Date:2022-07-28 19:59:03 |
Last Modify:2020-03-12 14:18:49 | Copyright©Brick |
home page | Tree |
Annotation kernel can get tool activity | Download SCCT | Chinese |
Name:ima_parse_rule
Proto:static int ima_parse_rule(char *rule, struct ima_rule_entry *entry)
Type:int
Parameter:
Type | Parameter | Name |
---|---|---|
char * | rule | |
struct ima_rule_entry * | entry |
899 | result = 0 |
904 | uid = INVALID_UID |
905 | fowner = INVALID_UID |
914 | If result < 0 Then Break |
918 | token = match_token(p, policy_tokens, args) |
920 | Case token == Opt_measure |
928 | Case token == Opt_dont_measure |
936 | Case token == Opt_appraise |
944 | Case token == Opt_dont_appraise |
953 | ima_log_string(ab, "action", "audit") |
959 | Break |
961 | ima_log_string(ab, "action", "hash") |
967 | Break |
968 | Case token == Opt_dont_hash |
969 | ima_log_string(ab, "action", "dont_hash") |
975 | Break |
977 | ima_log_string(ab, "func", from) |
982 | If strcmp(from, "FILE_CHECK") == 0 Then func = FILE_CHECK |
985 | Else if strcmp(from, "PATH_CHECK") == 0 Then func = FILE_CHECK |
987 | Else if strcmp(from, "MODULE_CHECK") == 0 Then func = MODULE_CHECK |
989 | Else if strcmp(from, "FIRMWARE_CHECK") == 0 Then func = FIRMWARE_CHECK |
991 | Else if strcmp(from, "FILE_MMAP") == 0 || strcmp(from, "MMAP_CHECK") == 0 Then func = MMAP_CHECK |
994 | Else if strcmp(from, "BPRM_CHECK") == 0 Then func = BPRM_CHECK |
996 | Else if strcmp(from, "CREDS_CHECK") == 0 Then func = CREDS_CHECK |
998 | Else if strcmp(from, "KEXEC_KERNEL_CHECK") == 0 Then func = KEXEC_KERNEL_CHECK |
1001 | Else if strcmp(from, "KEXEC_INITRAMFS_CHECK") == 0 Then func = KEXEC_INITRAMFS_CHECK |
1004 | Else if strcmp(from, "POLICY_CHECK") == 0 Then func = POLICY_CHECK |
1006 | Else if strcmp(from, "KEXEC_CMDLINE") == 0 Then func = KEXEC_CMDLINE |
1010 | If Not result Then flags |= lags definitions |
1012 | Break |
1014 | ima_log_string(ab, "mask", from) |
1029 | Else if strcmp(from, "MAY_APPEND") == 0 Then mask = MAY_APPEND |
1033 | If Not result Then flags |= If from == '^' Then IMA_INMASK Else IMA_MASK |
1036 | Break |
1037 | Case token == Opt_fsmagic |
1038 | ima_log_string(ab, "fsmagic", from) |
1040 | If fsmagic Then |
1046 | If Not result Then flags |= IMA_FSMAGIC |
1048 | Break |
1049 | Case token == Opt_fsname |
1050 | ima_log_string(ab, "fsname", from) |
1053 | If Not fsname Then |
1057 | result = 0 |
1058 | flags |= IMA_FSNAME |
1059 | Break |
1060 | Case token == Opt_fsuuid |
1061 | ima_log_string(ab, "fsuuid", from) |
1063 | If Not uuid_is_null( & fsuuid) Then |
1068 | result = uuid_parse(from, & fsuuid) |
1069 | If Not result Then flags |= IMA_FSUUID |
1071 | Break |
1072 | Case token == Opt_uid_gt |
1073 | Case token == Opt_euid_gt |
1076 | Case token == Opt_uid_lt |
1077 | Case token == Opt_euid_lt |
1078 | If token == Opt_uid_lt || token == Opt_euid_lt Then uid_op = uid_lt |
1081 | Case token == Opt_uid_eq |
1082 | Case token == Opt_euid_eq |
1083 | uid_token = token == Opt_uid_eq || token == Opt_uid_gt || token == Opt_uid_lt |
1087 | ima_log_string_op(ab, uid_token ? "uid" : "euid", from, uid_op) |
1096 | If Not result Then |
1106 | Break |
1107 | Case token == Opt_fowner_gt |
1110 | Case token == Opt_fowner_lt |
1111 | If token == Opt_fowner_lt Then fowner_op = uid_lt |
1114 | Case token == Opt_fowner_eq |
1115 | ima_log_string_op(ab, "fowner", from, fowner_op) |
1124 | If Not result Then |
1128 | Else flags |= IMA_FOWNER |
1131 | Break |
1132 | Case token == Opt_obj_user |
1133 | ima_log_string(ab, "obj_user", from) |
1134 | result = ima_lsm_rule_init(entry, args, LSM_OBJ_USER, AUDIT_OBJ_USER) |
1137 | Break |
1138 | Case token == Opt_obj_role |
1139 | ima_log_string(ab, "obj_role", from) |
1140 | result = ima_lsm_rule_init(entry, args, LSM_OBJ_ROLE, AUDIT_OBJ_ROLE) |
1143 | Break |
1144 | Case token == Opt_obj_type |
1145 | ima_log_string(ab, "obj_type", from) |
1146 | result = ima_lsm_rule_init(entry, args, LSM_OBJ_TYPE, AUDIT_OBJ_TYPE) |
1149 | Break |
1150 | Case token == Opt_subj_user |
1151 | ima_log_string(ab, "subj_user", from) |
1152 | result = ima_lsm_rule_init(entry, args, LSM_SUBJ_USER, security label user ) |
1155 | Break |
1156 | Case token == Opt_subj_role |
1157 | ima_log_string(ab, "subj_role", from) |
1158 | result = ima_lsm_rule_init(entry, args, LSM_SUBJ_ROLE, security label role ) |
1161 | Break |
1162 | Case token == Opt_subj_type |
1163 | ima_log_string(ab, "subj_type", from) |
1164 | result = ima_lsm_rule_init(entry, args, LSM_SUBJ_TYPE, security label type ) |
1167 | Break |
1168 | Case token == Opt_appraise_type |
1169 | If action != same as IMA_APPRAISE Then |
1174 | ima_log_string(ab, "appraise_type", from) |
1175 | If strcmp(from, "imasig") == 0 Then flags |= IMA_DIGSIG_REQUIRED |
1177 | Else if ima_hook_supports_modsig(func) && strcmp(from, "imasig|modsig") == 0 Then flags |= IMA_DIGSIG_REQUIRED | IMA_MODSIG_ALLOWED |
1183 | Break |
1184 | Case token == Opt_appraise_flag |
1185 | ima_log_string(ab, "appraise_flag", from) |
1186 | If strstr - Find the first substring in a %NUL terminated string*@s1: The string to be searched*@s2: The string to search for Then flags |= IMA_CHECK_BLACKLIST |
1188 | Break |
1189 | Case token == Opt_permit_directio |
1190 | flags |= IMA_PERMIT_DIRECTIO |
1191 | Break |
1193 | If action != same as IMA_MEASURE Then |
1197 | ima_log_string(ab, "pcr", from) |
1200 | If result || INVALID_PCR( uid_eq(), uid_gt(), uid_lt() ) Then result = -EINVAL |
1205 | Break |
1206 | Case token == Opt_template |
1207 | ima_log_string(ab, "template", from) |
1208 | If action != same as IMA_MEASURE Then |
1212 | template_desc = lookup_template_desc(from) |
1213 | If Not template_desc || template Then |
1223 | template_desc_init_fields(fmt, & (fields), & (num_fields)) |
1226 | template = template_desc |
1227 | Break |
1236 | Else if action == same as IMA_APPRAISE Then temp_ima_appraise |= ima_appraise_flag(func) |
1239 | If Not result && flags & IMA_MODSIG_ALLOWED Then |
1240 | template_desc = If template Then template Else ima_template_desc_current() |
1247 | Return result |
Name | Describe |
---|---|
ima_init_arch_policy | |
ima_parse_add_rule | ma_parse_add_rule - add a rule to ima_policy_rules*@rule - ima measurement policy rule* Avoid locking by allowing just one writer at a time in ima_write_policy()* Returns the length of the rule parsed, an error code on failure |
Source code conversion tool public plug-in interface | X |
---|---|
Support c/c++/esqlc/java Oracle/Informix/Mysql Plug-in can realize: logical Report Code generation and batch code conversion |