Skip to content

Commit

Permalink
[WIP] libsepol: do not dump pdb->global block if it is NULL
Browse files Browse the repository at this point in the history
TODO: does it make sense to have a policy with ->global=NULL?

gdb session:

    Program received signal SIGSEGV, Segmentation fault.
    blocks_to_cil (pdb=0x6042e0) at module_to_cil.c:3760
    3760        rc = global_block_to_cil(pdb, block, stack);
    (gdb) bt
    #0  blocks_to_cil (pdb=0x6042e0) at module_to_cil.c:3760
    SELinuxProject#1  sepol_module_policydb_to_cil (fp=fp@entry=0x7ffff79d05e0
    <_IO_2_1_stdout_>, pdb=0x6042e0, linked=linked@entry=0) at
    module_to_cil.c:4047
    SELinuxProject#2  0x00007ffff7a86ac5 in sepol_module_package_to_cil
    (fp=fp@entry=0x7ffff79d05e0 <_IO_2_1_stdout_>, mod_pkg=0x604280) at
    module_to_cil.c:4076
    SELinuxProject#3  0x0000000000401acc in main (argc=<optimized out>,
    argv=<optimized out>) at pp.c:150

    (gdb) p pdb->global
    $1 = (avrule_block_t *) 0x0

Signed-off-by: Nicolas Iooss <[email protected]>
  • Loading branch information
fishilico committed Jun 30, 2022
1 parent ac0975d commit 84616d8
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions libsepol/src/module_to_cil.c
Original file line number Diff line number Diff line change
Expand Up @@ -3878,6 +3878,10 @@ static int linked_blocks_to_cil(struct policydb *pdb)
}

block = pdb->global;
if (!block) {
goto exit;
}

rc = global_block_to_cil(pdb, block, stack);
if (rc != 0) {
goto exit;
Expand Down

0 comments on commit 84616d8

Please sign in to comment.