systemd: tmpfiles fixes#1136
Merged
Merged
Conversation
859f6ba to
c3345b6
Compare
beb7df9 to
1dcdd5c
Compare
pebenito
requested changes
May 26, 2026
1dcdd5c to
e4118af
Compare
pebenito
requested changes
Jun 1, 2026
tmpfiles cranks RLIMIT_NOFILE [0]:
> /* Descending down file system trees might take a lot of fds */
> (void) rlimit_nofile_bump(HIGH_RLIMIT_NOFILE);
yielding
```
AVC avc: denied { sys_resource } for pid=1439 comm="systemd-tmpfile" capability=24
scontext=system_u:system_r:systemd_tmpfiles_t:s0
tcontext=system_u:system_r:systemd_tmpfiles_t:s0
tclass=capability
AVC avc: denied { setrlimit } for pid=1439 comm="systemd-tmpfile"
scontext=system_u:system_r:systemd_tmpfiles_t:s0
tcontext=system_u:system_r:systemd_tmpfiles_t:s0
tclass=process
```
[0] https://github.com/systemd/systemd/blob/4d18eac5a99dbc8198f25cde9175e66f27e92cbc/src/tmpfiles/tmpfiles.c#L4867-L4868
Signed-off-by: Sam James <sam@gentoo.org>
For example, I have `/var/tmp/portage` on zram. On startup, zram-generator
mounts it, and later, systemd-tmpfiles processes a (pre-existing) tmpfiles.d
entry to create `/var/tmp/portage`. We need a way to keep the context.
Allow tmpfiles to relabel for these cases:
```
AVC avc: denied { getattr } for pid=1439 comm="systemd-tmpfile" path="/var/tmp/portage" dev="zram0" ino=128
scontext=system_u:system_r:systemd_tmpfiles_t:s0
tcontext=system_u:object_r:unlabeled_t:s0
tclass=dir
AVC avc: denied { setattr } for pid=1439 comm="systemd-tmpfile" name="/" dev="zram0" ino=128
scontext=system_u:system_r:systemd_tmpfiles_t:s0
tcontext=system_u:object_r:unlabeled_t:s0
tclass=dir
AVC avc: denied { relabelfrom } for pid=1439 comm="systemd-tmpfile" name="/" dev="zram0" ino=128
scontext=system_u:system_r:systemd_tmpfiles_t:s0
tcontext=system_u:object_r:unlabeled_t:s0
tclass=dir
```
Signed-off-by: Sam James <sam@gentoo.org>
audit installs a tmpfiles.d file for /var/log/audit [0]:
```
AVC avc: denied { relabelfrom } for pid=1439 comm="systemd-tmpfile" name="audit" dev="dm-0" ino=1246029
scontext=system_u:system_r:systemd_tmpfiles_t:s0
tcontext=system_u:object_r:auditd_log_t:s0
tclass=dir
AVC avc: denied { relabelto } for pid=1439 comm="systemd-tmpfile" name="audit" dev="dm-0" ino=1246029
scontext=system_u:system_r:systemd_tmpfiles_t:s0
tcontext=system_u:object_r:auditd_log_t:s0
tclass=dir
```
An explicit allow is needed because auditd_log_t is a security_file.
[0] linux-audit/audit-userspace@eb3a9a6
Signed-off-by: Sam James <sam@gentoo.org>
e4118af to
7d1dc1f
Compare
pebenito
approved these changes
Jun 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A few tmpfiles fixes.