Bug 2507393
| Summary: | SELinux is blocking systemd-tpm2-setup.service | ||
|---|---|---|---|
| Product: | [Fedora] Fedora | Reporter: | buubuu5456 |
| Component: | selinux-policy | Assignee: | Zdenek Pytela <zpytela> |
| Status: | ASSIGNED --- | QA Contact: | Fedora Extras Quality Assurance <extras-qa> |
| Severity: | medium | Docs Contact: | |
| Priority: | unspecified | ||
| Version: | 44 | CC: | bugskde.3zh61, buubuu5456, dwalsh, forums0, hujq, lvrabec, mmalik, omosnacek, pkoncity, rhbugzilla1, vmojzis, zpytela |
| Target Milestone: | --- | Keywords: | SELinux |
| Target Release: | --- | ||
| Hardware: | x86_64 | ||
| OS: | Linux | ||
| Whiteboard: | |||
| Fixed In Version: | Doc Type: | --- | |
| Doc Text: | Story Points: | --- | |
| Clone Of: | Environment: | ||
| Last Closed: | Type: | --- | |
| Regression: | --- | Mount Type: | --- |
| Documentation: | --- | CRM: | |
| Verified Versions: | Category: | --- | |
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
| Cloudforms Team: | --- | Target Upstream Version: | |
| Embargoed: | |||
Still reproducible on Fedora 45, and also on a GRUB setup (not UKI/systemd-boot).
Versions:
selinux-policy-targeted-45.24-1.fc45.noarch
systemd-262.1-1.fc45.x86_64
grub2-efi-x64-2.12-83.fc45.x86_64
kernel 7.3.3-300.fc45.x86_64
Boot setup: shim + GRUB, Secure Boot on, LUKS unlocked via TPM2,
systemd.tpm2_measured_os=yes on the kernel command line.
AVC on every boot (from journalctl -b _TRANSPORT=audit; it happens before
auditd is up, so ausearch on audit.log does not show it):
avc: denied { write } for pid=735 comm="systemd-tpm2-se" name="tpm2-measure.log"
dev="tmpfs" ino=129 scontext=system_u:system_r:init_t:s0
tcontext=system_u:object_r:syslogd_var_run_t:s0 tclass=file permissive=0
$ ls -Z /run/log/systemd/tpm2-measure.log
system_u:object_r:syslogd_var_run_t:s0 /run/log/systemd/tpm2-measure.log
The unit itself finishes ("Finished systemd-tpm2-setup.service"). I do not see
the nvpcr-anchor create denial on dosfs_t from the original report, only this
write denial, so that part looks specific to systemd-boot/UKI setups.
Same denial as in bug 2270929 (closed EOL on F42, never fixed) and comment 2 of
bug 2541481 (F45). Could the version of this bug be bumped to 45 so it does not
get closed at F44 EOL?
Forgot one version in the list above: shim-x64-16.1-7.x86_64 (Secure Boot enabled per mokutil --sb-state). I have recently gone through migrating to Fedora 45 and setting up systemd-boot/UKIS from scratch, and I do not seem to be seeing this denial anymore. On initial boot after tpm has been setup, ausearch -m avc -ts recent yields no denials, same with sealert -l '*'. Thanks for checking. Note that ausearch and sealert may not see this one: I think
the denial happens early in boot, before auditd is running, so it only ends up in
the journal and not in /var/log/audit/audit.log. Also, "-ts recent" only covers
the last 10 minutes.
On my machine (F45, selinux-policy 45.24, shim + GRUB) "ausearch -m AVC -ts boot"
shows nothing, while the same boot gives:
$ journalctl -b _TRANSPORT=audit --grep 'avc: denied' -o cat -q | grep tpm2-measure
AVC avc: denied { write } for pid=735 comm="systemd-tpm2-se" name="tpm2-measure.log" ...
Could you check with that journalctl command? If it is really gone on systemd-boot/UKI
but not on GRUB, that would narrow it down.
Thank you for the information, I checked that journalctl command and it seems the denial is, in fact, still there:
AVC avc: denied { write } for pid=664 comm="systemd-tpm2-se" name="tpm2-measure.log" dev="tmpfs" ino=92 scontext=system_u:system_r:init_t:s0 tcontext=system_u:object_r:syslogd_var_run_t:s0 tclass=file permissive=0
I am, however, not seeing the denial about the nvpcr now, and systemctl status for both systemd-tpm2-setup and systemd-tpm2-setup-early are reporting now issues.
(In reply to buubuu5456 from comment #5) > Thank you for the information, I checked that journalctl command and it > seems the denial is, in fact, still there: > AVC avc: denied { write } for pid=664 comm="systemd-tpm2-se" > name="tpm2-measure.log" dev="tmpfs" ino=92 > scontext=system_u:system_r:init_t:s0 > tcontext=system_u:object_r:syslogd_var_run_t:s0 tclass=file permissive=0 > > I am, however, not seeing the denial about the nvpcr now, and systemctl > status for both systemd-tpm2-setup and systemd-tpm2-setup-early are > reporting now issues. Reporting no* issues. My apologies. |
On Fedora 44, migrated to systemd-boot with a UKI (using Ukify and Dracut). systemd-tpm2-setup.service fails to start due to the following errors: Failed to write anchor secret file to '/boot/efi/loader/credentials/nvpcr-anchor.Fedora.cred': Permission denied ausearch yields the following: ---- time->Sun Jul 26 21:53:50 2026 type=AVC msg=audit(1785117230.162:1089): avc: denied { write } for pid=16740 comm="systemd-tpm2-se" name="tpm2-measure.log" dev="tmpfs" ino=83 scontext=system_u:system_r:init_t:s0 tcontext=system_u:object_r:syslogd_var_run_t:s0 tclass=file permissive=0 ---- time->Sun Jul 26 21:53:50 2026 type=AVC msg=audit(1785117230.163:1090): avc: denied { write } for pid=16740 comm="systemd-tpm2-se" name="tpm2-measure.log" dev="tmpfs" ino=83 scontext=system_u:system_r:init_t:s0 tcontext=system_u:object_r:syslogd_var_run_t:s0 tclass=file permissive=0 ---- time->Sun Jul 26 21:53:51 2026 type=AVC msg=audit(1785117231.466:1091): avc: denied { create } for pid=16740 comm="systemd-tpm2-se" name=".#nvpcr-anchor.Fedora.cred06da5f64f749a070" scontext=system_u:system_r:init_t:s0 tcontext=system_u:object_r:dosfs_t:s0 tclass=file permissive=0 sealert provides additional information: SELinux is preventing systemd-tpm2-se from write access on the file tpm2-measure.log. Source Context system_u:system_r:init_t:s0 Target Context system_u:object_r:syslogd_var_run_t:s0 Target Objects tpm2-measure.log [ file ] Source systemd-tpm2-se Source Path systemd-tpm2-se Port <Unknown> Host fedora-e14 Source RPM Packages Target RPM Packages SELinux Policy RPM selinux-policy-targeted-44.4-1.fc44.noarch Local Policy RPM selinux-policy-targeted-44.4-1.fc44.noarch Selinux Enabled True Policy Type targeted Enforcing Mode Enforcing SELinux is preventing systemd-tpm2-se from create access on the file .#nvpcr-anchor.Fedora.cred06da5f64f749a070. Source Context system_u:system_r:init_t:s0 Target Context system_u:object_r:dosfs_t:s0 Target Objects .#nvpcr-anchor.Fedora.cred06da5f64f749a070 [ file ] Source systemd-tpm2-se Source Path systemd-tpm2-se Port <Unknown> Host fedora-e14 Source RPM Packages Target RPM Packages SELinux Policy RPM selinux-policy-targeted-44.4-1.fc44.noarch Local Policy RPM selinux-policy-targeted-44.4-1.fc44.noarch Selinux Enabled True Policy Type targeted Enforcing Mode Enforcing sealert does provide options for providing permissions for this to work, however I'm not certain this should be enabled for the whole context of system_u:system_r:init_t:s0, or if this should only be allowed for this particular service. For context, systemd-tpm2-setup-early.service does appear to be running without issue. Reproducible: Always Expected Results: I'm not certain if the whole context should have access, or just this service, however it does seem systemd-tpm2-setup.service should have access to write the log file and nvpcr.