linux_hardening_guide:boot_parameters
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
linux_hardening_guide:boot_parameters [2025/05/31 15:22] – peter | linux_hardening_guide:boot_parameters [2025/05/31 15:42] (current) – peter | ||
---|---|---|---|
Line 4: | Line 4: | ||
* Some settings can be used to increase security, similar to [[Linux Hardening Guide: | * Some settings can be used to increase security, similar to [[Linux Hardening Guide: | ||
+ | |||
+ | |||
+ | Depending on the bootloader being used: | ||
+ | |||
+ | * If using GRUB as your bootloader, edit **/ | ||
+ | * If using Syslinux, edit **/ | ||
+ | * If using **systemd-boot**, | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Kernel self-protection ===== | ||
+ | |||
+ | <code bash> | ||
+ | slab_nomerge | ||
+ | </ | ||
+ | |||
+ | This disables slab merging, which significantly increases the difficulty of heap exploitation by [[https:// | ||
+ | |||
+ | ---- | ||
+ | |||
+ | <code bash> | ||
+ | init_on_alloc=1 init_on_free=1 | ||
+ | </ | ||
+ | |||
+ | This enables [[https:// | ||
+ | |||
+ | ---- | ||
+ | |||
+ | <code bash> | ||
+ | page_alloc.shuffle=1 | ||
+ | </ | ||
+ | |||
+ | This option [[https:// | ||
+ | |||
+ | * This also improves performance. | ||
+ | |||
+ | ---- | ||
+ | |||
+ | <code bash> | ||
+ | pti=on | ||
+ | </ | ||
+ | |||
+ | This enables [[https:// | ||
+ | |||
+ | ---- | ||
+ | |||
+ | <code bash> | ||
+ | randomize_kstack_offset=on | ||
+ | </ | ||
+ | |||
+ | This option [[https:// | ||
+ | |||
+ | ---- | ||
+ | |||
+ | <code bash> | ||
+ | vsyscall=none | ||
+ | </ | ||
+ | |||
+ | This disables [[https:// | ||
+ | |||
+ | * vsyscalls are also at fixed addresses in memory, making them a potential target for ROP attacks. | ||
+ | |||
+ | ---- | ||
+ | |||
+ | <code bash> | ||
+ | debugfs=off | ||
+ | </ | ||
+ | |||
+ | This disables debugfs, [[https:// | ||
+ | |||
+ | ---- | ||
+ | |||
+ | <code bash> | ||
+ | oops=panic | ||
+ | </ | ||
+ | |||
+ | Sometimes certain kernel exploits will cause what is known as an [[https:// | ||
+ | |||
+ | * This parameter will cause the kernel to panic on such oopses, thereby preventing those exploits. | ||
+ | * However, sometimes bad drivers cause harmless oopses which would result in your system crashing, meaning this boot parameter can only be used on certain hardware. | ||
+ | |||
+ | ---- | ||
+ | |||
+ | <code bash> | ||
+ | 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. | ||
+ | |||
+ | * This prevents all out-of-tree kernel modules, including DKMS modules from being loaded [[https:// | ||
+ | |||
+ | ---- | ||
+ | |||
+ | <code bash> | ||
+ | lockdown=confidentiality | ||
+ | </ | ||
+ | |||
+ | The [[https:// | ||
+ | |||
+ | * This LSM is necessary to implement a clear security boundary between user space and the kernel. | ||
+ | * The above option enables this feature in confidentiality mode, the strictest option. | ||
+ | * This implies **module.sig_enforce=1**. | ||
+ | |||
+ | ---- | ||
+ | |||
+ | <code bash> | ||
+ | mce=0 | ||
+ | </ | ||
+ | |||
+ | This causes the kernel to panic on uncorrectable errors in ECC memory which could be exploited. | ||
+ | |||
+ | * This is unnecessary for systems without ECC memory. | ||
+ | |||
+ | ---- | ||
+ | |||
+ | <code bash> | ||
+ | quiet loglevel=0 | ||
+ | </ | ||
+ | |||
+ | These parameters prevent information leaks during boot and must be used in combination with the **kernel.printk** sysctl documented at [[Linux Hardening Guide: | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== CPU mitigations ===== | ||
+ | |||
+ | <WRAP info> | ||
+ | **NOTE: | ||
+ | |||
+ | * This is a list that enables all built-in mitigations: | ||
+ | |||
+ | </ | ||
+ | |||
+ | |||
+ | <code bash> | ||
+ | spectre_v2=on spec_store_bypass_disable=on tsx=off tsx_async_abort=full, | ||
+ | </ | ||
+ | |||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Result ===== | ||
+ | |||
+ | If you have followed all of the above recommendations, | ||
+ | |||
+ | <code bash> | ||
+ | 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 | ||
+ | </ | ||
+ | |||
+ | <WRAP info> | ||
+ | **NOTE: | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ |
linux_hardening_guide/boot_parameters.1748704932.txt.gz · Last modified: 2025/05/31 15:22 by peter