hardening.config 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. # Make sure reporting of various hardening actions is possible.
  8. CONFIG_BUG=y
  9. # Basic kernel memory permission enforcement.
  10. CONFIG_STRICT_KERNEL_RWX=y
  11. CONFIG_STRICT_MODULE_RWX=y
  12. CONFIG_VMAP_STACK=y
  13. # Kernel image and memory ASLR.
  14. CONFIG_RANDOMIZE_BASE=y
  15. CONFIG_RANDOMIZE_MEMORY=y
  16. # Randomize allocator freelists, harden metadata.
  17. CONFIG_SLAB_FREELIST_RANDOM=y
  18. CONFIG_SLAB_FREELIST_HARDENED=y
  19. CONFIG_SLAB_BUCKETS=y
  20. CONFIG_SHUFFLE_PAGE_ALLOCATOR=y
  21. CONFIG_RANDOM_KMALLOC_CACHES=y
  22. # Sanity check userspace page table mappings.
  23. CONFIG_PAGE_TABLE_CHECK=y
  24. CONFIG_PAGE_TABLE_CHECK_ENFORCED=y
  25. # Randomize kernel stack offset on syscall entry.
  26. CONFIG_RANDOMIZE_KSTACK_OFFSET_DEFAULT=y
  27. # Basic stack frame overflow protection.
  28. CONFIG_STACKPROTECTOR=y
  29. CONFIG_STACKPROTECTOR_STRONG=y
  30. # Basic buffer length bounds checking.
  31. CONFIG_HARDENED_USERCOPY=y
  32. CONFIG_FORTIFY_SOURCE=y
  33. # Basic array index bounds checking.
  34. CONFIG_UBSAN=y
  35. CONFIG_UBSAN_TRAP=y
  36. CONFIG_UBSAN_BOUNDS=y
  37. # CONFIG_UBSAN_SHIFT is not set
  38. # CONFIG_UBSAN_DIV_ZERO is not set
  39. # CONFIG_UBSAN_UNREACHABLE is not set
  40. # CONFIG_UBSAN_SIGNED_WRAP is not set
  41. # CONFIG_UBSAN_BOOL is not set
  42. # CONFIG_UBSAN_ENUM is not set
  43. # CONFIG_UBSAN_ALIGNMENT is not set
  44. # Sampling-based heap out-of-bounds and use-after-free detection.
  45. CONFIG_KFENCE=y
  46. # Linked list integrity checking.
  47. CONFIG_LIST_HARDENED=y
  48. # Initialize all heap variables to zero on allocation.
  49. CONFIG_INIT_ON_ALLOC_DEFAULT_ON=y
  50. # Initialize all stack variables to zero on function entry.
  51. CONFIG_INIT_STACK_ALL_ZERO=y
  52. # Wipe RAM at reboot via EFI. For more details, see:
  53. # https://trustedcomputinggroup.org/resource/pc-client-work-group-platform-reset-attack-mitigation-specification/
  54. # https://bugzilla.redhat.com/show_bug.cgi?id=1532058
  55. CONFIG_RESET_ATTACK_MITIGATION=y
  56. # Disable DMA between EFI hand-off and the kernel's IOMMU setup.
  57. CONFIG_EFI_DISABLE_PCI_DMA=y
  58. # Force IOMMU TLB invalidation so devices will never be able to access stale
  59. # data content.
  60. CONFIG_IOMMU_SUPPORT=y
  61. CONFIG_IOMMU_DEFAULT_DMA_STRICT=y
  62. # Do not allow direct physical memory access to non-device memory.
  63. CONFIG_STRICT_DEVMEM=y
  64. CONFIG_IO_STRICT_DEVMEM=y
  65. # Provide userspace with seccomp BPF API for syscall attack surface reduction.
  66. CONFIG_SECCOMP=y
  67. CONFIG_SECCOMP_FILTER=y
  68. # Provides some protections against SYN flooding.
  69. CONFIG_SYN_COOKIES=y
  70. # Enable Kernel Control Flow Integrity (currently Clang only).
  71. CONFIG_CFI_CLANG=y
  72. # CONFIG_CFI_PERMISSIVE is not set
  73. # Attack surface reduction: do not autoload TTY line disciplines.
  74. # CONFIG_LDISC_AUTOLOAD is not set
  75. # Dangerous; enabling this disables userspace brk ASLR.
  76. # CONFIG_COMPAT_BRK is not set
  77. # Dangerous; exposes kernel text image layout.
  78. # CONFIG_PROC_KCORE is not set
  79. # Dangerous; enabling this disables userspace VDSO ASLR.
  80. # CONFIG_COMPAT_VDSO is not set
  81. # Attack surface reduction: Use the modern PTY interface (devpts) only.
  82. # CONFIG_LEGACY_PTYS is not set