Bug 1845594

Summary: SELinux is preventing systemd-logind from 'read' accesses on the file swapfile.
Product: [Fedora] Fedora Reporter: bober <sebastian.saletnik>
Component: selinux-policyAssignee: Zdenek Pytela <zpytela>
Status: CLOSED ERRATA QA Contact: Milos Malik <mmalik>
Severity: medium Docs Contact:
Priority: medium    
Version: 32CC: dwalsh, eric.buscher, grepl.miroslav, lvrabec, mmalik, plautrba, vmojzis, zpytela
Target Milestone: ---Keywords: Triaged
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard: abrt_hash:ac5c9102cf9c71479175349b9495822b8d26731382cf4b8e30a64ed00600ef58;VARIANT_ID=workstation;
Fixed In Version: selinux-policy-3.14.5-45.fc32 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-11-25 01:42:26 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1812955    
Bug Blocks:    

Description bober 2020-06-09 15:21:03 UTC
Description of problem:
"Swap" is in file
/swap/swapfile
and has swapfile_t type of selinux context

Kernel cmdline has resume_offset=XXXXXX

Run command:
systemctl hibernate

Hibernation work in Permissive mode
SELinux is preventing systemd-logind from 'read' accesses on the file swapfile.

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

If you believe that systemd-logind should be allowed read access on the swapfile 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 'systemd-logind' --raw | audit2allow -M my-systemdlogind
# semodule -X 300 -i my-systemdlogind.pp

Additional Information:
Source Context                system_u:system_r:systemd_logind_t:s0
Target Context                system_u:object_r:swapfile_t:s0
Target Objects                swapfile [ file ]
Source                        systemd-logind
Source Path                   systemd-logind
Port                          <Unknown>
Host                          (removed)
Source RPM Packages           
Target RPM Packages           
SELinux Policy RPM            selinux-policy-targeted-3.14.5-39.fc32.noarch
Local Policy RPM              selinux-policy-targeted-3.14.5-39.fc32.noarch
Selinux Enabled               True
Policy Type                   targeted
Enforcing Mode                Enforcing
Host Name                     (removed)
Platform                      Linux (removed) 5.6.15-300.fc32.x86_64 #1 SMP Fri
                              May 29 14:23:59 UTC 2020 x86_64 x86_64
Alert Count                   1
First Seen                    2020-06-09 17:15:33 CEST
Last Seen                     2020-06-09 17:15:33 CEST
Local ID                      9eb6f3f1-ea6f-4854-9dd0-024688deea7c

Raw Audit Messages
type=AVC msg=audit(1591715733.458:1091): avc:  denied  { read } for  pid=1238 comm="systemd-logind" name="swapfile" dev="dm-0" ino=257 scontext=system_u:system_r:systemd_logind_t:s0 tcontext=system_u:object_r:swapfile_t:s0 tclass=file permissive=0


Hash: systemd-logind,systemd_logind_t,swapfile_t,file,read

Version-Release number of selected component:
selinux-policy-targeted-3.14.5-39.fc32.noarch

Additional info:
component:      selinux-policy
reporter:       libreport-2.13.1
hashmarkername: setroubleshoot
kernel:         5.6.15-300.fc32.x86_64
type:           libreport

Comment 1 Lukas Vrabec 2020-06-15 12:09:50 UTC
Zdenek, 
After discussion with systemd team, we should allow it, can you please prepare patches? 

Thanks,
Lukas.

Comment 3 Milos Malik 2020-06-22 09:15:47 UTC
To avoid the actual hibernation, I added the PrivateDevices=yes line to the /usr/lib/systemd/system/systemd-hibernate.service file and called "systemctl daemon-reload".

Comment 6 Zdenek Pytela 2020-10-02 13:58:40 UTC
I've submitted a Fedora PR to address the issue:
https://github.com/fedora-selinux/selinux-policy/pull/452

Comment 7 Eric R. Buscher 2020-10-05 01:52:50 UTC
Similar problem has been detected:

1. Install sddm
2. Create a swapfile
3.  Add the swapfile to fstab
4. Reboot
5. Login

hashmarkername: setroubleshoot
kernel:         5.8.12-200.fc32.x86_64
package:        selinux-policy-targeted-3.14.5-43.fc32.noarch
reason:         SELinux is preventing systemd-logind from 'read' accesses on the file swapfile.
type:           libreport

Comment 8 Fedora Update System 2020-11-09 18:46:10 UTC
FEDORA-2020-77b49aa207 has been submitted as an update to Fedora 32. https://bodhi.fedoraproject.org/updates/FEDORA-2020-77b49aa207

Comment 9 Fedora Update System 2020-11-10 02:20:37 UTC
FEDORA-2020-77b49aa207 has been pushed to the Fedora 32 testing repository.
In short time you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --advisory=FEDORA-2020-77b49aa207`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2020-77b49aa207

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

Comment 10 Fedora Update System 2020-11-25 01:42:26 UTC
FEDORA-2020-77b49aa207 has been pushed to the Fedora 32 stable repository.
If problem still persists, please make note of it in this bug report.