Skip to content

A hardened Linux desktop, rebuilt from scratch, with your Windows apps built in. Free and open source.

5.2 KB
Raw Blame
# Sorts after Kicksecure's 30_kicksecure.cfg so these values win.
#
# This must stay the bare identifier. Debian's grub-efi postinst derives the
# EFI folder for GRUB upgrades from it (lowercased, cut at the first space), and
# that has to match the folder the installer used, or GRUB security updates
# would land in a folder the firmware never boots. grub-install, run without
# --bootloader-id, takes the folder from it the same way. Menu titles that
# say "Wild OS" are written by /etc/grub.d/10_wildos, not built from it.
GRUB_DISTRIBUTOR="wildos"

# Boot straight to the splash, as Windows and macOS do. Holding Shift or
# pressing Esc during start-up still shows the menu (safe graphics, Windows,
# firmware settings).
GRUB_TIMEOUT=0
GRUB_TIMEOUT_STYLE=hidden
GRUB_RECORDFAIL_TIMEOUT=5
GRUB_CMDLINE_LINUX_DEFAULT="$GRUB_CMDLINE_LINUX_DEFAULT quiet splash loglevel=3 rd.udev.log_level=3 vt.global_cursor_default=0"

# Full preemption: the kernel can stop background work at almost any point to
# run what you are clicking or typing into, instead of waiting for it to
# offer a break (Debian's default, "voluntary"). Costs about a percent of
# throughput; at every protection level, as it has nothing to do with
# security.
GRUB_CMDLINE_LINUX_DEFAULT="$GRUB_CMDLINE_LINUX_DEFAULT preempt=full"

# At Standard protection, speed over the last few percent of hardening on a
# personal PC. Strict and Maximum keep every Kicksecure option. Sorts after
# 40_cpu_mitigations.cfg and 40_kernel_hardening.cfg, so it edits what they
# added.
# - slab_debug=FZ is kernel memory debugging (checks and padding on every
#   kernel allocation), which every app pays for constantly.
# - The speculative store bypass mitigation goes from every process to the
#   kernel's default: only programs that ask for it get it.
# - init_on_free zeroes all memory as it is freed. init_on_alloc still
#   zeroes it before reuse, and RAM is wiped at shutdown.
# - The IOMMU still isolates every device; lazy mode only batches the
#   bookkeeping, which disks and graphics notice.
# - Windows mode's cache flush on every switch into it becomes conditional.
case "$(cat /etc/wildos/protection-level 2>/dev/null || true)" in
strict | maximum) ;;
*)
    GRUB_CMDLINE_LINUX="$(printf '%s\n' "$GRUB_CMDLINE_LINUX" | sed \
        -e 's/ slab_debug=FZ//g' \
        -e 's/ spec_store_bypass_disable=on//g' \
        -e 's/ ssbd=force-on//g' \
        -e 's/ init_on_free=1//g' \
        -e 's/ iommu.strict=1/ iommu.strict=0/g' \
        -e 's/ kvm-intel.vmentry_l1d_flush=always/ kvm-intel.vmentry_l1d_flush=cond/g')"

    # Processor flaw protections. Kicksecure forces several on whether or
    # not the processor has the flaw, as a guard for processors too new for
    # the kernel's lists, and keeps the second thread of every core off.
    # Unless "Extra processor protection" is on in Settings > Privacy and
    # security (/etc/wildos/cpu-protection), the kernel decides from its
    # own list of affected processors instead:
    # - spectre_v2=on also forces the cross-thread protection (STIBP) on
    #   every program; the default keeps the kernel protected and gives it
    #   to programs that ask for it.
    # - kvm.nx_huge_pages, indirect_target_selection and vmscape go back to
    #   their defaults, which still protect processors that have the flaw.
    #   Their forced forms mostly slow Windows mode.
    # - pti=on (with kpti=1, its Arm spelling) forces kernel page table
    #   isolation, the Meltdown protection, even on processors the kernel
    #   knows are not affected. There it only hides the kernel's layout a
    #   little better, and every system call pays for it: file-heavy work
    #   ran about 30% slower in testing. The kernel still turns it on by
    #   itself on every processor that has the flaw.
    # - Threads: "Use every processor thread" in Settings > System > Power
    #   and battery writes /etc/wildos/cpu-threads. Until it is touched,
    #   the kernel keeps the second thread of each core off only on
    #   processors it lists as unsafe for sharing a core (the ",nosmt"
    #   options and l1tf=full), and runs every thread everywhere else. "on"
    #   runs every thread even there; l1tf=flush still clears the cache each
    #   time a virtual machine runs. "off" keeps them off everywhere.
    if [ "$(cat /etc/wildos/cpu-protection 2>/dev/null || true)" != extra ]; then
        GRUB_CMDLINE_LINUX="$(printf '%s\n' "$GRUB_CMDLINE_LINUX" | sed \
            -e 's/ spectre_v2=on//g' \
            -e 's/ kvm.nx_huge_pages=force//g' \
            -e 's/ indirect_target_selection=force//g' \
            -e 's/ vmscape=force//g' \
            -e 's/ pti=on//g' \
            -e 's/ kpti=1//g')"
        case "$(cat /etc/wildos/cpu-threads 2>/dev/null || true)" in
        off) ;;
        on)
            GRUB_CMDLINE_LINUX="$(printf '%s\n' "$GRUB_CMDLINE_LINUX" | sed \
                -e 's/ nosmt=force//g' \
                -e 's/,nosmt//g' \
                -e 's/l1tf=full,force/l1tf=flush/g')"
            ;;
        *)
            GRUB_CMDLINE_LINUX="$(printf '%s\n' "$GRUB_CMDLINE_LINUX" | sed \
                -e 's/ nosmt=force//g' \
                -e 's/l1tf=full,force/l1tf=full/g')"
            ;;
        esac
    fi
    ;;
esac