xref: /linux/kernel/configs/hardening.config (revision eb01fe7abbe2d0b38824d2a93fdb4cc3eaf2ccc1)
1# Help: Basic kernel hardening options
2#
3# These are considered the basic kernel hardening, self-protection, and
4# attack surface reduction options. They are expected to have low (or
5# no) performance impact on most workloads, and have a reasonable level
6# of legacy API removals.
7
8# Make sure reporting of various hardening actions is possible.
9CONFIG_BUG=y
10
11# Basic kernel memory permission enforcement.
12CONFIG_STRICT_KERNEL_RWX=y
13CONFIG_STRICT_MODULE_RWX=y
14CONFIG_VMAP_STACK=y
15
16# Kernel image and memory ASLR.
17CONFIG_RANDOMIZE_BASE=y
18CONFIG_RANDOMIZE_MEMORY=y
19
20# Randomize allocator freelists, harden metadata.
21CONFIG_SLAB_FREELIST_RANDOM=y
22CONFIG_SLAB_FREELIST_HARDENED=y
23CONFIG_SHUFFLE_PAGE_ALLOCATOR=y
24CONFIG_RANDOM_KMALLOC_CACHES=y
25
26# Randomize kernel stack offset on syscall entry.
27CONFIG_RANDOMIZE_KSTACK_OFFSET_DEFAULT=y
28
29# Basic stack frame overflow protection.
30CONFIG_STACKPROTECTOR=y
31CONFIG_STACKPROTECTOR_STRONG=y
32
33# Basic buffer length bounds checking.
34CONFIG_HARDENED_USERCOPY=y
35CONFIG_FORTIFY_SOURCE=y
36
37# Basic array index bounds checking.
38CONFIG_UBSAN=y
39CONFIG_UBSAN_TRAP=y
40CONFIG_UBSAN_BOUNDS=y
41# CONFIG_UBSAN_SHIFT is not set
42# CONFIG_UBSAN_DIV_ZERO
43# CONFIG_UBSAN_UNREACHABLE
44# CONFIG_UBSAN_BOOL
45# CONFIG_UBSAN_ENUM
46# CONFIG_UBSAN_ALIGNMENT
47
48# Sampling-based heap out-of-bounds and use-after-free detection.
49CONFIG_KFENCE=y
50
51# Linked list integrity checking.
52CONFIG_LIST_HARDENED=y
53
54# Initialize all heap variables to zero on allocation.
55CONFIG_INIT_ON_ALLOC_DEFAULT_ON=y
56
57# Initialize all stack variables to zero on function entry.
58CONFIG_INIT_STACK_ALL_ZERO=y
59
60# Wipe RAM at reboot via EFI. For more details, see:
61# https://trustedcomputinggroup.org/resource/pc-client-work-group-platform-reset-attack-mitigation-specification/
62# https://bugzilla.redhat.com/show_bug.cgi?id=1532058
63CONFIG_RESET_ATTACK_MITIGATION=y
64
65# Disable DMA between EFI hand-off and the kernel's IOMMU setup.
66CONFIG_EFI_DISABLE_PCI_DMA=y
67
68# Force IOMMU TLB invalidation so devices will never be able to access stale
69# data content.
70CONFIG_IOMMU_SUPPORT=y
71CONFIG_IOMMU_DEFAULT_DMA_STRICT=y
72
73# Do not allow direct physical memory access to non-device memory.
74CONFIG_STRICT_DEVMEM=y
75CONFIG_IO_STRICT_DEVMEM=y
76
77# Provide userspace with seccomp BPF API for syscall attack surface reduction.
78CONFIG_SECCOMP=y
79CONFIG_SECCOMP_FILTER=y
80
81# Provides some protections against SYN flooding.
82CONFIG_SYN_COOKIES=y
83
84# Attack surface reduction: do not autoload TTY line disciplines.
85# CONFIG_LDISC_AUTOLOAD is not set
86
87# Dangerous; enabling this disables userspace brk ASLR.
88# CONFIG_COMPAT_BRK is not set
89
90# Dangerous; exposes kernel text image layout.
91# CONFIG_PROC_KCORE is not set
92
93# Dangerous; enabling this disables userspace VDSO ASLR.
94# CONFIG_COMPAT_VDSO is not set
95
96# Attack surface reduction: Use the modern PTY interface (devpts) only.
97# CONFIG_LEGACY_PTYS is not set
98