Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

overlay/mounts: Mount /boot and /boot/efi ro,nodev,nosuid #356

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Comment on lines +2 to +20
Copy link
Member

Choose a reason for hiding this comment

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

should this go in a separate file?

Copy link
Member

Choose a reason for hiding this comment

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

i.e. a different test and maybe add some text about why we have this test

Copy link
Member Author

Choose a reason for hiding this comment

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

But then we end up booting a whole other VM for it.

Copy link
Member Author

Choose a reason for hiding this comment

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

(What we really want are nondestructive tests and teach kola to reuse existing VMs for them)

Copy link
Member

Choose a reason for hiding this comment

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

yeah ok that's a good reason to keep it in the same file. Can we add some text at the top about an RFE for nondestructive tests (open issue somewhere?) and then we can break these out once that is in place,

It would still be nice to have a comment at the top of this particular test you are adding about
# in coreos-boot-mount-generator we mount boot readonly, verify it is readonly.