[PATCH 4.19 v3 5/6] ima: Evaluate error in init_ima()

GUO Zihua guozihua at huawei.com
Tue Feb 28 08:06:29 UTC 2023


From: Roberto Sassu <roberto.sassu at huawei.com>

[ Upstream commit e144d6b265415ddbdc54b3f17f4f95133effa5a8 ]

Evaluate error in init_ima() before register_blocking_lsm_notifier() and
return if not zero.

Cc: stable at vger.kernel.org # 5.3.x
Fixes: b16942455193 ("ima: use the lsm policy update notifier")
Signed-off-by: Roberto Sassu <roberto.sassu at huawei.com>
Reviewed-by: James Morris <jamorris at linux.microsoft.com>
Signed-off-by: Mimi Zohar <zohar at linux.ibm.com>
Signed-off-by: GUO Zihua <guozihua at huawei.com>
---
 security/integrity/ima/ima_main.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/security/integrity/ima/ima_main.c b/security/integrity/ima/ima_main.c
index 55681872c6ce..fcaaf2c2ba4b 100644
--- a/security/integrity/ima/ima_main.c
+++ b/security/integrity/ima/ima_main.c
@@ -557,6 +557,9 @@ static int __init init_ima(void)
 		error = ima_init();
 	}
 
+	if (error)
+		return error;
+
 	error = register_blocking_lsm_notifier(&ima_lsm_policy_notifier);
 	if (error)
 		pr_warn("Couldn't register LSM notifier, error %d\n", error);
-- 
2.17.1



More information about the Linux-security-module-archive mailing list