Bug 1520033 - systemd containers now cause AVC denials about init_t and container_file_t
Summary: systemd containers now cause AVC denials about init_t and container_file_t
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: selinux-policy
Version: 27
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Lukas Vrabec
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-12-02 10:12 UTC by Jan Pazdziora
Modified: 2018-01-02 16:47 UTC (History)
17 users (show)

Fixed In Version: selinux-policy-3.13.1-283.19.fc27
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-01-02 16:47:16 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Jan Pazdziora 2017-12-02 10:12:00 UTC
Description of problem:

Running fedora:25 systemd container now produces AVC denials during removal and start.

Version-Release number of selected component (if applicable):

container-selinux-2.29-1.fc27.noarch
docker-1.13.1-42.git4402c09.fc27.x86_64
oci-systemd-hook-0.1.13-1.gitafe4b4a.fc27.x86_64

but also versions from updates-testing:

container-selinux-2.36-1.fc27.noarch
docker-1.13.1-44.git584d391.fc27.x86_64
oci-systemd-hook-0.1.13-1.gitafe4b4a.fc27.x86_64

How reproducible:

Deterministic.

Steps to Reproduce:
1. setsebool -P container_manage_cgroup 1
2. systemctl start docker
3. docker pull registry.fedoraproject.org/fedora:25
4. docker run -e container=docker --name=systemd -d registry.fedoraproject.org/fedora:25 /usr/sbin/init
5. sleep 20 ; docker exec systemd systemctl
6. docker rm -f systemd
7. docker run -e container=docker --name=systemd -d registry.fedoraproject.org/fedora:25 /usr/sbin/init
8. sleep 20 ; docker exec systemd systemctl

Actual results:

No AVC denial with the first docker run.

The docker rm produces

type=AVC msg=audit(1512207018.002:188): avc:  denied  { rmdir } for  pid=1 comm="systemd" name="docker-0f00ae777aede773366c88bea8deb2564d01dc8d96130578e8149dbf9996d25d.scope" dev="cgroup" ino=356 scontext=system_u:system_r:init_t:s0 tcontext=system_u:object_r:container_file_t:s0:c518,c803 tclass=dir permissive=0

The second docker run produces

type=AVC msg=audit(1512207025.627:194): avc:  denied  { create } for  pid=1 comm="systemd" name="docker-b10ae8cc4f22d4191eba53d3a7edb564605a9fe0de91295490f7cc0219406813.scope" scontext=system_u:system_r:init_t:s0 tcontext=system_u:object_r:container_file_t:s0:c518,c803 tclass=dir permissive=0

type=AVC msg=audit(1512207025.630:195): avc:  denied  { create } for  pid=1 comm="systemd" name="var-lib-docker-devicemapper-mnt-c8418060b6c066f20a36380afad76fca47839f1dc4fac066db8a56d4e151f0a3.mount" scontext=system_u:system_r:init_t:s0 tcontext=system_u:object_r:container_file_t:s0:c518,c803 tclass=dir permissive=0

type=AVC msg=audit(1512207025.631:196): avc:  denied  { create } for  pid=1 comm="systemd" name="var-lib-docker-containers-b10ae8cc4f22d4191eba53d3a7edb564605a9fe0de91295490f7cc0219406813-shm.mount" scontext=system_u:system_r:init_t:s0 tcontext=system_u:object_r:container_file_t:s0:c518,c803 tclass=dir permissive=0

Expected results:

No AVC denials at all.

Additional info:

The docker exec systemd systemctl calls show that the containers and systemd in them are actually running fine.

Comment 1 Jan Pazdziora 2017-12-02 12:14:49 UTC
I see the same results when using fedora:26 or fedora:27 images.

OTOH, I don't see any AVC denials when running on Fedora 26, updates-testing or not.

Comment 4 Daniel Walsh 2017-12-04 12:39:55 UTC
Jan could you make sure that oci-systemd-hook did not do something nuts like relabling all of /sys/fs/cgroup

 find /sys/fs/cgroup/ -printf "%P %Z\n" | grep container_file_t

Comment 5 Jan Pazdziora 2017-12-05 07:34:51 UTC
I can see

systemd/system.slice system_u:object_r:container_file_t:s0:c173,c340
systemd/system.slice/docker-containerd.service system_u:object_r:container_file_t:s0:c173,c340
systemd/system.slice/docker-containerd.service/cgroup.clone_children system_u:object_r:container_file_t:s0:c173,c340
systemd/system.slice/docker-containerd.service/tasks system_u:object_r:container_file_t:s0:c173,c340
systemd/system.slice/docker-containerd.service/notify_on_release system_u:object_r:container_file_t:s0:c173,c340
systemd/system.slice/docker-containerd.service/cgroup.procs system_u:object_r:container_file_t:s0:c173,c340

Comment 7 Lukas Vrabec 2017-12-11 17:04:55 UTC
Fix will be part of next selinux-policy build. 

Thank you Dan for PR.

Comment 8 Fedora Update System 2017-12-13 08:25:13 UTC
selinux-policy-3.13.1-283.18.fc27 has been submitted as an update to Fedora 27. https://bodhi.fedoraproject.org/updates/FEDORA-2017-8225c4e502

Comment 9 Fedora Update System 2017-12-14 11:11:25 UTC
selinux-policy-3.13.1-283.18.fc27 has been pushed to the Fedora 27 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2017-8225c4e502

Comment 11 Fedora Update System 2017-12-20 11:23:00 UTC
selinux-policy-3.13.1-283.19.fc27 has been submitted as an update to Fedora 27. https://bodhi.fedoraproject.org/updates/FEDORA-2017-8225c4e502

Comment 12 Fedora Update System 2017-12-21 20:20:30 UTC
selinux-policy-3.13.1-283.19.fc27 has been pushed to the Fedora 27 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2017-8225c4e502

Comment 13 Fedora Update System 2018-01-02 16:47:16 UTC
selinux-policy-3.13.1-283.19.fc27 has been pushed to the Fedora 27 stable repository. If problems still persist, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.