Skip to content

Commit

Permalink
Remove u2mfn-related code that was needed on buster
Browse files Browse the repository at this point in the history
  • Loading branch information
legoktm committed Mar 25, 2024
1 parent 017b79e commit ea65dea
Showing 1 changed file with 1 addition and 33 deletions.
34 changes: 1 addition & 33 deletions securedrop-workstation-grsec/DEBIAN/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,9 @@ set -e

# Pin current version of custom kernel
GRSEC_VERSION='#DEB_VERSION_UPSTREAM#'
# When updating the kernel version, also check that the u2mfn version matches:
# https://github.com/QubesOS/qubes-linux-utils/blob/release4.0/version
# Note that u2mfn is only used on buster/Qubes 4.0
U2MFN_VERSION="4.0.34"

# Get the current Debian codename so we can vary based on version
eval "export $(cat /etc/os-release | grep CODENAME)"

# Sets default grub boot parameter to the kernel version specified
# by $GRSEC_VERSION because the default buster/bullseye kernels have
# by $GRSEC_VERSION because the default bullseye kernels have
# higher versions and would supersede our grsecurity kernels.
set_grub_default() {
GRUB_OPT="'Advanced options for Debian GNU/Linux>Debian GNU/Linux, with Linux $GRSEC_VERSION'"
Expand All @@ -47,35 +40,10 @@ start_paxctld() {
fi
}

# Checks that the u2mfn kernel module was successfully built via dkms.
verify_u2mfn_exists() {
ko_filepath="/usr/lib/modules/${GRSEC_VERSION}/updates/dkms/u2mfn.ko"
if ! test -f "$ko_filepath"; then
return 1
fi
}

# For reasons unknown, u2mfn may be missing. If not found, try to rebuild it,
# otherwise we'll fail and require admin intervention.
ensure_u2mfn_exists() {
if ! verify_u2mfn_exists ; then
dkms remove u2mfn -v "$U2MFN_VERSION" -k "$GRSEC_VERSION" || true
dkms autoinstall -k "$GRSEC_VERSION"
if ! verify_u2mfn_exists ; then
echo "ERROR: u2mfn kernel object is missing: $ko_filepath"
exit 1
fi
fi
}

case "$1" in
configure)
# Ensure pax flags are set prior to running grub
start_paxctld
if [[ "$VERSION_CODENAME" = "buster" ]]; then
# Rebuild u2mfn kernel module if missing
ensure_u2mfn_exists
fi
# Force latest hardened kernel for next boot
set_grub_default
update-grub
Expand Down

0 comments on commit ea65dea

Please sign in to comment.