Bug 1760146 - machinectl cannot launch any containers due to SELinux violations
Summary: machinectl cannot launch any containers due to SELinux violations
Keywords:
Status: CLOSED EOL
Alias: None
Product: Fedora
Classification: Fedora
Component: selinux-policy
Version: 33
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: ---
Assignee: Zdenek Pytela
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-10-10 00:42 UTC by Ryan Gonzalez
Modified: 2023-09-15 00:19 UTC (History)
8 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2021-11-30 19:08:41 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
SELinux Policy Changes for nspawn (3.65 KB, text/plain)
2021-09-09 00:16 UTC, kytechnelson
no flags Details

Description Ryan Gonzalez 2019-10-10 00:42:03 UTC
Description of problem: machined cannot launch containers due 


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


How reproducible: Very easily.


Steps to Reproduce:
1. Create a new systemd-machined container if needed, e.g.: machinectl pull-raw  --verify=no https://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud.qcow2 centos
2. Try starting the machine, e.g. `machinectl start centos`.

Actual results:

machinectl fails with the following output:


Job for systemd-nspawn failed because the control process exited with error code.
See "systemctl status systemd-nspawn" and "journalctl -xe" for details.


Expected results:

The machine should start.

Additional info:

Here are the relevant lines from the journal:


Oct 09 19:24:44 localhost.localdomain audit[859]: AVC avc:  denied  { search } for  pid=859 comm="systemd-machine" name="5661" dev="proc" ino=82262 scontext=system_u:system_r:systemd_machined_t:s0 tcontext=system_u:system_r:unconfined_se>
Oct 09 19:24:44 localhost.localdomain systemd-nspawn[5647]: Failed to register machine: Access denied
Oct 09 19:24:44 localhost.localdomain systemd-nspawn[5647]: Parent died too early
Oct 09 19:24:44 localhost.localdomain systemd[1]: systemd-nspawn: Main process exited, code=exited, status=1/FAILURE


Once this denial is worked around via audit2allow, more appear:


type=AVC msg=audit(1570667820.295:558): avc:  denied  { read } for  pid=859 comm="systemd-machine" name="cgroup" dev="proc" ino=87639 scontext=system_u:system_r:systemd_machined_t:s0 tcontext=system_u:system_r:unconfined_service_t:s0 tclass=file permissive=0
type=AVC msg=audit(1570667892.124:591): avc:  denied  { open } for  pid=859 comm="systemd-machine" path="/proc/6529/cgroup" dev="proc" ino=92371 scontext=system_u:system_r:systemd_machined_t:s0 tcontext=system_u:system_r:unconfined_service_t:s0 tclass=file permissive=0


The ending audit2allow-generated module that makes `machinectl start` work entirely is:


module machined 1.0;

require {
	type unconfined_service_t;
	type systemd_machined_t;
	class dir search;
	class file { open read };
}

#============= systemd_machined_t ==============

#!!!! This avc is allowed in the current policy
allow systemd_machined_t unconfined_service_t:dir search;

#!!!! This avc is allowed in the current policy
allow systemd_machined_t unconfined_service_t:file read;
allow systemd_machined_t unconfined_service_t:file open;

Comment 1 Lukas Vrabec 2019-10-10 08:25:11 UTC
Hi Ryan, 

Could you please reproduce the scenario and attrach output of:

# ps -efZ | grep unconfined_service_t 

Thanks,
Lukas.

Comment 2 Ryan Gonzalez 2019-10-10 14:24:04 UTC
(In reply to Lukas Vrabec from comment #1)
> Hi Ryan, 
> 
> Could you please reproduce the scenario and attrach output of:
> 
> # ps -efZ | grep unconfined_service_t 
> 
> Thanks,
> Lukas.

There are no results other than the grep command itself. Note that machined works by starting a new systemd service in the background (systemd-nspawn@.service) to start the container, so it won't be running as it never actually gets to start.

Comment 3 Ryan Gonzalez 2019-12-05 01:15:18 UTC
Just did some more research into this, apparently the unconfined_service_t is actually systemd-nspawn. It's unlabeled so it ends up as unconfined_service_t, but machined doesn't have any permissions to check out unconfined_service_t?

Comment 4 Ryan Gonzalez 2019-12-05 01:17:08 UTC
Actually correction, it's sd-stubinit; since it's PID 1, machined probably inspects it to check the status of the container.

Comment 5 Fedora Admin XMLRPC Client 2020-01-23 16:23:52 UTC
This package has changed maintainer in the Fedora.
Reassigning to the new maintainer of this component.

Comment 6 Ben Cotton 2020-11-03 17:22:46 UTC
This message is a reminder that Fedora 31 is nearing its end of life.
Fedora will stop maintaining and issuing updates for Fedora 31 on 2020-11-24.
It is Fedora's policy to close all bug reports from releases that are no longer
maintained. At that time this bug will be closed as EOL if it remains open with a
Fedora 'version' of '31'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 31 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 7 Ben Cotton 2020-11-24 20:15:48 UTC
Fedora 31 changed to end-of-life (EOL) status on 2020-11-24. Fedora 31 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.

Comment 8 Ryan Gonzalez 2020-11-29 01:02:02 UTC
This still definitely applies to F33; the following is now required for machined to work:

allow systemd_machined_t unconfined_service_t:dir search;
allow systemd_machined_t unconfined_service_t:file { getattr ioctl open read };

Comment 9 kytechnelson 2021-08-29 01:01:24 UTC
I can confirm the same issue exists in Fedora 34 out of the box. I am able to successfully install the systemd-containers package, however, running a container through machinectl would fail with various errors until I worked through multiple SELinux policy adjustments (with the help of the selinux troubleshooter included in fedora server 34). I will include a copy of the SELinux policy adjustments I had to make to successfully run and shell into a systemd container managed through machinectl as soon as I can.

Comment 10 kytechnelson 2021-09-09 00:16:55 UTC
Created attachment 1821666 [details]
SELinux Policy Changes for nspawn

Comments also include the attribute changes that needed to be applied to folders under /var/lib/machines

Comment 11 kytechnelson 2021-09-09 00:20:04 UTC
I have uploaded the SELinux changes I had to make on Fedora 34 for nspawn to sucessfully run. Tagging need for review since issue is still occurring on Fedora 34.

Comment 12 Ben Cotton 2021-11-04 13:44:18 UTC
This message is a reminder that Fedora 33 is nearing its end of life.
Fedora will stop maintaining and issuing updates for Fedora 33 on 2021-11-30.
It is Fedora's policy to close all bug reports from releases that are no longer
maintained. At that time this bug will be closed as EOL if it remains open with a
Fedora 'version' of '33'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 33 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 13 Ben Cotton 2021-11-04 14:13:49 UTC
This message is a reminder that Fedora 33 is nearing its end of life.
Fedora will stop maintaining and issuing updates for Fedora 33 on 2021-11-30.
It is Fedora's policy to close all bug reports from releases that are no longer
maintained. At that time this bug will be closed as EOL if it remains open with a
Fedora 'version' of '33'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 33 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 14 Ben Cotton 2021-11-04 15:11:26 UTC
This message is a reminder that Fedora 33 is nearing its end of life.
Fedora will stop maintaining and issuing updates for Fedora 33 on 2021-11-30.
It is Fedora's policy to close all bug reports from releases that are no longer
maintained. At that time this bug will be closed as EOL if it remains open with a
Fedora 'version' of '33'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 33 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 15 Ben Cotton 2021-11-30 19:08:41 UTC
Fedora 33 changed to end-of-life (EOL) status on 2021-11-30. Fedora 33 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.

Comment 16 Red Hat Bugzilla 2023-09-15 00:19:06 UTC
The needinfo request[s] on this closed bug have been removed as they have been unresolved for 500 days


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