Skip to content

Commit 7991b03

Browse files
committed
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security
Pull integrity subsystem regression fix from James Morris: "Commit fdf9072 "ima: support new kernel module syscall" by error modified init_module() to return INTEGRITY_UNKNOWN (which is 4) to user space if the kernel was built with CONFIG_IMA_APPRAISE=y. As a result, user space can no longer load kernel modules using init_module(). This commit fixes this regression." * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security: ima: fallback to MODULE_SIG_ENFORCE for existing kernel module syscall
2 parents 0c4a842 + ade24c9 commit 7991b03

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

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)