Bug 1462382

Summary: SELinux denies systemd-importd access to /var/lib/machines
Product: [Fedora] Fedora Reporter: Aditya Shah <aditya-shah>
Component: selinux-policyAssignee: Lukas Vrabec <lvrabec>
Status: CLOSED DUPLICATE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 26CC: david.ward, dominick.grift, dwalsh, lvrabec, mgrepl, mpatel, plautrba, pmoore, ssekidde, zeekec
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-05-29 11:42:43 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:
Attachments:
Description Flags
avcs none

Description Aditya Shah 2017-06-16 23:40:33 UTC
I am not very informed about SELinux, so I am giving everything I can in this report. I was trying to import an image of CentOS using machinectl as,

$ sudo machinectl pull-raw http://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud.raw.tar.gz

But it failed saying "Failed to transfer image: Access denied," with a SELinux alert.

The alert reports, that systemd-importd was denied read access to /var/lib/machines. I know that this directory is where machinectl pulls and stores images.

If I browse through nautilus and look at the properties of /var/lib/machines, its SELinux Context is system_u:object_r:systemd_machined_var_lib_t:s0.

Expected behaviour:

Image is pulled, extracted and stored under a new directory of the image name.

Comment 1 Mrunal Patel 2017-12-08 21:46:32 UTC
Dan, this is the AVC generated when trying to pull:

----
time->Fri Dec  8 15:45:23 2017
type=AVC msg=audit(1512769523.719:9390): avc:  denied  { read } for  pid=21095 comm="systemd-importd" name="machines" dev="dm-0" ino=6161837 scontext=system_u:system_r:init_t:s0 tcontext=system_u:object_r:systemd_machined_var_lib_t:s0 tclass=dir permissive=0

Comment 2 Daniel Walsh 2018-01-11 18:26:18 UTC
THis is pretty broken.  Making init_t is the easiest solution. 

But it looks like systemd-import is creating a new file system and mounting it

I think we will need at least the following:

+allow init_t daemon:process2 nnp_transition;
+allow init_t systemprocess:process2 nnp_transition;

There are some of the other AVC's I get when I run this command in permissive mode.

#!!!! This avc can be allowed using the boolean 'nis_enabled'
allow init_t http_port_t:tcp_socket name_connect;

#!!!! This avc can be allowed using the boolean 'domain_kernel_load_modules'
allow init_t kernel_t:system module_request;
allow init_t loop_control_device_t:chr_file { ioctl open read write };
allow init_t systemd_machined_var_lib_t:dir { mounton read };
allow init_t unlabeled_t:dir { add_name remove_name setattr write };
allow init_t unlabeled_t:file { create setattr unlink write };

Comment 3 Daniel Walsh 2018-01-11 18:27:13 UTC
Created attachment 1380155 [details]
avcs

Comment 4 Lukas Vrabec 2018-01-15 14:25:56 UTC
Dan,

We should write policy for systemd-importd. 

I'll try to do it in next sprint.

Comment 5 Fedora End Of Life 2018-05-03 07:56:01 UTC
This message is a reminder that Fedora 26 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 26. 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 '26'.

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 26 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 6 Fedora End Of Life 2018-05-29 11:42:43 UTC
Fedora 26 changed to end-of-life (EOL) status on 2018-05-29. Fedora 26
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 7 David Ward 2018-12-01 17:00:30 UTC
This is a duplicate of bug 1318047, which is unresolved. Please change the status of this bug. (This is the third result on Google for "systemd-importd selinux".)

Comment 8 Lukas Vrabec 2019-05-02 08:11:41 UTC

*** This bug has been marked as a duplicate of bug 1318047 ***