Bug 2070329 - SELinux is preventing mktemp from 'write' accesses on the directory tlp.
Summary: SELinux is preventing mktemp from 'write' accesses on the directory tlp.
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: selinux-policy
Version: 36
Hardware: x86_64
OS: Unspecified
medium
medium
Target Milestone: ---
Assignee: Zdenek Pytela
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard: abrt_hash:af3bf32fe8667adba079017b462...
: 2072272 2072273 2075641 (view as bug list)
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2022-03-30 20:28 UTC by Michael
Modified: 2022-04-26 02:40 UTC (History)
9 users (show)

Fixed In Version: selinux-policy-36.7-1.fc36
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2022-04-26 02:40:11 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Bugzilla 2072272 1 unspecified CLOSED SELinux is preventing rm from 'unlink' accesses on the file tlp-run.conf_tmp2Dz8Wi. 2022-04-20 14:50:49 UTC

Internal Links: 2072272

Description Michael 2022-03-30 20:28:23 UTC
Description of problem:
Upgrade to Fedora 36
SELinux is preventing mktemp from 'write' accesses on the directory tlp.

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

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

Additional Information:
Source Context                system_u:system_r:NetworkManager_dispatcher_t:s0
Target Context                system_u:object_r:var_run_t:s0
Target Objects                tlp [ dir ]
Source                        mktemp
Source Path                   mktemp
Port                          <Unknown>
Host                          (removed)
Source RPM Packages           
Target RPM Packages           
SELinux Policy RPM            selinux-policy-targeted-36.5-1.fc36.noarch
Local Policy RPM              selinux-policy-targeted-36.5-1.fc36.noarch
Selinux Enabled               True
Policy Type                   targeted
Enforcing Mode                Enforcing
Host Name                     (removed)
Platform                      Linux (removed) 5.16.16-200.fc35.x86_64 #1 SMP
                              PREEMPT Wed Mar 23 00:44:58 CET 2022 x86_64 x86_64
Alert Count                   18
First Seen                    2022-03-30 22:12:13 CEST
Last Seen                     2022-03-30 22:22:10 CEST
Local ID                      3ea87a12-5db4-4ed7-9b81-228a8c290e84

Raw Audit Messages
type=AVC msg=audit(1648671730.555:328): avc:  denied  { write } for  pid=2406 comm="mktemp" name="tlp" dev="tmpfs" ino=829 scontext=system_u:system_r:NetworkManager_dispatcher_t:s0 tcontext=system_u:object_r:var_run_t:s0 tclass=dir permissive=0


Hash: mktemp,NetworkManager_dispatcher_t,var_run_t,dir,write

Version-Release number of selected component:
selinux-policy-targeted-36.5-1.fc36.noarch

Additional info:
component:      selinux-policy
reporter:       libreport-2.17.1
hashmarkername: setroubleshoot
kernel:         5.16.16-200.fc35.x86_64
type:           libreport

Comment 1 Zdenek Pytela 2022-03-31 06:59:44 UTC
Michael,

Do you know which script triggered this denial?

Comment 2 Michael 2022-04-02 08:50:01 UTC
I have no idea.
It's a rather basic installation with TLP enabled, which was upgraded to Fedora 36.
Before the upgrade I didn't get any alarms.

Comment 3 Kevin P. Fleming 2022-04-06 19:53:57 UTC
It is /usr/lib/NetworkManager/dispatcher.d/99tlp-rdw-nm which triggers this (I just tracked it down on my own system). Setting SELinux to permissive mode allows tlp-rdw to manage my WiFi radio as it did in F35, but with SELinux in enforcing mode every time this dispatcher script is invoked by NetworkManager it fails because it cannot write into /run/tlp.

Comment 4 Kevin P. Fleming 2022-04-06 20:00:21 UTC
This comes from the 'tlp-rdw' package, not the base 'tlp' package. For existing users who have enabled WiFi power switching (rfkill), the result of this problem is that disconnecting their LAN link does *not* enable their WiFi link, so they have no network connectivity.

Comment 5 Flo H. 2022-04-07 17:27:51 UTC
Similar problem has been detected:

system startup with tlp enabled

hashmarkername: setroubleshoot
kernel:         5.17.1-300.fc36.x86_64
package:        selinux-policy-targeted-36.6-1.fc36.noarch
reason:         SELinux is preventing mktemp from 'write' accesses on the directory tlp.
type:           libreport

Comment 6 Kevin P. Fleming 2022-04-07 17:49:15 UTC
For what it's worth, I would be happy to test modified versions of the policies on my laptop to see if they address the problem.

Comment 7 Zdenek Pytela 2022-04-12 18:49:18 UTC
AVC from the duplicate bz:

type=AVC msg=audit(1649195759.77:395): avc:  denied  { read } for  pid=2525 comm="readlink" name="virbr0" dev="sysfs" ino=48505 scontext=system_u:system_r:NetworkManager_dispatcher_t:s0 tcontext=system_u:object_r:sysfs_t:s0 tclass=lnk_file permissive=1

Comment 8 Zdenek Pytela 2022-04-12 18:49:25 UTC
*** Bug 2072273 has been marked as a duplicate of this bug. ***

Comment 9 Flo H. 2022-04-17 22:47:34 UTC
Similar problem has been detected:

tlp enable

hashmarkername: setroubleshoot
kernel:         5.17.2-300.fc36.x86_64
package:        selinux-policy-targeted-36.6-1.fc36.noarch
reason:         SELinux is preventing mktemp from 'write' accesses on the directory tlp.
type:           libreport

Comment 10 Zdenek Pytela 2022-04-20 14:50:49 UTC
*** Bug 2072272 has been marked as a duplicate of this bug. ***

Comment 11 Zdenek Pytela 2022-04-20 14:54:20 UTC
AVC from another dup bz:

type=AVC msg=audit(1649956553.315:401): avc:  denied  { write } for  pid=2704 comm="tlp-readconfs" name="tlp-run.conf_tmpt6VMXI" dev="tmpfs" ino=1939 scontext=system_u:system_r:NetworkManager_dispatcher_t:s0 tcontext=system_u:object_r:var_run_t:s0 tclass=file permissive=1

Comment 12 Zdenek Pytela 2022-04-20 14:54:33 UTC
*** Bug 2075641 has been marked as a duplicate of this bug. ***

Comment 13 Fedora Update System 2022-04-21 14:14:20 UTC
FEDORA-2022-76963fee71 has been submitted as an update to Fedora 36. https://bodhi.fedoraproject.org/updates/FEDORA-2022-76963fee71

Comment 14 Fedora Update System 2022-04-21 17:50:18 UTC
FEDORA-2022-76963fee71 has been pushed to the Fedora 36 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --advisory=FEDORA-2022-76963fee71`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2022-76963fee71

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 15 Kevin P. Fleming 2022-04-21 18:59:47 UTC
The attached build now allows the script to write into the target directory, but then another AVC is generated when 'rfkill' is executed:

type=AVC msg=audit(1650567176.426:309): avc:  denied  { read write } for  pid=5826 comm="rfkill" name="rfkill" dev="devtmpfs" ino=209 scontext=system_u:system_r:NetworkManager_dispatcher_tlp_t:s0 tcontext=system_u:object_r:wireless_device_t:s0 tclass=chr_file permissive=0

If that should be reported in a separate BZ please let me know.

Comment 16 Zdenek Pytela 2022-04-22 13:49:51 UTC
In reply to Kevin P. Fleming from comment #15)
> The attached build now allows the script to write into the target directory,
> but then another AVC is generated when 'rfkill' is executed:
> 
> type=AVC msg=audit(1650567176.426:309): avc:  denied  { read write } for 
> pid=5826 comm="rfkill" name="rfkill" dev="devtmpfs" ino=209
> scontext=system_u:system_r:NetworkManager_dispatcher_tlp_t:s0
> tcontext=system_u:object_r:wireless_device_t:s0 tclass=chr_file permissive=0
> 
> If that should be reported in a separate BZ please let me know.

It is easy to miss an update, so generally it is better, not this time, you can check if the latest scratch build fixes all problems:

https://github.com/fedora-selinux/selinux-policy/pull/1161
Checks -> Details -> Artifacts -> rpms

Comment 17 Kevin P. Fleming 2022-04-22 14:19:11 UTC
Success! With the scratch build RPMs installed I'm able to switch between wired and WiFi connections using tlp-rdw as expected. Thanks!

Comment 18 Fedora Update System 2022-04-26 02:40:11 UTC
FEDORA-2022-76963fee71 has been pushed to the Fedora 36 stable repository.
If problem still persists, 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.