Skip to content

Commit a7f2a36

Browse files
author
Mimi Zohar
committed
ima: fallback to MODULE_SIG_ENFORCE for existing kernel module syscall
The new kernel module syscall appraises kernel modules based on policy. If the IMA policy requires kernel module checking, fallback to module signature enforcing for the existing syscall. Without CONFIG_MODULE_SIG_FORCE enabled, the kernel module's integrity is unknown, return -EACCES. Changelog v1: - Fix ima_module_check() return result (Tetsuo Handa) Reported-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> Reviewed-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> Signed-off-by: Mimi Zohar <zohar@us.ibm.com>
1 parent a49f0d1 commit a7f2a36

3 files changed

Lines changed: 11 additions & 5 deletions

File tree

‎security/integrity/ima/ima.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ void ima_delete_rules(void);
139139
/* Appraise integrity measurements */
140140
#define IMA_APPRAISE_ENFORCE 0x01
141141
#define IMA_APPRAISE_FIX 0x02
142+
#define IMA_APPRAISE_MODULES 0x04
142143

143144
#ifdef CONFIG_IMA_APPRAISE
144145
int ima_appraise_measurement(struct integrity_iint_cache *iint,

‎security/integrity/ima/ima_main.c‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -291,11 +291,15 @@ EXPORT_SYMBOL_GPL(ima_file_check);
291291
*/
292292
int ima_module_check(struct file *file)
293293
{
294-
int rc;
294+
int rc = 0;
295295

296-
if (!file)
297-
rc = INTEGRITY_UNKNOWN;
298-
else
296+
if (!file) {
297+
if (ima_appraise & IMA_APPRAISE_MODULES) {
298+
#ifndef CONFIG_MODULE_SIG_FORCE
299+
rc = -EACCES; /* INTEGRITY_UNKNOWN */
300+
#endif
301+
}
302+
} else
299303
rc = process_measurement(file, file->f_dentry->d_name.name,
300304
MAY_EXEC, MODULE_CHECK);
301305
return (ima_appraise & IMA_APPRAISE_ENFORCE) ? rc : 0;

‎security/integrity/ima/ima_policy.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,8 @@ static int ima_parse_rule(char *rule, struct ima_rule_entry *entry)
523523
}
524524
if (!result && (entry->action == UNKNOWN))
525525
result = -EINVAL;
526-
526+
else if (entry->func == MODULE_CHECK)
527+
ima_appraise |= IMA_APPRAISE_MODULES;
527528
audit_log_format(ab, "res=%d", !result);
528529
audit_log_end(ab);
529530
return result;

0 commit comments

Comments
 (0)