Skip to content

systemd: tmpfiles fixes#1136

Merged
pebenito merged 3 commits into
SELinuxProject:mainfrom
thesamesam:systemd-tmpfiles
Jun 1, 2026
Merged

systemd: tmpfiles fixes#1136
pebenito merged 3 commits into
SELinuxProject:mainfrom
thesamesam:systemd-tmpfiles

Conversation

@thesamesam
Copy link
Copy Markdown
Contributor

A few tmpfiles fixes.

@thesamesam thesamesam force-pushed the systemd-tmpfiles branch 3 times, most recently from 859f6ba to c3345b6 Compare May 24, 2026 01:20
@thesamesam thesamesam marked this pull request as draft May 24, 2026 23:07
@thesamesam thesamesam force-pushed the systemd-tmpfiles branch 2 times, most recently from beb7df9 to 1dcdd5c Compare May 25, 2026 06:32
@thesamesam thesamesam marked this pull request as ready for review May 25, 2026 06:35
Comment thread policy/modules/system/systemd.te Outdated
@thesamesam thesamesam requested a review from pebenito May 27, 2026 06:45
Comment thread policy/modules/system/logging.if Outdated
Comment thread policy/modules/system/logging.if Outdated
Comment thread policy/modules/system/systemd.te Outdated
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>
@pebenito pebenito merged commit ba84c15 into SELinuxProject:main Jun 1, 2026
118 checks passed
@thesamesam thesamesam deleted the systemd-tmpfiles branch June 1, 2026 20:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants