Bug 1662922 - SELinux is preventing sensord from 'getattr' accesses on the file /sys/devices/platform/thinkpad_hwmon/hwmon/hwmon2/fan1_input.
Summary: SELinux is preventing sensord from 'getattr' accesses on the file /sys/device...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: selinux-policy
Version: 29
Hardware: x86_64
OS: Linux
high
medium
Target Milestone: ---
Assignee: Lukas Vrabec
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard: abrt_hash:939317a1c5c4720ddba91310483...
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-01-02 12:27 UTC by accounts
Modified: 2019-01-17 02:16 UTC (History)
6 users (show)

Fixed In Version: selinux-policy-3.14.2-46.fc29
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2019-01-17 02:16:57 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description accounts 2019-01-02 12:27:45 UTC
Description of problem:
Normal usage of ThinkPad (browsing the Internet)
SELinux is preventing sensord from 'getattr' accesses on the file /sys/devices/platform/thinkpad_hwmon/hwmon/hwmon2/fan1_input.

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

If you believe that sensord should be allowed getattr access on the fan1_input 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 'sensord' --raw | audit2allow -M my-sensord
# semodule -X 300 -i my-sensord.pp

Additional Information:
Source Context                system_u:system_r:lsmd_t:s0
Target Context                system_u:object_r:sysfs_t:s0
Target Objects                /sys/devices/platform/thinkpad_hwmon/hwmon/hwmon2/
                              fan1_input [ file ]
Source                        sensord
Source Path                   sensord
Port                          <Unknown>
Host                          (removed)
Source RPM Packages           
Target RPM Packages           
Policy RPM                    selinux-policy-3.14.2-44.fc29.noarch
Selinux Enabled               True
Policy Type                   targeted
Enforcing Mode                Permissive
Host Name                     (removed)
Platform                      Linux (removed) 4.19.9-300.fc29.x86_64 #1 SMP Thu
                              Dec 13 17:25:01 UTC 2018 x86_64 x86_64
Alert Count                   8
First Seen                    2019-01-02 10:40:03 CET
Last Seen                     2019-01-02 13:20:03 CET
Local ID                      18f856b0-5b6f-46fe-834a-5b0a57d6490a

Raw Audit Messages
type=AVC msg=audit(1546431603.637:435): avc:  denied  { getattr } for  pid=1411 comm="sensord" path="/sys/devices/platform/thinkpad_hwmon/hwmon/hwmon2/fan1_input" dev="sysfs" ino=29631 scontext=system_u:system_r:lsmd_t:s0 tcontext=system_u:object_r:sysfs_t:s0 tclass=file permissive=1


Hash: sensord,lsmd_t,sysfs_t,file,getattr

Version-Release number of selected component:
selinux-policy-3.14.2-44.fc29.noarch

Additional info:
component:      selinux-policy
reporter:       libreport-2.9.7
hashmarkername: setroubleshoot
kernel:         4.19.9-300.fc29.x86_64
type:           libreport

Comment 1 Milos Malik 2019-01-07 08:15:59 UTC
The sensord process should not run as lsmd_t, but it does, because SELinux policy contains an incorrect file context pattern:

# semanage fcontext -l | grep sensord-service
/usr/libexec/lm_sensors/sensord-service-wrapper    regular file       system_u:object_r:lsmd_exec_t:s0 
# 

The file context pattern should look this way:

# semanage fcontext -l | grep sensord-service
/usr/libexec/lm_sensors/sensord-service-wrapper    regular file       system_u:object_r:sensord_exec_t:s0 
# 

Because lsmd_t is dedicated to lib storage management processes and it has nothing to do with sensord.

Comment 2 accounts 2019-01-07 09:09:47 UTC
If it helps, system was originally setup at Fedora 25, upgraded to 27 and now 29.
How would I change the SE context of the system service?

Comment 3 Milos Malik 2019-01-07 09:44:39 UTC
# semanage fcontext -a -t sensord_exec_t /usr/libexec/lm_sensors/sensord-service-wrapper

Unfortunately, above-mentioned file context pattern does not solve the problem completely. Following SELinux rules are needed too:

# cat mypolicy.cil 
( allow sensord_t passwd_file_t ( file ( getattr open read )))
( allow sensord_t sensord_exec_t ( file ( execute_no_trans )))
( allow sensord_t shell_exec_t ( file ( map execute )))
( allow sensord_t sssd_public_t ( dir ( search )))
( allow sensord_t sssd_public_t ( file ( getattr open read map )))
( allow sensord_t sssd_t ( unix_stream_socket ( connectto )))
( allow sensord_t sssd_var_lib_t ( dir ( search )))
( allow sensord_t sssd_var_lib_t ( sock_file ( write )))
# semodule -i mypolicy.cil
#

I'm using this ^^^ until an official fix becomes available.

Comment 4 Lukas Vrabec 2019-01-09 12:28:59 UTC
commit 8e8625f44d6144fe70c2c3a335ef622b4052c16a (HEAD -> rawhide)
Author: Lukas Vrabec <lvrabec>
Date:   Wed Jan 9 13:28:28 2019 +0100

    Change label of /usr/libexec/lm_sensors/sensord-service-wrapper from lsmd_exec_t to sensord_exec_t BZ(1662922)

Comment 5 Fedora Update System 2019-01-13 15:45:17 UTC
selinux-policy-3.14.2-46.fc29 has been submitted as an update to Fedora 29. https://bodhi.fedoraproject.org/updates/FEDORA-2019-6a20cfef61

Comment 6 Fedora Update System 2019-01-14 03:03:28 UTC
selinux-policy-3.14.2-46.fc29 has been pushed to the Fedora 29 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-6a20cfef61

Comment 7 Fedora Update System 2019-01-17 02:16:57 UTC
selinux-policy-3.14.2-46.fc29 has been pushed to the Fedora 29 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.