Bug 1325759

Summary: SELinux is preventing dbus-daemon from 'read, write' accesses on the chr_file /dev/pts/ptmx.
Product: [Fedora] Fedora Reporter: Paul Alesius <Paul>
Component: selinux-policyAssignee: Miroslav Grepl <mgrepl>
Status: CLOSED INSUFFICIENT_DATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: low Docs Contact:
Priority: unspecified    
Version: 23CC: dominick.grift, dwalsh, lvrabec, mgrepl, plautrba
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-04-11 07:38:11 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:

Description Paul Alesius 2016-04-11 06:45:33 UTC
## Description of problem:
Trying to login to a systemd-nspawn container using machinectl login <container>

## Version-Release number of selected component (if applicable):
selinux-policy.noarch                    3.13.1-158.12.fc23        @updates     
selinux-policy-targeted.noarch           3.13.1-158.12.fc23        @updates 

## How reproducible:
always

## Steps to Reproduce:
1.machinectl login <my-nspawn-machine>

## Actual results:
-> Failed to get machine PTY: Message recipient disconnected from message bus without replying

Because "it" (machinectl? systemd? nspawn?) tries to access /dev/pts/ptmx instead of /dev/ptmx

ls -lZ /dev/ptmx /dev/pts/ptmx:
-> root tty  system_u:object_r:ptmx_t:s0 /dev/ptmx
-> root root system_u:object_r:devpts_t:s0 /dev/pts/ptmx

semanage fcontext -l | grep ptmx:
-> /dev/ptmx    character device   system_u:object_r:ptmx_t:s0

## Expected results:
Login prompt to the container to show up.

## Additional info:
Source Context                system_u:system_r:system_dbusd_t:s0-s0:c0.c1023
Target Context                system_u:object_r:devpts_t:s0
Target Objects                /dev/pts/ptmx [ chr_file ]
Source                        dbus-daemon
Source Path                   dbus-daemon
Port                          <Unknown>
Host                          <Unknown>
Source RPM Packages           
Target RPM Packages           
Policy RPM                    selinux-policy-3.13.1-158.12.fc23.noarch
Selinux Enabled               True
Policy Type                   targeted
Enforcing Mode                Enforcing
Host Name                     hypervisor.unnsvc.dev
Platform                      Linux hypervisor.unnsvc.dev 4.5.0 #1 SMP Fri Apr 8
                              02:31:15 CEST 2016 x86_64 x86_64
Alert Count                   3
First Seen                    2016-04-11 07:03:15 CEST
Last Seen                     2016-04-11 07:03:33 CEST
Local ID                      bd6e884e-e862-4a9c-b030-4498d7cac5ba

Raw Audit Messages
type=AVC msg=audit(1460351013.405:190): avc:  denied  { read write } for  pid=746 comm="dbus-daemon" path="/dev/pts/ptmx" dev="devpts" ino=2 scontext=system_u:system_r:system_dbusd_t:s0-s0:c0.c1023 tcontext=system_u:object_r:devpts_t:s0 tclass=chr_file permissive=0


Hash: dbus-daemon,system_dbusd_t,devpts_t,chr_file,read,write

## The .te file it generates from the auditd.log:

module dbusd-ptmx 1.0;

require {
	type devpts_t;
	type system_dbusd_t;
	class chr_file { write read };
}

#============= system_dbusd_t ==============
allow system_dbusd_t devpts_t:chr_file { write read };

Comment 1 Paul Alesius 2016-04-11 07:38:11 UTC
For some reason, relabeling /dev/pts/ptmx doesn't work either, it will only work by allowing the above AVC. Closing for further debugging.