Skip to content

Commit

Permalink
overlay/mounts: Mount /boot and /boot/efi ro,nodev,nosuid
Browse files Browse the repository at this point in the history
Ironically ostree has had support for a `ro` boot for a long time,
and only more recently did we land the [sysroot readonly](coreos/coreos-assembler#736).

But we never actually went and made `/boot` `ro` for FCOS, so let's
do it now.

This was actually motivated by someone wanting to "security harden" RHCOS
running through a checklist saying certain mounts should be `nodev`.
Let's add `nosuid` while we're here.
  • Loading branch information
cgwalters committed Apr 17, 2020
1 parent 49de0c7 commit 89c33fe
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ if findmnt --fstab /boot &>/dev/null; then
exit 0
fi

# Some security hardening guidelines like to see this.
# https://bugzilla.redhat.com/show_bug.cgi?id=1627633
boot_options="ro,nodev,nosuid"

# Don't create mount units for /boot or /boot/efi on live systems.
# ConditionPathExists won't work here because conditions don't affect
# the dependency on the underlying device unit.
Expand All @@ -35,6 +39,7 @@ After=systemd-fsck@dev-disk-by\x2dlabel-boot.service
[Mount]
What=/dev/disk/by-label/boot
Where=/boot
Options=${boot_options}
EOF

# Only mount the EFI System Partition on machines where it exists,
Expand All @@ -54,6 +59,7 @@ After=systemd-fsck@dev-disk-by\x2dlabel-EFI\x2dSYSTEM.service
[Mount]
What=/dev/disk/by-label/EFI-SYSTEM
Where=/boot/efi
Options=${boot_options}
EOF
fi
fi
20 changes: 19 additions & 1 deletion tests/kola/basic
Original file line number Diff line number Diff line change
@@ -1,2 +1,20 @@
#!/bin/bash
exec systemctl is-enabled logrotate.service
set -euo pipefail
systemctl is-enabled logrotate.service
echo "ok logrotate"

validate_not_writable_mount() {
local mnt=$1
shift
findmnt "${mnt}" -o OPTIONS | grep -q ro
if test -w "${mnt}"; then
echo "writable ${mnt}"
exit 1
fi
echo "ok not writable ${mnt}"
}

validate_not_writable_mount /boot
if test -d /boot/efi; then
validate_not_writable_mount /boot/efi
fi

0 comments on commit 89c33fe

Please sign in to comment.