Bug 1321547

Summary: SELinux is preventing motion from 'read' accesses on the directory cpu.
Product: [Fedora] Fedora Reporter: Wolfgang Rupprecht <wolfgang.rupprecht>
Component: selinux-policyAssignee: Lukas Vrabec <lvrabec>
Status: CLOSED EOL QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: low Docs Contact:
Priority: low    
Version: 23CC: dominick.grift, dwalsh, lvrabec, mgrepl, plautrba, zimon
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Unspecified   
Whiteboard: abrt_hash:22cb9ea2ef957978321c66c31593301cd85cda09f7a051789502003a21b4b5b3;VARIANT_ID=workstation;
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-12-20 19:40:21 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Wolfgang Rupprecht 2016-03-28 10:33:18 UTC
Description of problem:
I simply started motion with "systemctl start motion".   This laptop has 2 cpu cores so motion may have tried to figure out how many CPU's it could use.
SELinux is preventing motion from 'read' accesses on the directory cpu.

*****  Plugin catchall (100. confidence) suggests   **************************

If you believe that motion should be allowed read access on the cpu directory by default.
Then you should report this as a bug.
You can generate a local policy module to allow this access.
Do
allow this access for now by executing:
# grep motion /var/log/audit/audit.log | audit2allow -M mypol
# semodule -i mypol.pp

Additional Information:
Source Context                system_u:system_r:motion_t:s0
Target Context                system_u:object_r:sysfs_t:s0
Target Objects                cpu [ dir ]
Source                        motion
Source Path                   motion
Port                          <Unknown>
Host                          (removed)
Source RPM Packages           
Target RPM Packages           
Policy RPM                    selinux-policy-3.13.1-158.11.fc23.noarch
Selinux Enabled               True
Policy Type                   targeted
Enforcing Mode                Enforcing
Host Name                     (removed)
Platform                      Linux (removed) 4.4.6-300.fc23.x86_64 #1 SMP Wed
                              Mar 16 22:10:37 UTC 2016 x86_64 x86_64
Alert Count                   2
First Seen                    2016-03-28 03:22:32 PDT
Last Seen                     2016-03-28 03:28:07 PDT
Local ID                      c377b5c9-3c2f-4cec-8110-6f8ab2109f30

Raw Audit Messages
type=AVC msg=audit(1459160887.293:254): avc:  denied  { read } for  pid=4292 comm="motion" name="cpu" dev="sysfs" ino=37 scontext=system_u:system_r:motion_t:s0 tcontext=system_u:object_r:sysfs_t:s0 tclass=dir permissive=0


Hash: motion,motion_t,sysfs_t,dir,read

Version-Release number of selected component:
selinux-policy-3.13.1-158.11.fc23.noarch

Additional info:
reporter:       libreport-2.6.4
hashmarkername: setroubleshoot
kernel:         4.4.6-300.fc23.x86_64
type:           libreport

Comment 1 Fedora Admin XMLRPC Client 2016-09-27 14:55:46 UTC
This package has changed ownership in the Fedora Package Database.  Reassigning to the new owner of this component.

Comment 2 Fedora End Of Life 2016-11-24 16:15:41 UTC
This message is a reminder that Fedora 23 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 23. 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 '23'.

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 23 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 3 Fedora End Of Life 2016-12-20 19:40:21 UTC
Fedora 23 changed to end-of-life (EOL) status on 2016-12-20. Fedora 23 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 4 zimon 2018-01-15 18:19:14 UTC
This happens still in Fedora 27.
This is a clean Fedora 27 installation with motion-4.0.1-6.fc27.x86_64

# systemctl start motion
From journal:
"
SELinux is preventing motion from read access on the directory cpu.

*****  Plugin catchall (100. confidence) suggests   **************************

If you believe that motion should be allowed read access on the cpu directory by default.
Then you should report this as a bug.
You can generate a local policy module to allow this access.
Do
allow this access for now by executing:
# ausearch -c 'motion' --raw | audit2allow -M my-motion
# semodule -X 300 -i my-motion.pp


Additional Information:
Source Context                system_u:system_r:motion_t:s0
Target Context                system_u:object_r:sysfs_t:s0
Target Objects                cpu [ dir ]
Source                        motion
Source Path                   motion
Port                          <Unknown>
Host                          myf27
Source RPM Packages           
Target RPM Packages           
Policy RPM                    selinux-policy-3.13.1-283.21.fc27.noarch
Selinux Enabled               True
Policy Type                   targeted
Enforcing Mode                Enforcing
Host Name                     myf27
Platform                      Linux myf27 4.14.11-300.fc27.x86_64 #1 SMP Wed Jan
                              3 13:52:28 UTC 2018 x86_64 x86_64
Alert Count                   6
First Seen                    2018-01-15 19:39:26 EET
Last Seen                     2018-01-15 19:39:43 EET
Local ID                      15881afe-747e-48f6-ba99-402a3db99d2a

Raw Audit Messages
type=AVC msg=audit(1516037983.624:3041): avc:  denied  { read } for  pid=30749 comm="motion" name="cpu" dev="sysfs" ino=33 scontext=system_u:system_r:motion_t:s0 tcontext=system_u:object_r:sysfs_t:s0 tclass=dir permissive=0


Hash: motion,motion_t,sysfs_t,dir,read
"

motion[31863]: [0:motion] [EMG] [ALL] motion_startup: Exit motion, cannot create log file /var/log/motion.log: Permission denied


Did those suggested SELinux-commands; ausearch and semodule.
Then retried:
# systemctl start motion

"
SELinux is preventing motion from read access on the file meminfo.

*****  Plugin catchall (100. confidence) suggests   **************************

If you believe that motion should be allowed read access on the meminfo file by default.
Then you should report this as a bug.
You can generate a local policy module to allow this access.
Do
allow this access for now by executing:
# ausearch -c 'motion' --raw | audit2allow -M my-motion
# semodule -X 300 -i my-motion.pp


Additional Information:
Source Context                system_u:system_r:motion_t:s0
Target Context                system_u:object_r:sysfs_t:s0
Target Objects                meminfo [ file ]
Source                        motion
Source Path                   motion
Port                          <Unknown>
Host                          myf27
Source RPM Packages           
Target RPM Packages           
Policy RPM                    selinux-policy-3.13.1-283.21.fc27.noarch
Selinux Enabled               True
Policy Type                   targeted
Enforcing Mode                Enforcing
Host Name                     myf27
Platform                      Linux myf27 4.14.11-300.fc27.x86_64 #1 SMP Wed Jan
                              3 13:52:28 UTC 2018 x86_64 x86_64
Alert Count                   1
First Seen                    2018-01-15 20:03:00 EET
Last Seen                     2018-01-15 20:03:00 EET
Local ID                      865654e4-05d0-4a40-b8fe-e4b613a4dfa8

Raw Audit Messages
type=AVC msg=audit(1516039380.872:3062): avc:  denied  { read } for  pid=31863 comm="motion" name="meminfo" dev="sysfs" ino=2432 scontext=system_u:system_r:motion_t:s0 tcontext=system_u:object_r:sysfs_t:s0 tclass=file permissive=0


Hash: motion,motion_t,sysfs_t,file,read
"

Then after once again doing those changes to SELinux-policy, next whine is this:

"
SELinux is preventing motion from open access on the file /sys/devices/system/node/node0/meminfo.

*****  Plugin catchall (100. confidence) suggests   **************************

If you believe that motion should be allowed open access on the meminfo file by default.
Then you should report this as a bug.
You can generate a local policy module to allow this access.
Do
allow this access for now by executing:
# ausearch -c 'motion' --raw | audit2allow -M my-motion
# semodule -X 300 -i my-motion.pp


Additional Information:
Source Context                system_u:system_r:motion_t:s0
Target Context                system_u:object_r:sysfs_t:s0
Target Objects                /sys/devices/system/node/node0/meminfo [ file ]
Source                        motion
Source Path                   motion
Port                          <Unknown>
Host                          myf27
Source RPM Packages           
Target RPM Packages           
Policy RPM                    selinux-policy-3.13.1-283.21.fc27.noarch
Selinux Enabled               True
Policy Type                   targeted
Enforcing Mode                Enforcing
Host Name                     myf27
Platform                      Linux myf27 4.14.11-300.fc27.x86_64 #1 SMP Wed Jan
                              3 13:52:28 UTC 2018 x86_64 x86_64
Alert Count                   1
First Seen                    2018-01-15 20:06:07 EET
Last Seen                     2018-01-15 20:06:07 EET
Local ID                      142cfb68-a62a-40ab-aeba-a63ae61aa3de

Raw Audit Messages
type=AVC msg=audit(1516039567.447:3073): avc:  denied  { open } for  pid=32021 comm="motion" path="/sys/devices/system/node/node0/meminfo" dev="sysfs" ino=2432 scontext=system_u:system_r:motion_t:s0 tcontext=system_u:object_r:sysfs_t:s0 tclass=file permissive=0


Hash: motion,motion_t,sysfs_t,file,open
"

Then still SELinux permissions to /dev/video0

"
SELinux is preventing ml1 from map access on the chr_file /dev/video0.

*****  Plugin catchall (100. confidence) suggests   **************************

If you believe that ml1 should be allowed map access on the video0 chr_file by default.
Then you should report this as a bug.
You can generate a local policy module to allow this access.
Do
allow this access for now by executing:
# ausearch -c 'ml1' --raw | audit2allow -M my-ml1
# semodule -X 300 -i my-ml1.pp


Additional Information:
Source Context                system_u:system_r:motion_t:s0
Target Context                system_u:object_r:v4l_device_t:s0
Target Objects                /dev/video0 [ chr_file ]
Source                        ml1
Source Path                   ml1
Port                          <Unknown>
Host                          myf27
Source RPM Packages           
Target RPM Packages           
Policy RPM                    selinux-policy-3.13.1-283.21.fc27.noarch
Selinux Enabled               True
Policy Type                   targeted
Enforcing Mode                Enforcing
Host Name                     myf27
Platform                      Linux myf27 4.14.11-300.fc27.x86_64 #1 SMP Wed Jan
                              3 13:52:28 UTC 2018 x86_64 x86_64
Alert Count                   639
First Seen                    2018-01-13 20:05:20 EET
Last Seen                     2018-01-15 20:11:40 EET
Local ID                      cef0be0a-7b17-422b-85ab-abc852245b7b

Raw Audit Messages
type=AVC msg=audit(1516039900.37:3093): avc:  denied  { map } for  pid=32302 comm="ml1" path="/dev/video0" dev="devtmpfs" ino=23584 scontext=system_u:system_r:motion_t:s0 tcontext=system_u:object_r:v4l_device_t:s0 tclass=chr_file permissive=0


Hash: ml1,motion_t,v4l_device_t,chr_file,map
"

After those several (4) SELinux configuration, motion started working.