···13assert (versionAtLeast version "4.9");
1415''
16-GCC_PLUGINS y # Enable gcc plugin options
0000000000000000000000000001718${optionalString (versionAtLeast version "4.11") ''
19 GCC_PLUGIN_STRUCTLEAK y # A port of the PaX structleak plugin
20''}
2122-DEBUG_WX y # A one-time check for W+X mappings at boot; doesn't do anything beyond printing a warning
02324-${optionalString (versionAtLeast version "4.10") ''
25- BUG_ON_DATA_CORRUPTION y # BUG if kernel struct validation detects corruption
26-''}
02728-# Additional validation of commonly targetted structures
29DEBUG_CREDENTIALS y
30DEBUG_NOTIFIERS y
31DEBUG_LIST y
32DEBUG_SG y
003334-HARDENED_USERCOPY y # Bounds check usercopy
0000000000003536-# Wipe on free with page_poison=1
037PAGE_POISONING y
38PAGE_POISONING_NO_SANITY y
39PAGE_POISONING_ZERO y
4041-CC_STACKPROTECTOR_REGULAR n
42-CC_STACKPROTECTOR_STRONG y
04344-# Stricter /dev/mem
45-STRICT_DEVMEM y
46-IO_STRICT_DEVMEM y
04748# Disable various dangerous settings
49ACPI_CUSTOM_METHOD n # Allows writing directly to physical memory
50PROC_KCORE n # Exposes kernel text image layout
51INET_DIAG n # Has been used for heap based attacks in the past
5253-${optionalString (stdenv.system == "x86_64-linux") ''
54- DEFAULT_MMAP_MIN_ADDR 65536 # Prevent allocation of first 64K of memory
55-56- # Reduce attack surface by disabling various emulations
57- IA32_EMULATION n
58- X86_X32 n
59-60- VMAP_STACK y # Catch kernel stack overflows
61-''}
62-63''
···13assert (versionAtLeast version "4.9");
1415''
16+# Report BUG() conditions and kill the offending process.
17+BUG y
18+19+${optionalString (stdenv.system == "x86_64-linux") ''
20+ DEFAULT_MMAP_MIN_ADDR 65536 # Prevent allocation of first 64K of memory
21+22+ # Reduce attack surface by disabling various emulations
23+ IA32_EMULATION n
24+ X86_X32 n
25+ MODIFY_LDT_SYSCALL n
26+27+ VMAP_STACK y # Catch kernel stack overflows
28+29+ # Randomize position of kernel and memory.
30+ RANDOMIZE_BASE y
31+ RANDOMIZE_MEMORY y
32+33+ # Modern libc no longer needs a fixed-position mapping in userspace, remove it as a possible target.
34+ LEGACY_VSYSCALL_NONE y
35+''}
36+37+# Make sure kernel page tables have safe permissions.
38+DEBUG_KERNEL y
39+40+${optionalString (versionOlder version "4.11") ''
41+ DEBUG_RODATA y
42+ DEBUG_SET_MODULE_RONX y
43+''}
4445${optionalString (versionAtLeast version "4.11") ''
46 GCC_PLUGIN_STRUCTLEAK y # A port of the PaX structleak plugin
47''}
4849+# Report any dangerous memory permissions (not available on all archs).
50+DEBUG_WX y
5152+# Do not allow direct physical memory access (but if you must have it, at least enable STRICT mode...)
53+# DEVMEM is not set
54+STRICT_DEVMEM y
55+IO_STRICT_DEVMEM y
5657+# Perform additional validation of various commonly targeted structures.
58DEBUG_CREDENTIALS y
59DEBUG_NOTIFIERS y
60DEBUG_LIST y
61DEBUG_SG y
62+BUG_ON_DATA_CORRUPTION y
63+SCHED_STACK_END_CHECK y
6465+# Provide userspace with seccomp BPF API for syscall attack surface reduction.
66+SECCOMP y
67+SECCOMP_FILTER y
68+69+# Provide userspace with ptrace ancestry protections.
70+SECURITY y
71+SECURITY_YAMA y
72+73+# Perform usercopy bounds checking.
74+HARDENED_USERCOPY y
75+76+# Randomize allocator freelists.
77+SLAB_FREELIST_RANDOM y
7879+# Wipe higher-level memory allocations when they are freed (needs "page_poison 1" command line below).
80+# (If you can afford even more performance penalty, leave PAGE_POISONING_NO_SANITY n)
81PAGE_POISONING y
82PAGE_POISONING_NO_SANITY y
83PAGE_POISONING_ZERO y
8485+# Reboot devices immediately if kernel experiences an Oops.
86+PANIC_ON_OOPS y
87+PANIC_TIMEOUT -1
8889+# Keep root from altering kernel memory via loadable modules.
90+# MODULES is not set
91+92+GCC_PLUGINS y # Enable gcc plugin options
9394# Disable various dangerous settings
95ACPI_CUSTOM_METHOD n # Allows writing directly to physical memory
96PROC_KCORE n # Exposes kernel text image layout
97INET_DIAG n # Has been used for heap based attacks in the past
9899+# Use -fstack-protector-strong (gcc 4.9+) for best stack canary coverage.
100+CC_STACKPROTECTOR_REGULAR n
101+CC_STACKPROTECTOR_STRONG y
0000000102''