Skip to content

selinux_ensure_install re-execs from $TMPDIR; fails with EACCES when /tmp is noexec (CIS hardening) #2432

Description

@gnathoi

What happened

On a host whose /tmp is mounted noexec (CIS mount_option_tmp_noexec, which SSG's remediation applies via tmp.mount), every bootc write-path command fails immediately:

$ sudo bootc upgrade
error: Initializing storage: Preparing for write: Ensuring selinux install_t type: execve: Permission denied (os error 13)

bootc status still works (read-only, never reaches prepare_for_write), so bootc-fetch-apply-updates.timer just fails quietly every week and the host looks healthy while it stops updating.

Cause

crates/lib/src/lsm.rs, selinux_ensure_install(): to enter install_t the binary is copied to tempfile::NamedTempFile::new(), labelled like /usr/bin/ostree, and exec'd. NamedTempFile::new() uses std::env::temp_dir(), i.e. $TMPDIR or /tmp. On a noexec mount the execve returns EACCES.

Versions

  • bootc 1.15.2 (bootc-1.15.2-1.el10_2.alma.1, AlmaLinux 10.2 bootc image); the code path is unchanged on main today.
  • SELinux enforcing, stock policy.

Workarounds

  • sudo TMPDIR=/var/tmp bootc upgrade
  • drop noexec from /tmp and waive the CIS rule (what we did)

Suggested fix

Put the re-exec copy somewhere that is never noexec and is already root-only, e.g. NamedTempFile::new_in("/run") (tmpfs, /run is not covered by any CIS/STIG noexec rule), or memfd_create + fexecve if the SELinux label can be set on the memfd. Happy to send a PR for the /run variant if that's acceptable.

This will bite any CIS/STIG-hardened image-mode host, since the benchmark's own /tmp remediation produces exactly this mount.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions