Bug 1486567 - SElinux systemd-resolved wrong label on /run/systemd/resolve/resolv.conf
Summary: SElinux systemd-resolved wrong label on /run/systemd/resolve/resolv.conf
Status: CLOSED EOL
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:
Keywords:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-08-30 07:47 UTC by Thilo Bangert
Modified: 2018-11-30 22:36 UTC (History)
8 users (show)

(edit)
Clone Of:
(edit)
Last Closed: 2018-11-30 22:36:56 UTC


Attachments (Terms of Use)

Description Thilo Bangert 2017-08-30 07:47:54 UTC
Description of problem:


If you use networkd and/or resolved, /etc/resolv.conf is a link to /run/systemd/resolve/resolv.conf.

However, the selinux attributes of /run/systemd/resolve/resolv.conf are wrong and consequently a number of daemons/process cannot access /etc/resolv.conf


Running 

sudo restorecon -Rv /run/systemd/

fixes the problem with the following output:
Relabeled /run/systemd/resolve/resolv.conf from system_u:object_r:systemd_resolved_var_run_t:s0 to system_u:object_r:net_conf_t:s0


Version-Release number of selected component (if applicable):
selinux-policy-3.13.1-260.6.fc26.src.rpm

How reproducible:
After reboot the selinux labels are wrong again.

This is related to bug #1471545

Comment 1 Anthony Messina 2017-12-17 17:19:06 UTC
This issue continues to occur in F27: selinux-policy-3.13.1-283.17.fc27.noarch

Can you update the version?

Comment 2 Lukas Vrabec 2017-12-18 23:20:22 UTC
Hi, 

I enabled: 

systemctl status systemd-networkd
● systemd-networkd.service - Network Service
   Loaded: loaded (/usr/lib/systemd/system/systemd-networkd.service; enabled; vendor preset: disabled)
   Active: active (running) since Tue 2017-12-19 00:15:23 CET; 3min 8s ago
     Docs: man:systemd-networkd.service(8)
 Main PID: 564 (systemd-network)
   Status: "Processing requests..."
    Tasks: 1 (limit: 4915)
   CGroup: /system.slice/systemd-networkd.service
           └─564 /usr/lib/systemd/systemd-networkd

Dec 19 00:15:22 virt-fedora-rawhide systemd[1]: Starting Network Service...
Dec 19 00:15:23 virt-fedora-rawhide systemd-networkd[564]: Enumeration completed
Dec 19 00:15:23 virt-fedora-rawhide systemd[1]: Started Network Service.
Dec 19 00:15:29 virt-fedora-rawhide systemd-networkd[564]: ens3: Gained carrier
Dec 19 00:15:30 virt-fedora-rawhide systemd-networkd[564]: ens3: Gained IPv6LL
Dec 19 00:15:31 virt-fedora-rawhide systemd-networkd[564]: virbr0-nic: Gained carrier
Dec 19 00:15:32 virt-fedora-rawhide systemd-networkd[564]: virbr0-nic: Lost carrier

 systemctl status systemd-resolved
● systemd-resolved.service - Network Name Resolution
   Loaded: loaded (/usr/lib/systemd/system/systemd-resolved.service; enabled; vendor preset: disabled)
   Active: active (running) since Tue 2017-12-19 00:15:29 CET; 3min 19s ago
     Docs: man:systemd-resolved.service(8)
           https://www.freedesktop.org/wiki/Software/systemd/resolved
           https://www.freedesktop.org/wiki/Software/systemd/writing-network-configuration-managers
           https://www.freedesktop.org/wiki/Software/systemd/writing-resolver-clients
 Main PID: 803 (systemd-resolve)
   Status: "Processing requests..."
    Tasks: 1 (limit: 4915)
   CGroup: /system.slice/systemd-resolved.service
           └─803 /usr/lib/systemd/systemd-resolved

Dec 19 00:15:28 virt-fedora-rawhide systemd[1]: Starting Network Name Resolution...
Dec 19 00:15:28 virt-fedora-rawhide systemd-resolved[803]: Positive Trust Anchors:
Dec 19 00:15:28 virt-fedora-rawhide systemd-resolved[803]: . IN DS 19036 8 2 49aac11d7b6f6446702e54a16073
Dec 19 00:15:28 virt-fedora-rawhide systemd-resolved[803]: . IN DS 20326 8 2 e06d44b80b8f1d39a95c0b0d7c65
Dec 19 00:15:28 virt-fedora-rawhide systemd-resolved[803]: Negative trust anchors: 10.in-addr.arpa 16.172
Dec 19 00:15:29 virt-fedora-rawhide systemd-resolved[803]: Using system hostname 'virt-fedora-rawhide'.
Dec 19 00:15:29 virt-fedora-rawhide systemd[1]: Started Network Name Resolution.


then rebooted the machine and I have no issue with labels:

#ls -Z /run/systemd/resolve 
                system_u:object_r:net_conf_t:s0 resolv.conf
system_u:object_r:systemd_resolved_var_run_t:s0 stub-resolv.conf

Could you attach working reproduced please? 

Thanks,
Lukas.

Comment 3 Paul DeStefano 2018-01-16 17:04:03 UTC
This happend to me too in F27.  I all I did was enable networkd and resolved, disable NetworkManager, and link /etc/resolv.conf to /run/systemd/resolve/resolv.conf, as directed in the man page for systemd-resolved.  Did you so that last part?

(Although, I'm still not sure I understand the three modes, so maybe I'm not doing what I mean to do.  In any case, this is a supported mode, and it's broken.)

When you say "no issues," are you running services like sshd, chronyd, cupsd?

What's worse is that something is relabeling /run/systemd/resolve/resolve.conf.  I ran restorecon on it last night, and when I woke up, it was wrong again and I had to run restorecon again.  He following list of AVCs is from *after* I "fixed" the context of this file.  So, something broke it again.  That makes no sense at all since networkd is static config, so, who is rewriting resolved.conf

                                        
Jan 16 08:39:36 hostname audit[1796]: AVC avc:  denied  { getattr } for  pid=1796 comm="tor" path="/run/systemd/resolve/resolv.conf" dev="tmpfs" ino=209309 scontext=system_u:system_r:tor_t:s0 tcontext=system_u:object_r:systemd_resolved_var_run_t:s0 tclass=file permissive=0
Jan 16 08:39:39 hostname audit[7383]: AVC avc:  denied  { read } for  pid=7383 comm="rpm" name="resolv.conf" dev="tmpfs" ino=209309 scontext=system_u:system_r:setroubleshootd_t:s0-s0:c0.c1023 tcontext=system_u:object_r:systemd_resolved_var_run_t:s0 tclass=file permissive=0
Jan 16 08:39:39 hostname audit[7384]: AVC avc:  denied  { read } for  pid=7384 comm="rpm" name="resolv.conf" dev="tmpfs" ino=209309 scontext=system_u:system_r:setroubleshootd_t:s0-s0:c0.c1023 tcontext=system_u:object_r:systemd_resolved_var_run_t:s0 tclass=file permissive=0
Jan 16 08:39:39 hostname audit[7387]: AVC avc:  denied  { read } for  pid=7387 comm="rpm" name="resolv.conf" dev="tmpfs" ino=209309 scontext=system_u:system_r:setroubleshootd_t:s0-s0:c0.c1023 tcontext=system_u:object_r:systemd_resolved_var_run_t:s0 tclass=file permissive=0
Jan 16 08:39:54 hostname audit[7430]: AVC avc:  denied  { getattr } for  pid=7430 comm="sshd" path="/run/systemd/resolve/resolv.conf" dev="tmpfs" ino=209309 scontext=system_u:system_r:sshd_t:s0-s0:c0.c1023 tcontext=system_u:object_r:systemd_resolved_var_run_t:s0 tclass=file permissive=0
Jan 16 08:39:54 hostname audit[7430]: AVC avc:  denied  { read } for  pid=7430 comm="sshd" name="resolv.conf" dev="tmpfs" ino=209309 scontext=system_u:system_r:sshd_t:s0-s0:c0.c1023 tcontext=system_u:object_r:systemd_resolved_var_run_t:s0 tclass=file permissive=0
Jan 16 08:39:57 hostname audit[7439]: AVC avc:  denied  { read } for  pid=7439 comm="rpm" name="resolv.conf" dev="tmpfs" ino=209309 scontext=system_u:system_r:setroubleshootd_t:s0-s0:c0.c1023 tcontext=system_u:object_r:systemd_resolved_var_run_t:s0 tclass=file permissive=0
Jan 16 08:39:57 hostname audit[7441]: AVC avc:  denied  { read } for  pid=7441 comm="rpm" name="resolv.conf" dev="tmpfs" ino=209309 scontext=system_u:system_r:setroubleshootd_t:s0-s0:c0.c1023 tcontext=system_u:object_r:systemd_resolved_var_run_t:s0 tclass=file permissive=0
Jan 16 08:39:58 hostname audit[7442]: AVC avc:  denied  { read } for  pid=7442 comm="rpm" name="resolv.conf" dev="tmpfs" ino=209309 scontext=system_u:system_r:setroubleshootd_t:s0-s0:c0.c1023 tcontext=system_u:object_r:systemd_resolved_var_run_t:s0 tclass=file permissive=0
Jan 16 08:39:58 hostname audit[7443]: AVC avc:  denied  { read } for  pid=7443 comm="rpm" name="resolv.conf" dev="tmpfs" ino=209309 scontext=system_u:system_r:setroubleshootd_t:s0-s0:c0.c1023 tcontext=system_u:object_r:systemd_resolved_var_run_t:s0 tclass=file permissive=0
Jan 16 08:39:58 hostname audit[7444]: AVC avc:  denied  { read } for  pid=7444 comm="rpm" name="resolv.conf" dev="tmpfs" ino=209309 scontext=system_u:system_r:setroubleshootd_t:s0-s0:c0.c1023 tcontext=system_u:object_r:systemd_resolved_var_run_t:s0 tclass=file permissive=0
Jan 16 08:40:36 hostname audit[1796]: AVC avc:  denied  { getattr } for  pid=1796 comm="tor" path="/run/systemd/resolve/resolv.conf" dev="tmpfs" ino=209309 scontext=system_u:system_r:tor_t:s0 tcontext=system_u:object_r:systemd_resolved_var_run_t:s0 tclass=file permissive=0
Jan 16 08:40:39 hostname audit[7628]: AVC avc:  denied  { read } for  pid=7628 comm="rpm" name="resolv.conf" dev="tmpfs" ino=209309 scontext=system_u:system_r:setroubleshootd_t:s0-s0:c0.c1023 tcontext=system_u:object_r:systemd_resolved_var_run_t:s0 tclass=file permissive=0
Jan 16 08:40:39 hostname audit[7629]: AVC avc:  denied  { read } for  pid=7629 comm="rpm" name="resolv.conf" dev="tmpfs" ino=209309 scontext=system_u:system_r:setroubleshootd_t:s0-s0:c0.c1023 tcontext=system_u:object_r:systemd_resolved_var_run_t:s0 tclass=file permissive=0
Jan 16 08:40:39 hostname audit[7630]: AVC avc:  denied  { read } for  pid=7630 comm="rpm" name="resolv.conf" dev="tmpfs" ino=209309 scontext=system_u:system_r:setroubleshootd_t:s0-s0:c0.c1023 tcontext=system_u:object_r:systemd_resolved_var_run_t:s0 tclass=file permissive=0

The fact that the file doesn't have the correct context is the first problem.  So, even if you aren't experiencing any consequences, you should see that.  If not, then that's important information, because I am and I'm Fedora policy.  If restorecon thinks it is being created wrong, then that is a bug that needs to be fixed.

Comment 4 Fedora End Of Life 2018-05-03 07:53:19 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 5 Thilo Bangert 2018-05-03 08:28:35 UTC
As reported in comment #1, this issue is also a problem in Fedora 27.

Comment 6 Paul DeStefano 2018-05-03 16:27:50 UTC
Thanks Thilo.  I'm on Fedora28, now, and I *think* it might be fixed there.  Check when you can.

Comment 7 Mathieu Chouquet-Stringer 2018-05-03 21:05:29 UTC
Yup, seems to be working for me as well in F28.

Comment 8 Anthony Messina 2018-05-17 23:21:03 UTC
Resolved in F28.

Comment 9 Ben Cotton 2018-11-27 14:35:08 UTC
This message is a reminder that Fedora 27 is nearing its end of life.
On 2018-Nov-30  Fedora will stop maintaining and issuing updates for
Fedora 27. 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 '27'.

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 27 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 10 Ben Cotton 2018-11-30 22:36:56 UTC
Fedora 27 changed to end-of-life (EOL) status on 2018-11-30. Fedora 27 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.


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