SELinux AVC denial against systemd-sleep while trying to hibernate

Hello,

I’ve been trying to setup hibernation on my Fedora 40 machine (KDE, non-atomic) with this guide: Setup hibernation on Fedora Atomic Desktops - #3 by aaravchen, so far all the steps haven’t given any issue, but I still can’t hibernate.
I use systemd-boot and don’t have secure boot enabled.
All the packages are up to date.

Here’s the output of SETroubleshoot

SELinux is preventing systemd-sleep from search access on the directory swap.

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

If you believe that systemd-sleep should be allowed search access on the swap 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 'systemd-sleep' --raw | audit2allow -M my-systemdsleep
# semodule -X 300 -i my-systemdsleep.pp

Additional Information:
Source Context                system_u:system_r:systemd_sleep_t:s0
Target Context                system_u:object_r:swapfile_t:s0
Target Objects                swap [ dir ]
Source                        systemd-sleep
Source Path                   systemd-sleep
Port                          <Unknown>
Host                          fedora
Source RPM Packages           
Target RPM Packages           
SELinux Policy RPM            selinux-policy-targeted-40.27-1.fc40.noarch
Local Policy RPM              selinux-policy-targeted-40.27-1.fc40.noarch
Selinux Enabled               True
Policy Type                   targeted
Enforcing Mode                Enforcing
Host Name                     fedora
Platform                      Linux fedora 6.10.6-200.fc40.x86_64 #1 SMP
                              PREEMPT_DYNAMIC Mon Aug 19 14:09:30 UTC 2024
                              x86_64
Alert Count                   3
First Seen                    2024-08-30 21:02:46 CEST
Last Seen                     2024-08-30 21:14:14 CEST
Local ID                      82a96bb5-7698-4876-bf35-eada9b1007fb

Raw Audit Messages
type=AVC msg=audit(1725045254.324:204): avc:  denied  { search } for  pid=2557 comm="systemd-sleep" name="swap" dev="nvme0n1p3" ino=256 scontext=system_u:system_r:systemd_sleep_t:s0 tcontext=system_u:object_r:swapfile_t:s0 tclass=dir permissive=0


Hash: systemd-sleep,systemd_sleep_t,swapfile_t,dir,search

Thank you

Executing the two commands suggested by the SETroubleshoot tool will likely resolve the problem.

Edit: I take that back, there might be a few other denials that are not being shown yet because that first denial blocked the rest of the process. You might need to run semanage permissive -a systemd_sleep_t, let the system hibernate and resume once, then run those two commands that the troubleshooter recommended. After you’ve compiled and installed the new policy, run semanage permissive -d systemd_sleep_t to undo the permissive mode for systemd-sleep.

Yes, another denial appeared about logind, I just ran the suggested commands by SETroubleshoot and now it hibernates OK.

Thank you.

1 Like