libsepol: validate common classes in scope indices
PATCH 1/1 libsepol: validate common classes in scope indices
Validate common classes inside scope indices similar to all other symbol table types.
Reported-by oss-fuzz (issue 64849)
Signed-off-by Christian Göttsche <[email protected]>
---
This probably also resolves issue 64854, which I could not reproduce locally.
--- libsepol/include/sepol/policydb/policydb.h | 1 + libsepol/src/policydb_validate.c | 2 ++ 2 files changed, 3 insertions(+)
libsepol/include/sepol/policydb/policydb.h +1 -0
@@ -430,6 +430,7 @@ typedef struct genfs {* subtract one) into the global policydb->scope array. */ typedef struct scope_index { ebitmap_t scope[SYM_NUM]; +#define p_commons_scope scope[SYM_COMMONS] #define p_classes_scope scope[SYM_CLASSES] #define p_roles_scope scope[SYM_ROLES] #define p_types_scope scope[SYM_TYPES]
libsepol/src/policydb_validate.c +2 -0
@@ -1344,6 +1344,8 @@ bad:static int validate_scope_index (sepol_handle_t *handle,const scope_index_t *scope_index,validate_t flavors[]) { +if (validate_ebitmap (&scope_index->p_commons_scope, &flavors[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
Quoted 31 lines · Christian Göttsche
Validate common classes inside scope indices similar to all other symbol table types.
Reported-by oss-fuzz (issue 64849)Signed-off-by Christian Göttsche <[email protected]>---
This probably also resolves issue 64854, which I could not reproduce locally.--- libsepol/include/sepol/policydb/policydb.h | 1 + libsepol/src/policydb_validate.c | 2 ++ 2 files changed, 3 insertions(+)libsepol/include/sepol/policydb/policydb.h +1
-0@@ -430,6 +430,7 @@ typedef struct genfs {* subtract one) into the global policydb->scope array. */ typedef struct scope_index { ebitmap_t scope[SYM_NUM]; +#define p_commons_scope scope[SYM_COMMONS] #define p_classes_scope scope[SYM_CLASSES] #define p_roles_scope scope[SYM_ROLES] #define p_types_scope scope[SYM_TYPES]libsepol/src/policydb_validate.c +0
-0
libsepol/src/policydb_validate.c bad: · line 1348
Quoted 5 lines
libsepol/src/policydb_validate.c +2
-0@@ -1344,6 +1344,8 @@ bad:static int validate_scope_index (sepol_handle_t *handle,const scope_index_t *scope_index,validate_t flavors[]) { +if (validate_ebitmap (&scope_index->p_commons_scope, &flavors[SYM_COMMONS ])) + goto bad;
As far as I know, there will never be any commons in the scope index, so it would be better to just check that it is empty.
Thanks,
Jim
Quoted 7 lines
libsepol/src/policydb_validate.c +0
-1if (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