Bug 2178990

Summary: Containers with custom policy fails to start on OCP 4.13 duo to access denial to devices
Product: Red Hat Enterprise Linux 9 Reporter: lpivarc
Component: container-selinuxAssignee: Jindrich Novy <jnovy>
Status: CLOSED ERRATA QA Contact: atomic-bugs <atomic-bugs>
Severity: high Docs Contact:
Priority: unspecified    
Version: 9.3CC: ajia, dbasunag, ddarrah, dollierp, dornelas, dshchedr, dwalsh, fdeutsch, jnovy, jwboyer, lfriedma, lsm5, mboddu, plautrba, qzhang, sgott, travier, tsweeney, vmojzis, ypu
Target Milestone: rcKeywords: Triaged
Target Release: 9.2   
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: container-selinux-2.205.0-1.el9_2 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 2179465 2181174 (view as bug list) Environment:
Last Closed: 2023-05-09 07:33:44 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 2177924, 2179392, 2179465, 2181174    

Description lpivarc 2023-03-16 11:47:02 UTC
Description of problem:
Trying to run a container with custom policy[0] fails as the starting process cannot access devices (such as /dev/null).
The produced avc is
type=AVC msg=audit(1678952803.346:303): avc:  denied  { open } for  pid=1905336 comm="virt-launcher-m" path="/dev/null" dev="tmpfs" ino=6 scontext=system_u:system_r:virt_launcher.process:s0:c804,c995 tcontext=system_u:object_r:container_file_t:s0:c804,c995 tclass=chr_file permissive=0

This seems to originate from https://github.com/containers/container-selinux/commit/24e57848527bcddad025316fa57493926ff1dfbf#diff-1cdb378311a88c884861f2d5996bca97ec20a49b1d66211dced87b2619c17ba9L826

[0] https://github.com/kubevirt/kubevirt/blob/main/cmd/virt-handler/virt_launcher.cil

Version-Release number of selected component (if applicable):
Running Openshift 4.13.0-0.nightly-2023-03-14-053612 which uses
CentOS Stream CoreOS 413.92.202303061740-0 (Plow)

Additionally:
Name        : container-selinux
Epoch       : 3
Version     : 2.199.0
Release     : 1.el9

Name        : selinux-policy
Version     : 38.1.8
Release     : 1.el9


How reproducible:
Run container/pod with custom SELinux policy

Steps to Reproduce:
1.
2.
3.

Actual results:


Expected results:


Additional info:

Comment 2 Daniel Walsh 2023-03-16 12:23:25 UTC
This looks like a bug in the policy of whatever package shipped

system_u:system_r:virt_launcher.process:s0:c804,c995

Comment 3 Daniel Walsh 2023-03-16 12:24:47 UTC
This is definitely not a container-selinux issue

Comment 4 lpivarc 2023-03-16 12:47:22 UTC
Let me just mention this was previously working, for example on 8.6 we are happily running this. My suspicion is that any workload on OCP using custom policy will face this issue. Are all policies expected to adjust to RHEL 9.2/OCP 4.13 now? In other words isn't this regression?

Comment 8 Daniel Walsh 2023-03-16 14:25:26 UTC
So this was intentional.  Because we wanted to allow two podman instances to run on a system and be isolated from each other, with one supporting container_file_t and the other using a different file type.

Both being container_domains.

I guess I can create a new domain, which works just like container_domain, but does not have access to container_file_t.

Comment 9 Daniel Walsh 2023-03-16 14:32:55 UTC
If I add


+manage_dirs_pattern(svirt_sandbox_domain, container_file_t, container_file_t)
+manage_files_pattern(svirt_sandbox_domain, container_file_t, container_file_t)
+manage_lnk_files_pattern(svirt_sandbox_domain, container_file_t, container_file_t)
+manage_chr_files_pattern(svirt_sandbox_domain, container_file_t, container_file_t)
+manage_blk_files_pattern(svirt_sandbox_domain, container_file_t, container_file_t)
+manage_sock_files_pattern(svirt_sandbox_domain, container_file_t, container_file_t)


Then I think that will fix your problem, and still give me the isolation I want.

Comment 10 sgott 2023-03-16 14:35:46 UTC
Brilliant, thank you for the clarity. What you're up to is completely sensible.

Comment 11 lpivarc 2023-03-16 14:37:56 UTC
Thank Daniel,

It seems good to me as well. Can we, therefore, assume this will be fixed in 9.2 which would then OCP 4.13 consume?

Comment 12 Tom Sweeney 2023-03-17 00:22:25 UTC
@dwalsh where is the new domain going to live, and is this something you can get together in the near term?

FYI @dornelas and @travier

Comment 13 Daniel Walsh 2023-03-17 12:31:16 UTC
We need a new version of container-selinux packaged up for RHEL.

container-selinux-2.205.0

Comment 14 Tom Sweeney 2023-03-17 15:54:44 UTC
@dwalsh I'm assuming that adding container-selinux-2.205.0 needs to be a ZeroDay fix for RHEL 8.8 and 9.2.  If you disagree, please let me know.

@jnovy heads up and assigning to you for any further packaging or BZ needs.
@travier heads up too.

Comment 23 Jindrich Novy 2023-03-20 09:33:24 UTC
Re-requesting z+ and fixing ITR. Also dev acking as in the worst case we can remove the user_namespace class to allow the build to pass.

Comment 24 Jindrich Novy 2023-03-20 11:32:54 UTC
*** Bug 2179392 has been marked as a duplicate of this bug. ***

Comment 25 Tom Sweeney 2023-03-20 14:46:13 UTC
Setting back to Blocker+ and ITR of 9.2

Comment 38 errata-xmlrpc 2023-05-09 07:33:44 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (container-selinux bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2023:2206

Comment 39 Red Hat Bugzilla 2023-09-19 04:34:33 UTC
The needinfo request[s] on this closed bug have been removed as they have been unresolved for 120 days