Kernel Hardening

Last updated: 2026-03-11

securitykernelhardening

Capsem compiles its own Linux kernel from source (6.6 LTS, ~7MB vs ~30MB stock Debian). The kernel version is auto-detected from kernel.org at build time. The full config is in images/defconfig.arm64.

Minimal attack surface

The kernel starts from allnoconfig and enables only what the VM needs. Everything else is compiled out — not disabled at runtime, absent from the binary.

Disabled subsystemConfig
Loadable modulesMODULES=n — root cannot load .ko files
io_uringIO_URING=n — high-CVE-count subsystem
eBPF syscallBPF_SYSCALL=n
userfaultfdUSERFAULTFD=n
32-bit compatCOMPAT=n — eliminates legacy syscall surface
USB, sound, DRM, wireless, BluetoothAll =n
SCSI, ATA=n — only VirtIO block devices
Network filesystemsNETWORK_FILESYSTEMS=n
kexec, hibernation, SysRqAll =n
/dev/mem, /dev/portDEVMEM=n, DEVPORT=n
debugfsDEBUG_FS=n
/proc/kallsymsKALLSYMS=n
IPv6IPV6=n

Memory hardening

ProtectionConfigEffect
Heap zeroingINIT_ON_ALLOC_DEFAULT_ON=yZero-fill all heap allocations
Freelist randomizationSLAB_FREELIST_RANDOMIZE=yRandomize SLUB freelist order
Freelist integritySLAB_FREELIST_HARDENED=yIntegrity checks on freelist pointers
Page randomizationSHUFFLE_PAGE_ALLOCATOR=yRandomize page allocation order
Usercopy boundsHARDENED_USERCOPY=yBounds-check copy_to/from_user
KPTIUNMAP_KERNEL_AT_EL0=yKernel page table isolation (Meltdown mitigation)
Heap ASLRCOMPAT_BRK=nRandomize brk heap base

ARM64 hardware security

Apple Silicon supports Branch Target Identification and Pointer Authentication Codes. Both are enabled:

Stack and code protections

Syscall filtering

Seccomp is enabled (SECCOMP=y, SECCOMP_FILTER=y) for userspace syscall filtering as defense in depth.

Boot cmdline hardening

The kernel command line includes runtime enforcement parameters:

console=hvc0 ro loglevel=1 init_on_alloc=1 slab_nomerge page_alloc.shuffle=1

Only VirtIO drivers

The VM runs inside Apple Virtualization.framework, which exposes only VirtIO devices. The kernel enables exactly those drivers and nothing else:

No Ethernet, no real NIC drivers, no USB host controllers.

Verification

Kernel hardening is verified at every boot by capsem-doctor, which checks cmdline parameters, seccomp availability, absence of /dev/mem, module loading disabled, and more. See capsem-doctor for the full test list.