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

Policies are not generated in order/not reproduceable #84

Open
JAORMX opened this issue Mar 14, 2021 · 8 comments
Open

Policies are not generated in order/not reproduceable #84

JAORMX opened this issue Mar 14, 2021 · 8 comments
Labels
question Further information is requested

Comments

@JAORMX
Copy link
Collaborator

JAORMX commented Mar 14, 2021

Describe the bug

When generating selinux policies in CI, one expects that subsequent calls to Udica will generate the same policy, however, this doesn't seem to be the case. While the policies are equivalent, the order of the items in the policy differs. This makes it really hard to detect if new changes come in the policy as the container evolves, and thus, prevents us from checking this in CI.

For instance:

$ diff /tmp/ci/selinuxd.cil selinuxd/security/selinuxd.cil
5,7d4
<     (allow process sysfs_t ( dir ( add_name create getattr ioctl lock open read remove_name rmdir search setattr write ))) 
<     (allow process sysfs_t ( file ( append create getattr ioctl lock map open read rename setattr unlink write ))) 
<     (allow process sysfs_t ( sock_file ( append getattr open read write ))) 
22a20,22
>     (allow process sysfs_t ( dir ( add_name create getattr ioctl lock open read remove_name rmdir search setattr write ))) 
>     (allow process sysfs_t ( file ( append create getattr ioctl lock map open read rename setattr unlink write ))) 
>     (allow process sysfs_t ( sock_file ( append getattr open read write ))) 

While that diff doesn't differ in content, the issue there is that that section was created a different order in the policy.

To Reproduce
Steps to reproduce the behavior:

  1. generate a policy for a container and store the file
  2. run the policy generation again and store the file
  3. diff them

Expected behavior
Running Udica for a container should always generate the same policy in the same order (so commands like diff show they're equivalent.

JAORMX added a commit to JAORMX/selinuxd that referenced this issue Mar 14, 2021
We're currently not able to check this as Udica doesn't generate the
policy files in order.

Related-bug: containers/udica#84

Signed-off-by: Juan Antonio Osorio Robles <[email protected]>
@JAORMX
Copy link
Collaborator Author

JAORMX commented Jul 1, 2021

@wrabcak anybody from the team that can check this out? This is preventing us from using Udica in CI environments.

@vmojzis
Copy link
Collaborator

vmojzis commented Jul 1, 2021

@JAORMX Thank you for reporting the issue, could you please share a container inspection file (or 2 that have the same content, just ordered differently) that is causing this issue?

@JAORMX
Copy link
Collaborator Author

JAORMX commented Jul 1, 2021

I don't have one handy right now, but this is how we were generating it https://github.com/JAORMX/selinuxd/blob/main/hack/ci/daemon-and-trace.sh#L48

vmojzis added a commit to vmojzis/udica that referenced this issue Jul 15, 2021
This should diminish differences between policies generated for the same
container (allow rules should be in the same order).

Fixes:  Two subsequent calls to Udica on the same container sometimes
        generate different policy files (functionally equivalent, but
        with different rule order). This issue makes it difficult to use
        udica for CI purposes.

        containers#84

Signed-off-by: Vit Mojzis <[email protected]>
@vmojzis
Copy link
Collaborator

vmojzis commented Jul 15, 2021

I'm sorry, but after trying several different containers I haven't been able to reproduce the issue.

I added sorting to some of the container inspect data, which should diminish differences between policies generated for the same container. But, without a reliable reproducer I cannot be sure this resolves your issue.
#97

@vmojzis vmojzis added the question Further information is requested label Jul 15, 2021
@JAORMX
Copy link
Collaborator Author

JAORMX commented Jul 18, 2021

@vmojzis I'm on PTO, but I'll provide a reproducer when I'm back. Or @jhrozek any chance you could look into this?

@jhrozek
Copy link

jhrozek commented Jul 29, 2021

@vmojzis I'm on PTO, but I'll provide a reproducer when I'm back. Or @jhrozek any chance you could look into this?

Hmm, I can't reproduce this either now because udica is throwing Couldn't create policy: 'BPF' . Is that a new problem? Should I create a new ticket for that?

@vmojzis
Copy link
Collaborator

vmojzis commented Jul 30, 2021

@vmojzis I'm on PTO, but I'll provide a reproducer when I'm back. Or @jhrozek any chance you could look into this?

Hmm, I can't reproduce this either now because udica is throwing Couldn't create policy: 'BPF' . Is that a new problem? Should I create a new ticket for that?

Yes, that is a different issue addressed by 6e74f83 (selinux-policy contains new capabilities unknown to udica).

vmojzis added a commit that referenced this issue Aug 25, 2021
This should diminish differences between policies generated for the same
container (allow rules should be in the same order).

Fixes:  Two subsequent calls to Udica on the same container sometimes
        generate different policy files (functionally equivalent, but
        with different rule order). This issue makes it difficult to use
        udica for CI purposes.

        #84

Signed-off-by: Vit Mojzis <[email protected]>
@vmojzis vmojzis removed the question Further information is requested label Nov 29, 2021
@vmojzis
Copy link
Collaborator

vmojzis commented Feb 28, 2022

@JAORMX @jhrozek 6e74f83 should be fixed now. Any update on the reproducer? Did aa2da32 help at all?

@vmojzis vmojzis added the question Further information is requested label Apr 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants