Kernel Hardening via Boot Parameters

Set Boot Parameters via Grub

Example config for the Grub boot loader (/etc/default/grub.d/50_hardening.cfg):

GRUB_CMDLINE_LINUX_DEFAULT="init_on_alloc=1 nosmt=force vsyscall=none"

Then update the config:

$ update-grub

Tip

On Debian, the package hardening-runtime can be installed which configures many of this parameters for you. Look at /etc/default/grub.d/01_hardening.cfg after installing it.

Boot Parameters

init_on_alloc

Zero newly allocated pages:

init_on_alloc=1

See:

init_on_free

Zero free pages:

init_on_free=1

Warning

Stick with only init_on_alloc if performance is a concern.

See:

nosmt

Force-disable symmetric multithreading (AKA hyperthreading):

nosmt=force

See nosmt= in The kernel’s command-line parameters

page_alloc.shuffle

Tell page allocator to shuffle free list unconditionally:

page_alloc.shuffle=1

See:

pti

Turn on PTI unconditionally:

pti=on

See:

random.trust_cpu

Do not trust CPU as a source of randomness:

random.trust_cpu=off

Concerns about backdoors have been raised and a series of bugs [1,2,3] have been uncovered.

See random.trust_cpu= in The kernel’s command-line parameters

randomize_kstack_offset

Randomize offset of kernel stack:

randomize_kstack_offset=1

See random.trust_cpu= in The kernel’s command-line parameters

slub_debug

Enable SLUB redzoning and sanity checking:

slub_debug=ZF

See Short users guide for SLUB

slab_nomerge

Do not merge slabs with similar size:

slab_nomerge

See slab_nomerge in The kernel’s command-line parameters

vsyscall

Disable legacy vsyscall mechanism:

vsyscall=none

See vsyscall= in The kernel’s command-line parameters

Other Resources