Skip to content

Commit

Permalink
libsepol: test for ebitmap_read() negative return value
Browse files Browse the repository at this point in the history
While fuzzing hll/pp, the fuzzer (AFL) crafted a policy which triggered
the following message without making the policy loading fail (the
program crashed with a segmentation fault later):

    security: ebitmap: map size 192 does not match my size 64 (high bit
    was 0)

This is because ebitmap_read() returned -EINVAL and this value was
handled as a successful return value by scope_index_read() because it
was not -1.

Signed-off-by: Nicolas Iooss <[email protected]>
  • Loading branch information
fishilico authored and stephensmalley committed Nov 16, 2016
1 parent 784b43b commit 0a32f3b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions libsepol/src/policydb.c
Original file line number Diff line number Diff line change
Expand Up @@ -3447,7 +3447,7 @@ static int scope_index_read(scope_index_t * scope_index,
int rc;

for (i = 0; i < num_scope_syms; i++) {
if (ebitmap_read(scope_index->scope + i, fp) == -1) {
if (ebitmap_read(scope_index->scope + i, fp) < 0) {
return -1;
}
}
Expand All @@ -3465,7 +3465,7 @@ static int scope_index_read(scope_index_t * scope_index,
return -1;
}
for (i = 0; i < scope_index->class_perms_len; i++) {
if (ebitmap_read(scope_index->class_perms_map + i, fp) == -1) {
if (ebitmap_read(scope_index->class_perms_map + i, fp) < 0) {
return -1;
}
}
Expand Down

0 comments on commit 0a32f3b

Please sign in to comment.