Skip to contentSkip to conversation

libsepol: validate empty common classes in scope indices

PATCH In review Christian Göttsche 2 participants 3 messages Dec 11, 2023 – Dec 12, 2023 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libsepol: validate empty common classes in scope indices

Validate no common classes inside scope indices are defined.

Reported-by oss-fuzz (issue 64849)

---
This probably also resolves issue 64854, which I could not reproduce locally.

Supersedes https://patchwork.kernel.org/project/selinux/patch/[email protected]/

---
 libsepol/src/policydb_validate.c | 2 ++
 1 file changed, 2 insertions(+)
libsepol/src/policydb_validate.c +2 -0
index bd8e9f8f..d86f885e 100644
@@ -1344,6 +1344,8 @@ bad:
 
 static int validate_scope_index(sepol_handle_t *handle, const scope_index_t *scope_index, validate_t flavors[])
 {
+	if (!ebitmap_is_empty(&scope_index->scope[SYM_COMMONS]))
+		goto bad;
 	if (validate_ebitmap(&scope_index->p_classes_scope, &flavors[SYM_CLASSES]))
 		goto bad;
 	if (validate_ebitmap(&scope_index->p_roles_scope, &flavors[SYM_ROLES]))
Signature · 1 line
2.43.0
Acked-by on v1 1/1
#1 lore raw
Quoted 5 lines · Christian Göttsche

Validate no common classes inside scope indices are defined.

Reported-by oss-fuzz (issue 64849)
Quoted 26 lines

---
This probably also resolves issue 64854, which I could not reproduce locally.

Supersedes https://patchwork.kernel.org/project/selinux/patch/[email protected]/

---
 libsepol/src/policydb_validate.c | 2 ++
 1 file changed, 2 insertions(+)
libsepol/src/policydb_validate.c +2 -1
index bd8e9f8f..d86f885e 100644
@@ -1344,6 +1344,8 @@ bad:
 
 static int validate_scope_index(sepol_handle_t *handle, const scope_index_t *scope_index, validate_t flavors[])
 {
+       if (!ebitmap_is_empty(&scope_index->scope[SYM_COMMONS]))
+               goto bad;
        if (validate_ebitmap(&scope_index->p_classes_scope, &flavors[SYM_CLASSES]))
                goto bad;
        if (validate_ebitmap(&scope_index->p_roles_scope, &flavors[SYM_ROLES]))
--

2.43.0

#2 lore raw
Quoted 11 lines · James Carter
Quoted 5 lines · Christian Göttsche

Validate no common classes inside scope indices are defined.

Reported-by oss-fuzz (issue 64849)

Merged.
Thanks,
Jim

Quoted 26 lines
Quoted 26 lines

---
This probably also resolves issue 64854, which I could not reproduce locally.

Supersedes https://patchwork.kernel.org/project/selinux/patch/[email protected]/

---
 libsepol/src/policydb_validate.c | 2 ++
 1 file changed, 2 insertions(+)
libsepol/src/policydb_validate.c +2 -1
index bd8e9f8f..d86f885e 100644
@@ -1344,6 +1344,8 @@ bad:
 
 static int validate_scope_index(sepol_handle_t *handle, const scope_index_t *scope_index, validate_t flavors[])
 {
+       if (!ebitmap_is_empty(&scope_index->scope[SYM_COMMONS]))
+               goto bad;
        if (validate_ebitmap(&scope_index->p_classes_scope, &flavors[SYM_CLASSES]))
                goto bad;
        if (validate_ebitmap(&scope_index->p_roles_scope, &flavors[SYM_ROLES]))
--

2.43.0