Skip to contentSkip to conversation

libsepol: validate common classes have at least one permissions

PATCH In review Christian Göttsche 2 participants 3 messages Nov 13, 2023 – Nov 16, 2023 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libsepol: validate common classes have at least one permissions

The traditional language and CIL permit common classes only to be defined with at least one permission. Thus writing a common class without one will fail.

Reported-by oss-fuzz (issue 64059)
---
 libsepol/src/policydb_validate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
libsepol/src/policydb_validate.c +1 -1
index 016ab655..1121c8bb 100644
@@ -369,7 +369,7 @@ static int validate_common_datum(sepol_handle_t *handle, const common_datum_t *c
 {
 	if (validate_value(common->s.value, &flavors[SYM_COMMONS]))
 		goto bad;
-	if (common->permissions.nprim > PERM_SYMTAB_SIZE)
+	if (common->permissions.table->nel == 0 || common->permissions.nprim > PERM_SYMTAB_SIZE)
 		goto bad;
 
 	return 0;
Signature · 1 line
2.42.0
Acked-by on v1 1/1
#1 lore raw
Quoted 7 lines · Christian Göttsche

The traditional language and CIL permit common classes only to be defined with at least one permission. Thus writing a common class without one will fail.

Reported-by oss-fuzz (issue 64059)
Quoted 20 lines
---
 libsepol/src/policydb_validate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
libsepol/src/policydb_validate.c +1 -2
index 016ab655..1121c8bb 100644
@@ -369,7 +369,7 @@ static int validate_common_datum(sepol_handle_t *handle, const common_datum_t *c
 {
        if (validate_value(common->s.value, &flavors[SYM_COMMONS]))
                goto bad;
-       if (common->permissions.nprim > PERM_SYMTAB_SIZE)
+       if (common->permissions.table->nel == 0 || common->permissions.nprim > PERM_SYMTAB_SIZE)
                goto bad;
 
        return 0;
--

2.42.0

#2 lore raw
Quoted 4 lines · James Carter
Quoted 1 line · Christian Göttsche
Quoted 9 lines
Quoted 6 lines

The traditional language and CIL permit common classes only to be defined with at least one permission. Thus writing a common class without one will fail.

Reported-by oss-fuzz (issue 64059)

This patch has been merged.
Thanks,
Jim

Quoted 20 lines
Quoted 20 lines
---
 libsepol/src/policydb_validate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
libsepol/src/policydb_validate.c +1 -2
index 016ab655..1121c8bb 100644
@@ -369,7 +369,7 @@ static int validate_common_datum(sepol_handle_t *handle, const common_datum_t *c
 {
        if (validate_value(common->s.value, &flavors[SYM_COMMONS]))
                goto bad;
-       if (common->permissions.nprim > PERM_SYMTAB_SIZE)
+       if (common->permissions.table->nel == 0 || common->permissions.nprim > PERM_SYMTAB_SIZE)
                goto bad;
 
        return 0;
--

2.42.0