Bug 2273959 - upgrade to F40 beta breaks hibernation: selinux denies access
Summary: upgrade to F40 beta breaks hibernation: selinux denies access
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: selinux-policy
Version: 40
Hardware: x86_64
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Zdenek Pytela
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
: 2277489 2277933 (view as bug list)
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2024-04-08 11:09 UTC by Christian Herzog
Modified: 2024-04-30 07:05 UTC (History)
19 users (show)

Fixed In Version: selinux-policy-40.17-1.fc40
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2024-04-30 01:04:11 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github fedora-selinux selinux-policy pull 2079 0 None Draft Allow systemd-sleep read raw disk data 2024-04-12 13:30:24 UTC
Red Hat Bugzilla 1928539 0 medium CLOSED SELinux prevents hibernation (preventing systemd-sleep from getaddr access to swap partition) 2024-04-12 09:11:57 UTC

Description Christian Herzog 2024-04-08 11:09:28 UTC
Hi,

I've been using hibernate to a swap partition on a Lenovo X250 for years. After a dnf upgrade to F40 beta, hibernation breaks with the following log entries:

audit[5317]: AVC avc:  denied  { read } for  pid=5317 comm="systemd-sleep" name="dm-1" dev="devtmpfs" ino=423 scontext=system_u:system_r:systemd_sleep_t:s0 tcontext=system_u:object_r:fixed_disk_device_t:s0 tclass=blk_file permissive=0 
systemd-sleep[5317]: Failed to find location to hibernate to: Permission denied 
systemd[1]: systemd-hibernate.service: Main process exited, code=exited, status=1/FAILURE 
systemd[1]: systemd-hibernate.service: Failed with result 'exit-code'. 
systemd[1]: Failed to start systemd-hibernate.service - System Hibernate. 
systemd[1]: Dependency failed for hibernate.target - System Hibernation. 
systemd[1]: hibernate.target: Job hibernate.target/start failed with result 'dependency'. 
audit[1]: SERVICE_START pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=systemd-hibernate comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=failed' 

I haven't been able to find out how to give/restore the required permissions.

Reproducible: Always

Steps to Reproduce:
1. Install F39
2. Set up hibernation to swap partition
3. dnf upgrade to F40 beta
Actual Results:  
hibernation fails due to selinux permissions

Expected Results:  
successful hibernation

Comment 1 Zdenek Pytela 2024-04-12 09:06:28 UTC
Christian,

Can you check if adding the reported permission is sufficient?

# cat local_sleep.cil
(allow systemd_sleep_t fixed_disk_device_t (blk_file (read)))
# semodule -i local_sleep.cil
<reproduce>
# semodule -r local_sleep

Comment 2 Zdenek Pytela 2024-04-12 09:11:58 UTC
This is currently in the policy:

1618 # systemd-sleep needs to getattr swap partitions
1619 storage_getattr_fixed_disk_dev(systemd_sleep_t)
1620 storage_getattr_removable_dev(systemd_sleep_t)

I wonder when it started not to be enough since nobody reported a related problem since 2021.

Comment 3 Christian Herzog 2024-04-12 09:16:44 UTC
I'm not very familiar with selinux. I found other .cil files in /usr/share/udica/templates, so I created local_sleep.cil with this one line in there and ran semodule -i local_sleep.cil. This did not change things, the error remains the same.

Comment 4 Zdenek Pytela 2024-04-12 10:17:56 UTC
I believe the content of the cil file matches the reported denial, therefore there should not be the same denial again.
Can you confirm there is again the same avc, or a different one, or just the service failing?

Comment 5 Christian Herzog 2024-04-12 10:33:41 UTC
with the file in place, the error is:

audit[10498]: AVC avc:  denied  { open } for  pid=10498 comm="systemd-sleep" path="/dev/dm-1" dev="devtmpfs" ino=423 scontext=system_u:system_r:systemd_sleep_t:s0 tcontext=system_u:object_r:fixed_disk_device_t:s0 tclass=blk_file permissive=0
systemd-sleep[10498]: Failed to find location to hibernate to: Permission denied
systemd[1]: systemd-hibernate.service: Main process exited, code=exited, status=1/FAILURE
systemd[1]: systemd-hibernate.service: Failed with result 'exit-code'.
systemd[1]: Failed to start systemd-hibernate.service - System Hibernate.
systemd[1]: Dependency failed for hibernate.target - System Hibernation.
systemd[1]: hibernate.target: Job hibernate.target/start failed with result 'dependency'.
audit[1]: SERVICE_START pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=systemd-hibernate comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=failed'

which differs in one detail from the previous one:

                                ******
audit[5317]: AVC avc:  denied  { read } for  pid=5317 comm="systemd-sleep" name="dm-1" dev="devtmpfs" ino=423 scontext=system_u:system_r:systemd_sleep_t:s0 tcontext=system_u:object_r:fixed_disk_device_t:s0 tclass=blk_file permissive=0 

so I modified the rule to read

(allow systemd_sleep_t fixed_disk_device_t (blk_file (open read)))

and hibernate works again!

thank you very much!

Comment 6 Zdenek Pytela 2024-04-12 13:30:24 UTC
This is exactly what I needed to know, thank you for your cooperation.

Comment 7 Fedora Update System 2024-04-26 10:31:29 UTC
FEDORA-2024-57cdb8429c (selinux-policy-40.17-1.fc40) has been submitted as an update to Fedora 40.
https://bodhi.fedoraproject.org/updates/FEDORA-2024-57cdb8429c

Comment 8 Fedora Update System 2024-04-27 01:08:56 UTC
FEDORA-2024-57cdb8429c has been pushed to the Fedora 40 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2024-57cdb8429c`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2024-57cdb8429c

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

Comment 9 Zdenek Pytela 2024-04-29 09:07:35 UTC
*** Bug 2277489 has been marked as a duplicate of this bug. ***

Comment 10 Fedora Update System 2024-04-30 01:04:11 UTC
FEDORA-2024-57cdb8429c (selinux-policy-40.17-1.fc40) has been pushed to the Fedora 40 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 11 Mat Kowalski 2024-04-30 07:05:54 UTC
*** Bug 2277933 has been marked as a duplicate of this bug. ***


Note You need to log in before you can comment on or make changes to this bug.