Skip to content

Commit 589e2db

Browse files
cgzonesjwcart2
authored andcommitted
libsepol: check scope permissions refer to valid class
Validate that the permission maps in the scope index refer to a valid class datum. Otherwise since commit 52e5c30 ("libsepol: move unchanged data out of loop") this can lead to a NULL dereference in the class existence check during linking. Reported-by: oss-fuzz (issue 69655) Signed-off-by: Christian Göttsche <[email protected]> Acked-by: James Carter <[email protected]>
1 parent 1efc121 commit 589e2db

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

libsepol/src/policydb_validate.c

+6-2
Original file line numberDiff line numberDiff line change
@@ -1468,6 +1468,8 @@ static int validate_range_trans_rules(sepol_handle_t *handle, const range_trans_
14681468

14691469
static int validate_scope_index(sepol_handle_t *handle, const scope_index_t *scope_index, validate_t flavors[])
14701470
{
1471+
uint32_t i;
1472+
14711473
if (!ebitmap_is_empty(&scope_index->scope[SYM_COMMONS]))
14721474
goto bad;
14731475
if (validate_ebitmap(&scope_index->p_classes_scope, &flavors[SYM_CLASSES]))
@@ -1484,8 +1486,10 @@ static int validate_scope_index(sepol_handle_t *handle, const scope_index_t *sco
14841486
goto bad;
14851487
if (validate_ebitmap(&scope_index->p_cat_scope, &flavors[SYM_CATS]))
14861488
goto bad;
1487-
if (scope_index->class_perms_len > flavors[SYM_CLASSES].nprim)
1488-
goto bad;
1489+
1490+
for (i = 0; i < scope_index->class_perms_len; i++)
1491+
if (validate_value(i + 1, &flavors[SYM_CLASSES]))
1492+
goto bad;
14891493

14901494
return 0;
14911495

0 commit comments

Comments
 (0)