2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2026-11-19 08:52:15 +00:00
Files
xcat-core/xCAT-server/lib
Daniel Hilst 4ee82d40d8 fix(xcat-core): a stateless node is told to run SELinux and cannot boot
netboot_supported() answered 1 for rhels8 and later and for every
openEuler, so mknetboot wrote no selinux= argument and a stateless node
was asked to run SELinux enforcing. It does not boot.

A stateless root is a cpio archive unpacked into tmpfs, and cpio carries
no SELinux label, so the root starts unlabelled. Three boots of an
AlmaLinux 10.1 image on an enforcing node measured both ways out of
that, on cluster xcat163:

- With the stock dracut selinux module, which this branch added to the
  module list, the policy loads at pre-pivot 50 over the unlabelled
  initramfs. 61 Permission denied lines follow, setfiles returns 126 and
  the node loops. That module ships with check() returning 255, so no
  image enables it by accident.
- Without it, and with the relabel hook corrected, setfiles labels the
  root: /usr/lib/systemd/systemd reads init_exec_t. systemd then loads
  the policy after switch_root, cannot relabel /dev or /run, and stops
  with "Failed to allocate manager object. Freezing execution".

The hook could not have worked as written either. It read the mode with
sed piped into tail, and the initramfs has neither tail nor chroot:
chroot arrived with the selinux module. The console reported "tail:
command not found" twice and relabelled nothing.

So netboot_supported() answers 0, mknetboot writes selinux=0 for every
stateless node and nodeset says why. The code that only serves a
stateless node with SELinux on is removed with it: the relabel hook and
its two installers, the selinux dracut module, write_image_config, and
the squashfs label machinery that stored labels nothing reads. The
netboot postinstalls and the stateless xcatroot write SELINUX=disabled
again, so the image says what the kernel command line does.

What stays is what was measured working: a diskful node provisioned
enforcing with zero xCAT denials, the kickstart templates, the policy
package, and the service node mount options.

Tests: selinux_netboot_kcmdline.t fails 34 of its 69 checks on the
parent commit. selinux_cn_diskless_disabled_by_design in cases1
provisions a stateless node asked for enforcing and requires selinux=0
on its command line and getenforce Disabled. selinux_image_config.t and
selinux_squashfs_labels.t go with the subs they tested.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-10-21 10:35:22 -03:00
..