Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Policy fails to build due to unconfined role move #829

Open
cgzones opened this issue Oct 30, 2024 · 7 comments
Open

Policy fails to build due to unconfined role move #829

cgzones opened this issue Oct 30, 2024 · 7 comments

Comments

@cgzones
Copy link
Contributor

cgzones commented Oct 30, 2024

Commit ca3698d changed the definition of the unconfined_r role from the base module kernel to the non-base module unconfined.
While directly linking the policy via make validate works, loading such policy on an actual systems fails with the following error message:

...
Creating refpolicy base module base.conf                                                                                                                      
Compiling refpolicy base module                                                                                                                               
Creating refpolicy base module package                                                                                                                        
Installing refpolicy base.pp policy package.                                                                                                                  
Loading configured modules.                                                                                                                                   
Failed to resolve roletype statement at /var/lib/selinux/refpolicy/tmp/modules/400/unconfined/cil:5                                                           
Failed to resolve AST                                                                                                                                         
/usr/sbin/semodule:  Failed!                                                                                                                                  
make: *** [Rules.modular:59: load] Error 1

I don't think role definitions are supported in non-base modular policies (only role statements associating them to types).

@yizhao1
Copy link
Contributor

yizhao1 commented Nov 1, 2024

I also encountered this issue.

@pebenito
Copy link
Member

pebenito commented Nov 1, 2024

First, we need to fix the discrepancy between the two SELinux userspace behaviors. Then we can update refpolicy, if necessary.

cc @jwcart2

@jwcart2
Copy link
Contributor

jwcart2 commented Nov 1, 2024

I am not sure what is going on here. Roles most definitely can be in modules. It looks like a problem converting the module pp file to CIL (creating a roletype rule instead of a role), but I have test policy which has roles in modules and pp converted them to CIL just fine. I will investigate.

@jwcart2
Copy link
Contributor

jwcart2 commented Nov 1, 2024

I found the issue. It is in module_to_cil.c. It will not create user_r, staff_r, sysadm_r, system_r, or unconfined_r, so that duplicate role definitions are not created. I can remove unconfined_r from the list in module_to_cil.c, but I am worried that that would break other policies.

@pebenito
Copy link
Member

pebenito commented Nov 1, 2024

Each project's special case behavior is co-dependent on each other, making this a difficult cycle to break. I see the options as:

  1. revert the policy change, live with co-dependence until refpolicy3 stops using module to cil in favor of cascade (cc @dburgener )
  2. change refpolicy to emit cil instead of modules, bypassing module_to_cil.c behavior(?)
  3. ?

@jwcart2
Copy link
Contributor

jwcart2 commented Nov 1, 2024

We already allow types and type attributes to have duplicates if the multiple_decls field is set by calling cil_set_multiple_decls(). In secilc, this happens when you use the "-m" command-line option.

I could remove unconfined_r from the list in module_to_cil.c, allow multiple roles in CIL when the multiple_decls field is set, and change libsemanage to always call cil_set_multiple_decls() before calling cil_compile(). This should prevent problems with previous policies. Allowing multiple decls should be harmless.

@jwcart2
Copy link
Contributor

jwcart2 commented Nov 4, 2024

I sent a patch series to the SELinux list which will fix this.

pebenito added a commit to pebenito/refpolicy that referenced this issue Nov 12, 2024
There have been some discrepancies between semodule_link/_expand
and semodule -i, see SELinuxProject#829.  Add an extra CI test of installing
the modules using semodule -i.

Signed-off-by: Chris PeBenito <[email protected]>
pebenito added a commit to pebenito/refpolicy that referenced this issue Nov 22, 2024
There have been some discrepancies between semodule_link/_expand
and semodule -i, see SELinuxProject#829.  Add an extra CI test of installing
the modules using semodule -i.

Signed-off-by: Chris PeBenito <[email protected]>
pebenito added a commit to pebenito/refpolicy that referenced this issue Nov 22, 2024
There have been some discrepancies between semodule_link/_expand
and semodule -i, see SELinuxProject#829.  Add an extra CI test of installing
the modules using semodule -i.

Signed-off-by: Chris PeBenito <[email protected]>
pebenito added a commit to pebenito/refpolicy that referenced this issue Nov 22, 2024
There have been some discrepancies between semodule_link/_expand
and semodule -i, see SELinuxProject#829.  Add an extra CI test of installing
the modules using semodule -i.

Signed-off-by: Chris PeBenito <[email protected]>
pebenito added a commit to pebenito/refpolicy that referenced this issue Nov 22, 2024
There have been some discrepancies between semodule_link/_expand
and semodule -i, see SELinuxProject#829.  Add an extra CI test of installing
the modules using semodule -i.

Signed-off-by: Chris PeBenito <[email protected]>
pebenito added a commit to pebenito/refpolicy that referenced this issue Nov 22, 2024
There have been some discrepancies between semodule_link/_expand
and semodule -i, see SELinuxProject#829.  Add an extra CI test of installing
the modules using semodule -i.

Signed-off-by: Chris PeBenito <[email protected]>
pebenito added a commit to pebenito/refpolicy that referenced this issue Nov 22, 2024
There have been some discrepancies between semodule_link/_expand
and semodule -i, see SELinuxProject#829.  Add an extra CI test of installing
the modules using semodule -i.

Signed-off-by: Chris PeBenito <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants