Table of Contents

Linux Hardening Guide - Boot parameters

Boot parameters pass settings to the kernel at boot using your bootloader.

Depending on the bootloader being used:


Kernel self-protection

slab_nomerge

This disables slab merging, which significantly increases the difficulty of heap exploitation by preventing overwriting objects from merged caches and by making it harder to influence slab cache layout.


init_on_alloc=1 init_on_free=1

This enables zeroing of memory during allocation and free time, which can help mitigate use-after-free vulnerabilities and erase sensitive information in memory.


page_alloc.shuffle=1

This option randomizes page allocator freelists, improving security by making page allocations less predictable.


pti=on

This enables Kernel Page Table Isolation, which mitigates Meltdown and prevents some KASLR bypasses.


randomize_kstack_offset=on

This option randomizes the kernel stack offset on each syscall, which makes attacks that rely on deterministic kernel stack layout significantly more difficult, such as the exploitation of CVE-2019-18683.


vsyscall=none

This disables vsyscalls, as they are obsolete and have been replaced with vDSO.


debugfs=off

This disables debugfs, which exposes a lot of sensitive information about the kernel.


oops=panic

Sometimes certain kernel exploits will cause what is known as an "oops".


module.sig_enforce=1

This only allows kernel modules that have been signed with a valid key to be loaded, which increases security by making it much harder to load a malicious kernel module.


lockdown=confidentiality

The kernel lockdown LSM can eliminate many methods that user space code could abuse to escalate to kernel privileges and extract sensitive information.


mce=0

This causes the kernel to panic on uncorrectable errors in ECC memory which could be exploited.


quiet loglevel=0

These parameters prevent information leaks during boot and must be used in combination with the kernel.printk sysctl documented at sysctl.


CPU mitigations

NOTE: It is best to enable all CPU mitigations that are applicable to your CPU as to ensure that you are not affected by known vulnerabilities.

  • This is a list that enables all built-in mitigations:
spectre_v2=on spec_store_bypass_disable=on tsx=off tsx_async_abort=full,nosmt mds=full,nosmt l1tf=full,force nosmt=force kvm.nx_huge_pages=force

Result

If you have followed all of the above recommendations, excluding your specific CPU mitigations, you will have:

slab_nomerge init_on_alloc=1 init_on_free=1 page_alloc.shuffle=1 pti=on vsyscall=none debugfs=off oops=panic module.sig_enforce=1 lockdown=confidentiality mce=0 quiet loglevel=0

NOTE: You need to regenerate your GRUB configuration file to apply these if using GRUB as your bootloader.

—-