When a roleattribute is in a declared scope, CIL roletype statements are generated for all types associated with it. This incorrectly includes types that are associated with the roleattribute in optional blocks, which can result in CIL resolution failures if the optional block is turned off due to a missing type. So, change the roletype CIL statement generation with roleattributes to mimic the behavior of roles, ensuring declared roleattributes are only associated with in-scope types. Signed-off-by: Steve Lawrence <slawrence@xxxxxxxxxx> Reported-by: Miroslav Grepl <mgrepl@xxxxxxxxxx> --- libsepol/src/module_to_cil.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libsepol/src/module_to_cil.c b/libsepol/src/module_to_cil.c index 8d16d3e..1ded21d 100644 --- a/libsepol/src/module_to_cil.c +++ b/libsepol/src/module_to_cil.c @@ -2091,7 +2091,9 @@ static int role_to_cil(int indent, struct policydb *pdb, struct avrule_block *UN for (i = 0; i < num_types; i++) { - cil_println(indent, "(roletype %s %s)", key, types[i]); + if (is_id_in_scope(pdb, decl_stack, types[i], SYM_TYPES)) { + cil_println(indent, "(roletype %s %s)", key, types[i]); + } } break; -- 2.1.0 _______________________________________________ Selinux mailing list Selinux@xxxxxxxxxxxxx To unsubscribe, send email to Selinux-leave@xxxxxxxxxxxxx. To get help, send an email containing "help" to Selinux-request@xxxxxxxxxxxxx.