[PATCH] ima: fix return value of ima_restore_measurement_list
Yan Zhu
zhuyan2015 at foxmail.com
Thu Sep 7 16:53:49 UTC 2023
When the function restore_template_fmt returns NULL due to insufficient
memory, the ima_restore_measurement_list function will exit and the IMA
measurement list recovery fails. However, since the return value of
ima_restore_measurement_list is 0, there will be no prompt for IMA
measurement list recovery failure in ima_load_kexec_buffer, which can
easily cause misunderstandings for users.
Signed-off-by: Yan Zhu <zhuyan2015 at foxmail.com>
---
security/integrity/ima/ima_template.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/security/integrity/ima/ima_template.c b/security/integrity/ima/ima_template.c
index 04c49f0..1b030cd 100644
--- a/security/integrity/ima/ima_template.c
+++ b/security/integrity/ima/ima_template.c
@@ -489,8 +489,10 @@ int ima_restore_measurement_list(loff_t size, void *buf)
template_desc = lookup_template_desc(template_name);
if (!template_desc) {
template_desc = restore_template_fmt(template_name);
- if (!template_desc)
+ if (!template_desc) {
+ ret = -ENOMEM;
break;
+ }
}
/*
--
2.33.0
More information about the Linux-security-module-archive
mailing list