Bug 1840278

Summary: systemctl reboot --firmware-setup requires write access to efivars
Product: [Fedora] Fedora Reporter: Johannes Pfrang <johannespfrang>
Component: selinux-policyAssignee: Zdenek Pytela <zpytela>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: medium    
Version: 32CC: dwalsh, grepl.miroslav, lvrabec, mmalik, plautrba, vmojzis, zpytela
Target Milestone: ---Keywords: Triaged
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: selinux-policy-3.14.5-40.fc32 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-06-11 22:57:16 UTC Type: Bug
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 Johannes Pfrang 2020-05-26 16:48:17 UTC
Description of problem:

I cannot directly reboot into the EFI setup with Fedora 32 any more. This used to work with Fedora 31.


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


Steps to Reproduce:
1. Run `systemctl reboot --firmware-setup`

Actual results:
Error message: Cannot indicate to EFI to boot into setup mode: Access denied

Expected results:
System reboots into EFI.


Additional info:

SELinux is preventing systemd-logind from 'write' accesses on the directory /sys/firmware/efi/efivars.

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

If you believe that systemd-logind should be allowed write access on the efivars 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-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:efivarfs_t:s0
Target Objects                /sys/firmware/efi/efivars [ dir ]
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.14-300.fc32.x86_64 #1 SMP Wed
                            May 20 20:47:32 UTC 2020 x86_64 x86_64
Alert Count                   2
First Seen                    2020-05-26 18:36:18 CEST
Last Seen                     2020-05-26 18:36:22 CEST
Local ID                      a59f152b-ce13-4c85-a2d4-e60e1cb9aea0

Raw Audit Messages
type=AVC msg=audit(1590510982.249:1233): avc:  denied  { write } for  pid=1886 comm="systemd-logind" name="/" dev="efivarfs" ino=3134 scontext=system_u:system_r:systemd_logind_t:s0 tcontext=system_u:object_r:efivarfs_t:s0 tclass=dir permissive=0


Hash: systemd-logind,systemd_logind_t,efivarfs_t,dir,write

Comment 1 Johannes Pfrang 2020-06-01 12:15:26 UTC
The issue also affects KDE Plasma System Settings -> Startup and Shutdown -> Desktop Session -> Enter UEFI setup on next restart:

SELinux is preventing systemd-logind from write access on the file OsIndications-8be4df61-93ca-11d2-aa0d-00e098032b8c.

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

If you believe that systemd-logind should be allowed write access on the OsIndications-8be4df61-93ca-11d2-aa0d-00e098032b8c 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:efivarfs_t:s0
Target Objects                OsIndications-8be4df61-93ca-11d2-aa0d-00e098032b8c
                              [ file ]
Source                        systemd-logind
Source Path                   systemd-logind
Port                          <Unknown>
Host                          johnp-pc
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                     johnp-pc
Platform                      Linux johnp-pc 5.6.15-300.fc32.x86_64 #1 SMP Fri
                              May 29 14:23:59 UTC 2020 x86_64 x86_64
Alert Count                   7
First Seen                    2020-05-31 21:15:37 CEST
Last Seen                     2020-06-01 14:14:37 CEST
Local ID                      c3dc3794-fbcf-477c-9313-7c65ea8a0817

Raw Audit Messages
type=AVC msg=audit(1591013677.890:754): avc:  denied  { write } for  pid=1476 comm="systemd-logind" name="OsIndications-8be4df61-93ca-11d2-aa0d-00e098032b8c" dev="efivarfs" ino=19561 scontext=system_u:system_r:systemd_logind_t:s0 tcontext=system_u:object_r:efivarfs_t:s0 tclass=file permissive=0


Hash: systemd-logind,systemd_logind_t,efivarfs_t,file,write

Comment 2 Zdenek Pytela 2020-06-03 14:30:27 UTC
I've submitted a Fedora PR to address the issue:
https://github.com/fedora-selinux/selinux-policy/pull/363

Comment 3 Zdenek Pytela 2020-06-04 07:20:08 UTC
commit c9d9038b2f1f76934f0f949bce521d602430037a (HEAD -> rawhide, upstream/rawhide, origin/rawhide, origin/HEAD)
Author: Zdenek Pytela <zpytela>
Date:   Wed Jun 3 16:27:56 2020 +0200

    Allow systemd-logind manage efivarfs files
    
    Add new fs_manage_efivarfs_files() interface.
    Allow systemd_logind_t fs_manage_efivarfs_files().
    
    Resolves: rhbz#1840278

Comment 4 Fedora Update System 2020-06-05 13:42:18 UTC
FEDORA-2020-ca8855e4de has been submitted as an update to Fedora 32. https://bodhi.fedoraproject.org/updates/FEDORA-2020-ca8855e4de

Comment 5 Fedora Update System 2020-06-08 01:46:08 UTC
FEDORA-2020-ca8855e4de 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-ca8855e4de`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2020-ca8855e4de

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

Comment 6 Fedora Update System 2020-06-11 22:57:16 UTC
selinux-policy-3.14.5-40.fc32 has been pushed to the Fedora 32 stable repository. If problems still persist, please make note of it in this bug report.