Skip to contentSkip to conversation

libsepol/cil: Expand class-permissions in deny rules

PATCH In review James Carter 1 participant 2 messages Jul 1, 2025 – Jul 3, 2025 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libsepol/cil: Expand class-permissions in deny rules

The classperms list of deny rules is not being expanded. This causes an invalid read if "all" is used in the permissions.

Evaluate the classperms list of deny rules.

Reported-by oss-fuzz (issue 398075935)
---
 libsepol/cil/src/cil_post.c | 8 ++++++++
 1 file changed, 8 insertions(+)
libsepol/cil/src/cil_post.c +8 -0
index 70e5b734..2b6dad73 100644
@@ -2265,6 +2265,14 @@ static int __cil_post_db_classperms_helper(struct cil_tree_node *node, uint32_t
 		}
 		break;
 	}
+	case CIL_DENY_RULE: {
+		struct cil_deny_rule *deny = node->data;
+		rc = __evaluate_classperms_list(deny->classperms, db);
+		if (rc != SEPOL_OK) {
+			goto exit;
+		}
+		break;
+	}
 	case CIL_CONSTRAIN:
 	case CIL_MLSCONSTRAIN: {
 		struct cil_constrain *constrain = node->data;
Signature · 1 line
2.50.0
#1 lore raw
Quoted 8 lines · James Carter

The classperms list of deny rules is not being expanded. This causes an invalid read if "all" is used in the permissions.

Evaluate the classperms list of deny rules.

Reported-by oss-fuzz (issue 398075935)

Seeing no objections, I have merged this.
Jim

Quoted 26 lines
---
 libsepol/cil/src/cil_post.c | 8 ++++++++
 1 file changed, 8 insertions(+)
libsepol/cil/src/cil_post.c +8 -1
index 70e5b734..2b6dad73 100644
@@ -2265,6 +2265,14 @@ static int __cil_post_db_classperms_helper(struct cil_tree_node *node, uint32_t
                }
                break;
        }
+       case CIL_DENY_RULE: {
+               struct cil_deny_rule *deny = node->data;
+               rc = __evaluate_classperms_list(deny->classperms, db);
+               if (rc != SEPOL_OK) {
+                       goto exit;
+               }
+               break;
+       }
        case CIL_CONSTRAIN:
        case CIL_MLSCONSTRAIN: {
                struct cil_constrain *constrain = node->data;
--

2.50.0