Skip to contentSkip to conversation

ima: Handle error code from security_audit_rule_match

PATCH In review GUO Zihua 2 participants 3 messages Dec 27, 2022 – Dec 30, 2022

Subsystems (4)
lore
Share & tools
lore

GUO Zihua

author
#0 lore raw

PATCH 1/1 ima: Handle error code from security_audit_rule_match

commit c7423dbdbc9e ("ima: Handle -ESTALE returned by ima_filter_rule_match()") introduced the handling of -ESTALE returned by security_audit_rule_match(). However, security_audit_rule_match() might return other error codes if some error occurred. We should handle those error codes as well.

Fixes c7423dbdbc9e ("ima: Handle -ESTALE returned by ima_filter_rule_match()")
---
 security/integrity/ima/ima_policy.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
security/integrity/ima/ima_policy.c +1 -1
index 6a68ec270822..5561e1b2c376 100644
@@ -663,7 +663,7 @@ static bool ima_match_rules(struct ima_rule_entry *rule,
 			break;
 		}
 
-		if (rc == -ESTALE && !rule_reinitialized) {
+		if (rc < 0 && !rule_reinitialized) {
 			lsm_rule = ima_lsm_copy_rule(rule);
 			if (lsm_rule) {
 				rule_reinitialized = true;
Signature · 1 line
2.17.1
maintainer
#1 lore raw
Quoted 17 lines · GUO Zihua

commit c7423dbdbc9e ("ima: Handle -ESTALE returned by ima_filter_rule_match()") introduced the handling of -ESTALE returned by security_audit_rule_match(). However, security_audit_rule_match() might return other error codes if some error occurred. We should handle those error codes as well.

Fixes c7423dbdbc9e ("ima: Handle -ESTALE returned by ima_filter_rule_match()")
---
 security/integrity/ima/ima_policy.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
security/integrity/ima/ima_policy.c +0 -0
index 6a68ec270822..5561e1b2c376 100644

security/integrity/ima/ima_policy.c static bool ima_match_rules(struct ima_rule_entry *rule, · line 666

Quoted 5 lines
security/integrity/ima/ima_policy.c +1 -1
@@ -663,7 +663,7 @@ static bool ima_match_rules(struct ima_rule_entry *rule,
 			break;
 		}
 
-		if (rc == -ESTALE && !rule_reinitialized) {
+		if (rc < 0 && !rule_reinitialized) {

Which other error codes are resolved by retrying?

Quoted 3 lines
security/integrity/ima/ima_policy.c +0 -0
 			lsm_rule = ima_lsm_copy_rule(rule);
 			if (lsm_rule) {
 				rule_reinitialized = true;
Signature · 3 lines
Thanks,

Mimi
#2 lore raw
Quoted 21 lines · Mimi Zohar
Quoted 20 lines · GUO Zihua

commit c7423dbdbc9e ("ima: Handle -ESTALE returned by ima_filter_rule_match()") introduced the handling of -ESTALE returned by security_audit_rule_match(). However, security_audit_rule_match() might return other error codes if some error occurred. We should handle those error codes as well.

Fixes c7423dbdbc9e ("ima: Handle -ESTALE returned by ima_filter_rule_match()")
---
 security/integrity/ima/ima_policy.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
security/integrity/ima/ima_policy.c +0 -0
index 6a68ec270822..5561e1b2c376 100644
@@ -663,7 +663,7 @@ static bool ima_match_rules(struct ima_rule_entry *rule,
 			break;
 		}
 
Quoted 4 lines

security/integrity/ima/ima_policy.c static bool ima_match_rules(struct ima_rule_entry *rule, · line 666

Quoted 2 lines
security/integrity/ima/ima_policy.c +1 -1
-		if (rc == -ESTALE && !rule_reinitialized) {
+		if (rc < 0 && !rule_reinitialized) {

Which other error codes are resolved by retrying?

Well I re-checked security_audit_rule_match() and it seems that only -ESTALE can be handled. This patch could be ignored.

Quoted 5 lines
Quoted 4 lines
security/integrity/ima/ima_policy.c +0 -0
 			lsm_rule = ima_lsm_copy_rule(rule);
 			if (lsm_rule) {
 				rule_reinitialized = true;
Signature · 2 lines
Best
GUO Zihua