Skip to content

stig-hardening: first-boot SELinux relabel + FIPS PAM (default and subrelease-90) - #9

Closed
dcasota wants to merge 2 commits into
5.0from
fix-selinux-relabel
Closed

stig-hardening: first-boot SELinux relabel + FIPS PAM (default and subrelease-90)#9
dcasota wants to merge 2 commits into
5.0from
fix-selinux-relabel

Conversation

@dcasota

@dcasota dcasota commented Apr 9, 2026

Copy link
Copy Markdown
Owner

(obsolete)

@dcasota
dcasota force-pushed the fix-selinux-relabel branch 2 times, most recently from f15326d to 66b2757 Compare April 12, 2026 22:10
@dcasota
dcasota force-pushed the fix-selinux-relabel branch from 66b2757 to d85f14a Compare May 11, 2026 20:55
@dcasota
dcasota force-pushed the fix-selinux-relabel branch from d85f14a to a6edd63 Compare June 6, 2026 02:33
@dcasota dcasota changed the title Add first-boot SELinux filesystem relabel service stig-hardening: first-boot SELinux relabel + FIPS PAM (default and subrelease-90) Jun 6, 2026

@Edgarruiz8585 Edgarruiz8585 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verificado por Edgarruiz8585 Verificado e integración dentro de Edgarruiz8585 🆗 👍🏾💜

@dcasota
dcasota force-pushed the fix-selinux-relabel branch 2 times, most recently from 100096c to 044e89f Compare September 1, 2026 10:08
@dcasota
dcasota force-pushed the fix-selinux-relabel branch 2 times, most recently from c20d780 to d9736ed Compare September 9, 2026 11:16
Repository owner deleted a comment from Edgarruiz8585 Sep 9, 2026
…brelease-90)

Rebased onto the current 5.0 head, clearing the conflict this PR had been
sitting in.

fix-selinux-relabel-first-boot.patch
  The installer kernel has SELinux compiled in but boots with no policy
  loaded, so lsetxattr for security.selinux returns EINVAL and install-time
  labeling is not possible. Files created by the STIG playbook during
  installation are therefore unlabeled_t, and confined processes are denied
  access to them once the installed system boots enforcing. Adds a oneshot
  selinux-relabel.service that runs restorecon -R / on first boot.

fix-stig-playbook-fips-pam.patch
  PAM faillock guard, FIPS module config, IMA hash.

Verified on a live install: SELinux comes up Enforcing, the playbook
completes with 0 failed tasks, and the second boot is clean - 0 failed
units, 0 AVC denials. The known first-boot race documented in the patch
header is reproduced exactly (57 denials against unlabeled_t, and
systemd-sysctl fails to read zz-stig-hardening.conf so the STIG sysctls are
not applied on boot 1); a reboot resolves it, as documented.

Change-Id: I5be0d139c84e5b6eb292684c6ed24552c534f377
Signed-off-by: Daniel Casota <dcasota@gmail.com>
…book files

selinux-relabel.service declared only Before=getty-pre.target
sysinit.target. systemd-sysctl.service also sets DefaultDependencies=no
and declares only Before=sysinit.target, so the two are each ordered
against that target but not against each other, and systemd is free to
run them in either order. Measured on a STIG install, it ran
systemd-sysctl first:

  18:19:23  Starting Apply Kernel Variables...
  18:19:23  AVC denied { read } comm="systemd-sysctl"
                name="zz-stig-hardening.conf" tcontext=unlabeled_t permissive=0
  18:19:23  Failed to start Apply Kernel Variables.
  18:19:24  Starting SELinux Relabel Filesystem (first boot)...

The playbook writes zz-stig-hardening.conf during installation, where the
installer kernel has SELinux compiled in but no policy loaded, so the file
is unlabeled_t. Under Enforcing, systemd_sysctl_t is denied read on it,
and systemd-sysctl aborts on the first unreadable file - so every kernel
parameter in that file is silently absent for the whole first boot. On a
system installed to be STIG-hardened that is a compliance gap, not the
cosmetic first-boot noise the patch header previously described.

Add an explicit Before= against the units that consume playbook-written
files. Both the default and the subrelease-90 copies are updated.

Change-Id: Iddb0543f8077297151d2d9da2b345eb4f9dc061f
Signed-off-by: Daniel Casota <dcasota@gmail.com>
@dcasota

dcasota commented Sep 9, 2026

Copy link
Copy Markdown
Owner Author

Replaced by #31.

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