Bug 1761765 - Cannot lock down cockpit.service: avc: denied { mounton } / { nnp_transition }
Summary: Cannot lock down cockpit.service: avc: denied { mounton } / { nnp_transition }
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: selinux-policy
Version: 31
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: ---
Assignee: Patrik Koncity
QA Contact: Fedora Extras Quality Assurance
URL: https://github.com/fedora-selinux/sel...
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-10-15 10:24 UTC by Martin Pitt
Modified: 2019-10-29 01:27 UTC (History)
5 users (show)

Fixed In Version: selinux-policy-3.14.4-39.fc31
Clone Of:
Environment:
Last Closed: 2019-10-29 01:27:42 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Martin Pitt 2019-10-15 10:24:01 UTC
Description of problem: I'm currently trying to lock down the permissions of cockpit.service (in version 205+ we can finally do that in a meaningful way).

But it seems some SELinux policy prevents using systemd's features like PrivateTmp=, ProtectHome=, and similar ones that set up a private mount namespace. Others that don't involve mount name spaces, like NoNewPrivileges=true or MemoryDenyWriteExecute=true do work.


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

selinux-policy-3.14.4-35.fc31.noarch
cockpit-204-1.fc31

How reproducible: Always


Steps to Reproduce:
1. echo PrivateTmp=true >> /usr/lib/systemd/system/cockpit.service
2. systemctl daemon-reload; systemctl stop cockpit; systemctl start cockpit.socket
3. visit http://localhost:9090

Actual results: Browser fails with "The connection was reset", and journal shows errors:

audit[10307]: AVC avc:  denied  { mounton } for  pid=10307 comm="(emotectl)" path="/run/systemd/unit-root/run/cockpit/tls" dev="tmpfs" ino=59323 scontext=system_u:system_r:init_t:s0 tcontext=system_u:object_r:cockpit_var_run_t:s0 tclass=dir permissive=0

cockpit.service: Failed to set up mount namespacing: /run/systemd/unit-root/run/cockpit/tls: Permission denied

Expected results: cockpit.service starts and login works

This looks very similar for ProtectSystem=true and others.



I tried with the full glory:

User=cockpit-ws
Group=cockpit-ws
NoNewPrivileges=true
ProtectSystem=strict
ProtectHome=true
rivateTmp=true
PrivateDevices=true
ProtectKernelTunables=true
RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6
MemoryDenyWriteExecute=true

This works after `setenforce 0`. This shows another follow-up error which is also relevant:

AVC avc:  denied  { nnp_transition } for  pid=10443 comm="(kpit-tls)" scontext=system_u:system_r:init_t:s0 tcontext=system_u:system_r:cockpit_ws_t:s0 tclass=process2 permissive=1

Comment 1 Lukas Vrabec 2019-10-22 18:17:30 UTC
commit 793708559184e44e7b7c93f47eb5860fcb1017fd (HEAD -> rawhide, origin/rawhide, origin/HEAD)
Author: Patrik Koncity <pkoncity>
Date:   Tue Oct 22 17:24:10 2019 +0200

    Update cockpit policy
    
    Allow to systemd to use dir with file context cockpit_var_run_t as mount point
    Allow SELinux Domain trasition from sytemd into confined domain with NoNewPrivileges
    Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1761765

Comment 2 Martin Pitt 2019-10-22 19:16:15 UTC
Awesome, thank you Lukas!

Comment 3 Lukas Vrabec 2019-10-22 19:25:05 UTC
Kudos to Patrik. :) 

Fix will be part of next selinux-policy update. If you need some scratch builds we could provide them.

Comment 4 Fedora Update System 2019-10-26 16:59:16 UTC
FEDORA-2019-7d65c50fd6 has been submitted as an update to Fedora 31. https://bodhi.fedoraproject.org/updates/FEDORA-2019-7d65c50fd6

Comment 5 Fedora Update System 2019-10-27 04:02:43 UTC
selinux-policy-3.14.4-39.fc31 has been pushed to the Fedora 31 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-2019-7d65c50fd6

Comment 6 Martin Pitt 2019-10-28 06:55:12 UTC
The update works great, thank you! OOI, is this fix also aimed at Fedora 30?

Comment 7 Fedora Update System 2019-10-29 01:27:42 UTC
selinux-policy-3.14.4-39.fc31 has been pushed to the Fedora 31 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.