<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://kernsec.org/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Anthraxx</id>
	<title>Linux Kernel Security Subsystem - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="http://kernsec.org/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Anthraxx"/>
	<link rel="alternate" type="text/html" href="http://kernsec.org/wiki/index.php/Special:Contributions/Anthraxx"/>
	<updated>2026-05-07T12:04:03Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.36.1</generator>
	<entry>
		<id>http://kernsec.org/wiki/index.php?title=Kernel_Self_Protection_Project/Recommended_Settings&amp;diff=4031</id>
		<title>Kernel Self Protection Project/Recommended Settings</title>
		<link rel="alternate" type="text/html" href="http://kernsec.org/wiki/index.php?title=Kernel_Self_Protection_Project/Recommended_Settings&amp;diff=4031"/>
		<updated>2021-09-15T22:51:20Z</updated>

		<summary type="html">&lt;p&gt;Anthraxx: Add missing critical whitespaces to the newly added randomize_kstack_offset entries to preserve a single visual block&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Sometimes people ask the [[Kernel Self Protection Project]] what a secure set of build CONFIGs and runtime settings are. This is a brain-dump of the various options for a particularly paranoid system.&lt;br /&gt;
&lt;br /&gt;
Another place to find recommended kernel hardening settings is via the &amp;quot;[https://github.com/a13xp0p0v/kconfig-hardened-check/ kconfig-hardened-check]&amp;quot; tool maintained by Alexander Popov.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= CONFIGs =&lt;br /&gt;
&lt;br /&gt;
 # Report BUG() conditions and kill the offending process.&lt;br /&gt;
 CONFIG_BUG=y&lt;br /&gt;
 &lt;br /&gt;
 # Make sure kernel page tables have safe permissions.&lt;br /&gt;
 CONFIG_DEBUG_KERNEL=y (prior to v4.11, needed to select CONFIG_DEBUG_RODATA below)&lt;br /&gt;
 CONFIG_DEBUG_RODATA=y (prior to v4.11)&lt;br /&gt;
 CONFIG_STRICT_KERNEL_RWX=y (since v4.11)&lt;br /&gt;
 &lt;br /&gt;
 # Report any dangerous memory permissions (not available on all archs).&lt;br /&gt;
 CONFIG_DEBUG_WX=y&lt;br /&gt;
 &lt;br /&gt;
 # Use -fstack-protector-strong (gcc 4.9+) for best stack canary coverage.&lt;br /&gt;
 # Prior to v4.18, these are:&lt;br /&gt;
 #  CONFIG_CC_STACKPROTECTOR=y&lt;br /&gt;
 #  CONFIG_CC_STACKPROTECTOR_STRONG=y&lt;br /&gt;
 CONFIG_STACKPROTECTOR=y&lt;br /&gt;
 CONFIG_STACKPROTECTOR_STRONG=y&lt;br /&gt;
 &lt;br /&gt;
 # Do not allow direct physical memory access (but if you must have it, at least enable STRICT mode...)&lt;br /&gt;
 # CONFIG_DEVMEM is not set&lt;br /&gt;
 CONFIG_STRICT_DEVMEM=y&lt;br /&gt;
 CONFIG_IO_STRICT_DEVMEM=y&lt;br /&gt;
 &lt;br /&gt;
 # Provides some protections against SYN flooding.&lt;br /&gt;
 CONFIG_SYN_COOKIES=y&lt;br /&gt;
 &lt;br /&gt;
 # Perform additional validation of various commonly targeted structures.&lt;br /&gt;
 CONFIG_DEBUG_CREDENTIALS=y&lt;br /&gt;
 CONFIG_DEBUG_NOTIFIERS=y&lt;br /&gt;
 CONFIG_DEBUG_LIST=y&lt;br /&gt;
 CONFIG_DEBUG_SG=y&lt;br /&gt;
 CONFIG_BUG_ON_DATA_CORRUPTION=y&lt;br /&gt;
 CONFIG_SCHED_STACK_END_CHECK=y&lt;br /&gt;
 &lt;br /&gt;
 # Provide userspace with seccomp BPF API for syscall attack surface reduction.&lt;br /&gt;
 CONFIG_SECCOMP=y&lt;br /&gt;
 CONFIG_SECCOMP_FILTER=y&lt;br /&gt;
 &lt;br /&gt;
 # Provide userspace with ptrace ancestry protections.&lt;br /&gt;
 CONFIG_SECURITY=y&lt;br /&gt;
 CONFIG_SECURITY_YAMA=y&lt;br /&gt;
 &lt;br /&gt;
 # Perform usercopy bounds checking. (And disable fallback to gain full whitelist enforcement.)&lt;br /&gt;
 CONFIG_HARDENED_USERCOPY=y&lt;br /&gt;
 # CONFIG_HARDENED_USERCOPY_FALLBACK is not set&lt;br /&gt;
 # CONFIG_HARDENED_USERCOPY_PAGESPAN is not set&lt;br /&gt;
 &lt;br /&gt;
 # Randomize allocator freelists, harden metadata.&lt;br /&gt;
 CONFIG_SLAB_FREELIST_RANDOM=y&lt;br /&gt;
 CONFIG_SLAB_FREELIST_HARDENED=y&lt;br /&gt;
 &lt;br /&gt;
 # Randomize high-order page allocation freelist.&lt;br /&gt;
 CONFIG_SHUFFLE_PAGE_ALLOCATOR=y&lt;br /&gt;
 &lt;br /&gt;
 # Allow allocator validation checking to be enabled (see &amp;quot;slub_debug=P&amp;quot; below).&lt;br /&gt;
 CONFIG_SLUB_DEBUG=y&lt;br /&gt;
 &lt;br /&gt;
 # Wipe higher-level memory allocations when they are freed (needs &amp;quot;page_poison=1&amp;quot; command line below).&lt;br /&gt;
 # (If you can afford even more performance penalty, leave CONFIG_PAGE_POISONING_NO_SANITY=n)&lt;br /&gt;
 CONFIG_PAGE_POISONING=y&lt;br /&gt;
 CONFIG_PAGE_POISONING_NO_SANITY=y&lt;br /&gt;
 CONFIG_PAGE_POISONING_ZERO=y&lt;br /&gt;
 &lt;br /&gt;
 # Wipe slab and page allocations (since v5.3)&lt;br /&gt;
 # Instead of &amp;quot;slub_debug=P&amp;quot; and &amp;quot;page_poison=1&amp;quot;, a single place can control memory allocation wiping now.&lt;br /&gt;
 # The init_on_free is only needed if there is concern about minimizing stale data lifetime.&lt;br /&gt;
 CONFIG_INIT_ON_ALLOC_DEFAULT_ON=y&lt;br /&gt;
 CONFIG_INIT_ON_FREE_DEFAULT_ON=y&lt;br /&gt;
 &lt;br /&gt;
 # Initialize all stack variables on function entry. (Clang builds only. For GCC, see CONFIG_GCC_PLUGIN_STRUCTLEAK_BYREF_ALL=y below)&lt;br /&gt;
 CONFIG_INIT_STACK_ALL=y&lt;br /&gt;
 &lt;br /&gt;
 # Adds guard pages to kernel stacks (not all architectures support this yet).&lt;br /&gt;
 CONFIG_VMAP_STACK=y&lt;br /&gt;
 &lt;br /&gt;
 # Perform extensive checks on reference counting.&lt;br /&gt;
 CONFIG_REFCOUNT_FULL=y&lt;br /&gt;
 &lt;br /&gt;
 # Check for memory copies that might overflow a structure in str*() and mem*() functions both at build-time and run-time.&lt;br /&gt;
 CONFIG_FORTIFY_SOURCE=y&lt;br /&gt;
 &lt;br /&gt;
 # Avoid kernel memory address exposures via dmesg (sets sysctl kernel.dmesg_restrict initial value to 1)&lt;br /&gt;
 CONFIG_SECURITY_DMESG_RESTRICT=y&lt;br /&gt;
 &lt;br /&gt;
 # Dangerous; enabling this allows direct physical memory writing.&lt;br /&gt;
 # CONFIG_ACPI_CUSTOM_METHOD is not set&lt;br /&gt;
 &lt;br /&gt;
 # Dangerous; enabling this disables brk ASLR.&lt;br /&gt;
 # CONFIG_COMPAT_BRK is not set&lt;br /&gt;
 &lt;br /&gt;
 # Dangerous; enabling this allows direct kernel memory writing.&lt;br /&gt;
 # CONFIG_DEVKMEM is not set&lt;br /&gt;
 &lt;br /&gt;
 # Dangerous; exposes kernel text image layout.&lt;br /&gt;
 # CONFIG_PROC_KCORE is not set&lt;br /&gt;
 &lt;br /&gt;
 # Dangerous; enabling this disables VDSO ASLR.&lt;br /&gt;
 # CONFIG_COMPAT_VDSO is not set&lt;br /&gt;
 &lt;br /&gt;
 # Dangerous; enabling this allows replacement of running kernel.&lt;br /&gt;
 # CONFIG_KEXEC is not set&lt;br /&gt;
 &lt;br /&gt;
 # Dangerous; enabling this allows replacement of running kernel.&lt;br /&gt;
 # CONFIG_HIBERNATION is not set&lt;br /&gt;
 &lt;br /&gt;
 # Prior to v4.1, assists heap memory attacks; best to keep interface disabled.&lt;br /&gt;
 # CONFIG_INET_DIAG is not set&lt;br /&gt;
 &lt;br /&gt;
 # Easily confused by misconfigured userspace, keep off.&lt;br /&gt;
 # CONFIG_BINFMT_MISC is not set&lt;br /&gt;
 &lt;br /&gt;
 # Use the modern PTY interface (devpts) only.&lt;br /&gt;
 # CONFIG_LEGACY_PTYS is not set&lt;br /&gt;
 &lt;br /&gt;
 # If SELinux can be disabled at runtime, the LSM structures cannot be read-only; keep off.&lt;br /&gt;
 # CONFIG_SECURITY_SELINUX_DISABLE is not set&lt;br /&gt;
 &lt;br /&gt;
 # Reboot devices immediately if kernel experiences an Oops.&lt;br /&gt;
 CONFIG_PANIC_ON_OOPS=y&lt;br /&gt;
 CONFIG_PANIC_TIMEOUT=-1&lt;br /&gt;
 &lt;br /&gt;
 # Keep root from altering kernel memory via loadable modules.&lt;br /&gt;
 # CONFIG_MODULES is not set&lt;br /&gt;
 &lt;br /&gt;
 # But if CONFIG_MODULE=y is needed, at least they must be signed with a per-build key.&lt;br /&gt;
 CONFIG_DEBUG_SET_MODULE_RONX=y (prior to v4.11)&lt;br /&gt;
 CONFIG_STRICT_MODULE_RWX=y (since v4.11)&lt;br /&gt;
 CONFIG_MODULE_SIG=y&lt;br /&gt;
 CONFIG_MODULE_SIG_FORCE=y&lt;br /&gt;
 CONFIG_MODULE_SIG_ALL=y&lt;br /&gt;
 CONFIG_MODULE_SIG_SHA512=y&lt;br /&gt;
 CONFIG_MODULE_SIG_HASH=&amp;quot;sha512&amp;quot;&lt;br /&gt;
 CONFIG_MODULE_SIG_KEY=&amp;quot;certs/signing_key.pem&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== GCC plugins ==&lt;br /&gt;
&lt;br /&gt;
 # Enable GCC Plugins&lt;br /&gt;
 CONFIG_GCC_PLUGINS=y&lt;br /&gt;
 &lt;br /&gt;
 # Gather additional entropy at boot time for systems that may not have appropriate entropy sources.&lt;br /&gt;
 CONFIG_GCC_PLUGIN_LATENT_ENTROPY=y&lt;br /&gt;
 &lt;br /&gt;
 # Force all structures to be initialized before they are passed to other functions.&lt;br /&gt;
 # When building with GCC:&lt;br /&gt;
 CONFIG_GCC_PLUGIN_STRUCTLEAK=y&lt;br /&gt;
 CONFIG_GCC_PLUGIN_STRUCTLEAK_BYREF_ALL=y&lt;br /&gt;
 &lt;br /&gt;
 # Wipe stack contents on syscall exit (reduces stale data lifetime in stack)&lt;br /&gt;
 CONFIG_GCC_PLUGIN_STACKLEAK=y&lt;br /&gt;
 &lt;br /&gt;
 # Randomize the layout of system structures. This may have dramatic performance impact, so&lt;br /&gt;
 # use with caution or also use CONFIG_GCC_PLUGIN_RANDSTRUCT_PERFORMANCE=y&lt;br /&gt;
 CONFIG_GCC_PLUGIN_RANDSTRUCT=y&lt;br /&gt;
&lt;br /&gt;
== x86_64 ==&lt;br /&gt;
&lt;br /&gt;
 # Full 64-bit means PAE and NX bit.&lt;br /&gt;
 CONFIG_X86_64=y&lt;br /&gt;
 &lt;br /&gt;
 # Disallow allocating the first 64k of memory.&lt;br /&gt;
 CONFIG_DEFAULT_MMAP_MIN_ADDR=65536&lt;br /&gt;
 &lt;br /&gt;
 # Disable Model-Specific Register writes.&lt;br /&gt;
 # CONFIG_X86_MSR is not set&lt;br /&gt;
 &lt;br /&gt;
 # Randomize position of kernel and memory.&lt;br /&gt;
 CONFIG_RANDOMIZE_BASE=y&lt;br /&gt;
 CONFIG_RANDOMIZE_MEMORY=y&lt;br /&gt;
 &lt;br /&gt;
 # Randomize kernel stack offset on syscall entry (since v5.13).&lt;br /&gt;
 CONFIG_RANDOMIZE_KSTACK_OFFSET_DEFAULT=y&lt;br /&gt;
 &lt;br /&gt;
 # Modern libc no longer needs a fixed-position mapping in userspace, remove it as a possible target.&lt;br /&gt;
 CONFIG_LEGACY_VSYSCALL_NONE=y&lt;br /&gt;
 &lt;br /&gt;
 # Enable Kernel Page Table Isolation to remove an entire class of cache timing side-channels.&lt;br /&gt;
 CONFIG_PAGE_TABLE_ISOLATION=y&lt;br /&gt;
 &lt;br /&gt;
 # Remove additional attack surface, unless you really need them.&lt;br /&gt;
 # CONFIG_IA32_EMULATION is not set&lt;br /&gt;
 # CONFIG_X86_X32 is not set&lt;br /&gt;
 # CONFIG_MODIFY_LDT_SYSCALL is not set&lt;br /&gt;
&lt;br /&gt;
== arm64 ==&lt;br /&gt;
&lt;br /&gt;
 # Disallow allocating the first 32k of memory (cannot be 64k due to ARM loader).&lt;br /&gt;
 CONFIG_DEFAULT_MMAP_MIN_ADDR=32768&lt;br /&gt;
 &lt;br /&gt;
 # Randomize position of kernel (requires UEFI RNG or bootloader support for /chosen/kaslr-seed DT property).&lt;br /&gt;
 CONFIG_RANDOMIZE_BASE=y&lt;br /&gt;
 &lt;br /&gt;
 # Randomize kernel stack offset on syscall entry (since v5.13).&lt;br /&gt;
 CONFIG_RANDOMIZE_KSTACK_OFFSET_DEFAULT=y&lt;br /&gt;
 &lt;br /&gt;
 # Make sure PAN emulation is enabled.&lt;br /&gt;
 CONFIG_ARM64_SW_TTBR0_PAN=y&lt;br /&gt;
 &lt;br /&gt;
 # Enable Kernel Page Table Isolation to remove an entire class of cache timing side-channels.&lt;br /&gt;
 CONFIG_UNMAP_KERNEL_AT_EL0=y&lt;br /&gt;
&lt;br /&gt;
== x86_32 ==&lt;br /&gt;
&lt;br /&gt;
 # On 32-bit kernels, require PAE for NX bit support.&lt;br /&gt;
 # CONFIG_M486 is not set&lt;br /&gt;
 # CONFIG_HIGHMEM4G is not set&lt;br /&gt;
 CONFIG_HIGHMEM64G=y&lt;br /&gt;
 CONFIG_X86_PAE=y&lt;br /&gt;
 &lt;br /&gt;
 # Disallow allocating the first 64k of memory.&lt;br /&gt;
 CONFIG_DEFAULT_MMAP_MIN_ADDR=65536&lt;br /&gt;
 &lt;br /&gt;
 # Disable Model-Specific Register writes.&lt;br /&gt;
 # CONFIG_X86_MSR is not set&lt;br /&gt;
 &lt;br /&gt;
 # Randomize position of kernel.&lt;br /&gt;
 CONFIG_RANDOMIZE_BASE=y&lt;br /&gt;
 &lt;br /&gt;
 # Randomize kernel stack offset on syscall entry (since v5.13).&lt;br /&gt;
 CONFIG_RANDOMIZE_KSTACK_OFFSET_DEFAULT=y&lt;br /&gt;
 &lt;br /&gt;
 # Enable Kernel Page Table Isolation to remove an entire class of cache timing side-channels.&lt;br /&gt;
 CONFIG_PAGE_TABLE_ISOLATION=y&lt;br /&gt;
 &lt;br /&gt;
 # Don't allow for 16-bit program emulation and associated LDT tricks.&lt;br /&gt;
 # CONFIG_MODIFY_LDT_SYSCALL is not set&lt;br /&gt;
&lt;br /&gt;
== arm ==&lt;br /&gt;
&lt;br /&gt;
 # Disallow allocating the first 32k of memory (cannot be 64k due to ARM loader).&lt;br /&gt;
 CONFIG_DEFAULT_MMAP_MIN_ADDR=32768&lt;br /&gt;
 &lt;br /&gt;
 # For maximal userspace memory area (and maximum ASLR).&lt;br /&gt;
 CONFIG_VMSPLIT_3G=y&lt;br /&gt;
 &lt;br /&gt;
 # If building an old out-of-tree Qualcomm kernel, this is similar to CONFIG_STRICT_KERNEL_RWX.&lt;br /&gt;
 CONFIG_STRICT_MEMORY_RWX=y&lt;br /&gt;
 &lt;br /&gt;
 # Make sure PXN/PAN emulation is enabled.&lt;br /&gt;
 CONFIG_CPU_SW_DOMAIN_PAN=y&lt;br /&gt;
 &lt;br /&gt;
 # Dangerous; old interfaces and needless additional attack surface.&lt;br /&gt;
 # CONFIG_OABI_COMPAT is not set&lt;br /&gt;
&lt;br /&gt;
= kernel command line options =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 # Wipe slab and page allocations (Since v5.3; supersedes &amp;quot;slub_debug=P&amp;quot; and &amp;quot;page_poison=1&amp;quot; below)&lt;br /&gt;
 # See CONFIG_INIT_ON_ALLOC_DEFAULT_ON=y and CONFIG_INIT_ON_FREE_DEFAULT_ON=y above.&lt;br /&gt;
 init_on_alloc=1&lt;br /&gt;
 init_on_free=1&lt;br /&gt;
 &lt;br /&gt;
 # Randomize kernel stack offset on syscall entry (since v5.13).&lt;br /&gt;
 # See CONFIG_RANDOMIZE_KSTACK_OFFSET_DEFAULT above.&lt;br /&gt;
 randomize_kstack_offset=on&lt;br /&gt;
 &lt;br /&gt;
 # Disable slab merging (makes many heap overflow attacks more difficult).&lt;br /&gt;
 slab_nomerge&lt;br /&gt;
 &lt;br /&gt;
 # Always enable Kernel Page Table Isolation, even if the CPU claims it is safe from Meltdown.&lt;br /&gt;
 pti=on&lt;br /&gt;
 &lt;br /&gt;
 # To prevent against L1TF, at the cost of losing hyper threading ('''slow''').&lt;br /&gt;
 nosmt&lt;br /&gt;
 &lt;br /&gt;
 # Enable SLUB redzoning and sanity checking ('''slow'''; requires CONFIG_SLUB_DEBUG=y above).&lt;br /&gt;
 slub_debug=ZF&lt;br /&gt;
 &lt;br /&gt;
 # (Before v5.3 without &amp;quot;init_on_free=1&amp;quot;) Enable slub/slab allocator free poisoning (requires CONFIG_SLUB_DEBUG=y above).&lt;br /&gt;
 slub_debug=P&lt;br /&gt;
 &lt;br /&gt;
 # (Before v5.3 without &amp;quot;init_on_free=1&amp;quot;) Enable buddy allocator free poisoning (requires CONFIG_PAGE_POISONING=y above).&lt;br /&gt;
 page_poison=1&lt;br /&gt;
 &lt;br /&gt;
== x86_64 ==&lt;br /&gt;
&lt;br /&gt;
 # Remove vsyscall entirely to avoid it being a fixed-position ROP target of any kind.&lt;br /&gt;
 # (Same as CONFIG_LEGACY_VSYSCALL_NONE=y above.)&lt;br /&gt;
 vsyscall=none&lt;br /&gt;
&lt;br /&gt;
= sysctls =&lt;br /&gt;
&lt;br /&gt;
 # Try to keep kernel address exposures out of various /proc files (kallsyms, modules, etc). (There is [https://lore.kernel.org/lkml/20101217164431.08f3e730.akpm@linux-foundation.org/ no CONFIG] for the changing the initial value.)&lt;br /&gt;
 kernel.kptr_restrict = 1&lt;br /&gt;
 &lt;br /&gt;
 # Avoid kernel memory address exposures via dmesg (this value can also be set by CONFIG_SECURITY_DMESG_RESTRICT).&lt;br /&gt;
 kernel.dmesg_restrict = 1&lt;br /&gt;
 &lt;br /&gt;
 # Block non-uid-0 profiling (needs [https://patchwork.kernel.org/patch/9249919/ distro patch], otherwise this is the same as &amp;quot;= 2&amp;quot;)&lt;br /&gt;
 kernel.perf_event_paranoid = 3&lt;br /&gt;
 &lt;br /&gt;
 # Turn off kexec, even if it's built in.&lt;br /&gt;
 kernel.kexec_load_disabled = 1&lt;br /&gt;
 &lt;br /&gt;
 # Avoid non-ancestor ptrace access to running processes and their credentials.&lt;br /&gt;
 kernel.yama.ptrace_scope = 1&lt;br /&gt;
 &lt;br /&gt;
 # Disable User Namespaces, as it opens up a large attack surface to unprivileged users.&lt;br /&gt;
 user.max_user_namespaces = 0&lt;br /&gt;
 &lt;br /&gt;
 # Turn off unprivileged eBPF access.&lt;br /&gt;
 kernel.unprivileged_bpf_disabled = 1&lt;br /&gt;
 &lt;br /&gt;
 # Turn on BPF JIT hardening, if the JIT is enabled.&lt;br /&gt;
 net.core.bpf_jit_harden = 2&lt;/div&gt;</summary>
		<author><name>Anthraxx</name></author>
	</entry>
	<entry>
		<id>http://kernsec.org/wiki/index.php?title=Kernel_Self_Protection_Project/Recommended_Settings&amp;diff=4030</id>
		<title>Kernel Self Protection Project/Recommended Settings</title>
		<link rel="alternate" type="text/html" href="http://kernsec.org/wiki/index.php?title=Kernel_Self_Protection_Project/Recommended_Settings&amp;diff=4030"/>
		<updated>2021-09-15T22:45:36Z</updated>

		<summary type="html">&lt;p&gt;Anthraxx: Add randomize_kstack_offset (CONFIG_RANDOMIZE_KSTACK_OFFSET_DEFAULT) for x86_64, arm64 and x86_32 (since v5.13)&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Sometimes people ask the [[Kernel Self Protection Project]] what a secure set of build CONFIGs and runtime settings are. This is a brain-dump of the various options for a particularly paranoid system.&lt;br /&gt;
&lt;br /&gt;
Another place to find recommended kernel hardening settings is via the &amp;quot;[https://github.com/a13xp0p0v/kconfig-hardened-check/ kconfig-hardened-check]&amp;quot; tool maintained by Alexander Popov.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= CONFIGs =&lt;br /&gt;
&lt;br /&gt;
 # Report BUG() conditions and kill the offending process.&lt;br /&gt;
 CONFIG_BUG=y&lt;br /&gt;
 &lt;br /&gt;
 # Make sure kernel page tables have safe permissions.&lt;br /&gt;
 CONFIG_DEBUG_KERNEL=y (prior to v4.11, needed to select CONFIG_DEBUG_RODATA below)&lt;br /&gt;
 CONFIG_DEBUG_RODATA=y (prior to v4.11)&lt;br /&gt;
 CONFIG_STRICT_KERNEL_RWX=y (since v4.11)&lt;br /&gt;
 &lt;br /&gt;
 # Report any dangerous memory permissions (not available on all archs).&lt;br /&gt;
 CONFIG_DEBUG_WX=y&lt;br /&gt;
 &lt;br /&gt;
 # Use -fstack-protector-strong (gcc 4.9+) for best stack canary coverage.&lt;br /&gt;
 # Prior to v4.18, these are:&lt;br /&gt;
 #  CONFIG_CC_STACKPROTECTOR=y&lt;br /&gt;
 #  CONFIG_CC_STACKPROTECTOR_STRONG=y&lt;br /&gt;
 CONFIG_STACKPROTECTOR=y&lt;br /&gt;
 CONFIG_STACKPROTECTOR_STRONG=y&lt;br /&gt;
 &lt;br /&gt;
 # Do not allow direct physical memory access (but if you must have it, at least enable STRICT mode...)&lt;br /&gt;
 # CONFIG_DEVMEM is not set&lt;br /&gt;
 CONFIG_STRICT_DEVMEM=y&lt;br /&gt;
 CONFIG_IO_STRICT_DEVMEM=y&lt;br /&gt;
 &lt;br /&gt;
 # Provides some protections against SYN flooding.&lt;br /&gt;
 CONFIG_SYN_COOKIES=y&lt;br /&gt;
 &lt;br /&gt;
 # Perform additional validation of various commonly targeted structures.&lt;br /&gt;
 CONFIG_DEBUG_CREDENTIALS=y&lt;br /&gt;
 CONFIG_DEBUG_NOTIFIERS=y&lt;br /&gt;
 CONFIG_DEBUG_LIST=y&lt;br /&gt;
 CONFIG_DEBUG_SG=y&lt;br /&gt;
 CONFIG_BUG_ON_DATA_CORRUPTION=y&lt;br /&gt;
 CONFIG_SCHED_STACK_END_CHECK=y&lt;br /&gt;
 &lt;br /&gt;
 # Provide userspace with seccomp BPF API for syscall attack surface reduction.&lt;br /&gt;
 CONFIG_SECCOMP=y&lt;br /&gt;
 CONFIG_SECCOMP_FILTER=y&lt;br /&gt;
 &lt;br /&gt;
 # Provide userspace with ptrace ancestry protections.&lt;br /&gt;
 CONFIG_SECURITY=y&lt;br /&gt;
 CONFIG_SECURITY_YAMA=y&lt;br /&gt;
 &lt;br /&gt;
 # Perform usercopy bounds checking. (And disable fallback to gain full whitelist enforcement.)&lt;br /&gt;
 CONFIG_HARDENED_USERCOPY=y&lt;br /&gt;
 # CONFIG_HARDENED_USERCOPY_FALLBACK is not set&lt;br /&gt;
 # CONFIG_HARDENED_USERCOPY_PAGESPAN is not set&lt;br /&gt;
 &lt;br /&gt;
 # Randomize allocator freelists, harden metadata.&lt;br /&gt;
 CONFIG_SLAB_FREELIST_RANDOM=y&lt;br /&gt;
 CONFIG_SLAB_FREELIST_HARDENED=y&lt;br /&gt;
 &lt;br /&gt;
 # Randomize high-order page allocation freelist.&lt;br /&gt;
 CONFIG_SHUFFLE_PAGE_ALLOCATOR=y&lt;br /&gt;
 &lt;br /&gt;
 # Allow allocator validation checking to be enabled (see &amp;quot;slub_debug=P&amp;quot; below).&lt;br /&gt;
 CONFIG_SLUB_DEBUG=y&lt;br /&gt;
 &lt;br /&gt;
 # Wipe higher-level memory allocations when they are freed (needs &amp;quot;page_poison=1&amp;quot; command line below).&lt;br /&gt;
 # (If you can afford even more performance penalty, leave CONFIG_PAGE_POISONING_NO_SANITY=n)&lt;br /&gt;
 CONFIG_PAGE_POISONING=y&lt;br /&gt;
 CONFIG_PAGE_POISONING_NO_SANITY=y&lt;br /&gt;
 CONFIG_PAGE_POISONING_ZERO=y&lt;br /&gt;
 &lt;br /&gt;
 # Wipe slab and page allocations (since v5.3)&lt;br /&gt;
 # Instead of &amp;quot;slub_debug=P&amp;quot; and &amp;quot;page_poison=1&amp;quot;, a single place can control memory allocation wiping now.&lt;br /&gt;
 # The init_on_free is only needed if there is concern about minimizing stale data lifetime.&lt;br /&gt;
 CONFIG_INIT_ON_ALLOC_DEFAULT_ON=y&lt;br /&gt;
 CONFIG_INIT_ON_FREE_DEFAULT_ON=y&lt;br /&gt;
 &lt;br /&gt;
 # Initialize all stack variables on function entry. (Clang builds only. For GCC, see CONFIG_GCC_PLUGIN_STRUCTLEAK_BYREF_ALL=y below)&lt;br /&gt;
 CONFIG_INIT_STACK_ALL=y&lt;br /&gt;
 &lt;br /&gt;
 # Adds guard pages to kernel stacks (not all architectures support this yet).&lt;br /&gt;
 CONFIG_VMAP_STACK=y&lt;br /&gt;
 &lt;br /&gt;
 # Perform extensive checks on reference counting.&lt;br /&gt;
 CONFIG_REFCOUNT_FULL=y&lt;br /&gt;
 &lt;br /&gt;
 # Check for memory copies that might overflow a structure in str*() and mem*() functions both at build-time and run-time.&lt;br /&gt;
 CONFIG_FORTIFY_SOURCE=y&lt;br /&gt;
 &lt;br /&gt;
 # Avoid kernel memory address exposures via dmesg (sets sysctl kernel.dmesg_restrict initial value to 1)&lt;br /&gt;
 CONFIG_SECURITY_DMESG_RESTRICT=y&lt;br /&gt;
 &lt;br /&gt;
 # Dangerous; enabling this allows direct physical memory writing.&lt;br /&gt;
 # CONFIG_ACPI_CUSTOM_METHOD is not set&lt;br /&gt;
 &lt;br /&gt;
 # Dangerous; enabling this disables brk ASLR.&lt;br /&gt;
 # CONFIG_COMPAT_BRK is not set&lt;br /&gt;
 &lt;br /&gt;
 # Dangerous; enabling this allows direct kernel memory writing.&lt;br /&gt;
 # CONFIG_DEVKMEM is not set&lt;br /&gt;
 &lt;br /&gt;
 # Dangerous; exposes kernel text image layout.&lt;br /&gt;
 # CONFIG_PROC_KCORE is not set&lt;br /&gt;
 &lt;br /&gt;
 # Dangerous; enabling this disables VDSO ASLR.&lt;br /&gt;
 # CONFIG_COMPAT_VDSO is not set&lt;br /&gt;
 &lt;br /&gt;
 # Dangerous; enabling this allows replacement of running kernel.&lt;br /&gt;
 # CONFIG_KEXEC is not set&lt;br /&gt;
 &lt;br /&gt;
 # Dangerous; enabling this allows replacement of running kernel.&lt;br /&gt;
 # CONFIG_HIBERNATION is not set&lt;br /&gt;
 &lt;br /&gt;
 # Prior to v4.1, assists heap memory attacks; best to keep interface disabled.&lt;br /&gt;
 # CONFIG_INET_DIAG is not set&lt;br /&gt;
 &lt;br /&gt;
 # Easily confused by misconfigured userspace, keep off.&lt;br /&gt;
 # CONFIG_BINFMT_MISC is not set&lt;br /&gt;
 &lt;br /&gt;
 # Use the modern PTY interface (devpts) only.&lt;br /&gt;
 # CONFIG_LEGACY_PTYS is not set&lt;br /&gt;
 &lt;br /&gt;
 # If SELinux can be disabled at runtime, the LSM structures cannot be read-only; keep off.&lt;br /&gt;
 # CONFIG_SECURITY_SELINUX_DISABLE is not set&lt;br /&gt;
 &lt;br /&gt;
 # Reboot devices immediately if kernel experiences an Oops.&lt;br /&gt;
 CONFIG_PANIC_ON_OOPS=y&lt;br /&gt;
 CONFIG_PANIC_TIMEOUT=-1&lt;br /&gt;
 &lt;br /&gt;
 # Keep root from altering kernel memory via loadable modules.&lt;br /&gt;
 # CONFIG_MODULES is not set&lt;br /&gt;
 &lt;br /&gt;
 # But if CONFIG_MODULE=y is needed, at least they must be signed with a per-build key.&lt;br /&gt;
 CONFIG_DEBUG_SET_MODULE_RONX=y (prior to v4.11)&lt;br /&gt;
 CONFIG_STRICT_MODULE_RWX=y (since v4.11)&lt;br /&gt;
 CONFIG_MODULE_SIG=y&lt;br /&gt;
 CONFIG_MODULE_SIG_FORCE=y&lt;br /&gt;
 CONFIG_MODULE_SIG_ALL=y&lt;br /&gt;
 CONFIG_MODULE_SIG_SHA512=y&lt;br /&gt;
 CONFIG_MODULE_SIG_HASH=&amp;quot;sha512&amp;quot;&lt;br /&gt;
 CONFIG_MODULE_SIG_KEY=&amp;quot;certs/signing_key.pem&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== GCC plugins ==&lt;br /&gt;
&lt;br /&gt;
 # Enable GCC Plugins&lt;br /&gt;
 CONFIG_GCC_PLUGINS=y&lt;br /&gt;
 &lt;br /&gt;
 # Gather additional entropy at boot time for systems that may not have appropriate entropy sources.&lt;br /&gt;
 CONFIG_GCC_PLUGIN_LATENT_ENTROPY=y&lt;br /&gt;
 &lt;br /&gt;
 # Force all structures to be initialized before they are passed to other functions.&lt;br /&gt;
 # When building with GCC:&lt;br /&gt;
 CONFIG_GCC_PLUGIN_STRUCTLEAK=y&lt;br /&gt;
 CONFIG_GCC_PLUGIN_STRUCTLEAK_BYREF_ALL=y&lt;br /&gt;
 &lt;br /&gt;
 # Wipe stack contents on syscall exit (reduces stale data lifetime in stack)&lt;br /&gt;
 CONFIG_GCC_PLUGIN_STACKLEAK=y&lt;br /&gt;
 &lt;br /&gt;
 # Randomize the layout of system structures. This may have dramatic performance impact, so&lt;br /&gt;
 # use with caution or also use CONFIG_GCC_PLUGIN_RANDSTRUCT_PERFORMANCE=y&lt;br /&gt;
 CONFIG_GCC_PLUGIN_RANDSTRUCT=y&lt;br /&gt;
&lt;br /&gt;
== x86_64 ==&lt;br /&gt;
&lt;br /&gt;
 # Full 64-bit means PAE and NX bit.&lt;br /&gt;
 CONFIG_X86_64=y&lt;br /&gt;
 &lt;br /&gt;
 # Disallow allocating the first 64k of memory.&lt;br /&gt;
 CONFIG_DEFAULT_MMAP_MIN_ADDR=65536&lt;br /&gt;
 &lt;br /&gt;
 # Disable Model-Specific Register writes.&lt;br /&gt;
 # CONFIG_X86_MSR is not set&lt;br /&gt;
 &lt;br /&gt;
 # Randomize position of kernel and memory.&lt;br /&gt;
 CONFIG_RANDOMIZE_BASE=y&lt;br /&gt;
 CONFIG_RANDOMIZE_MEMORY=y&lt;br /&gt;
 &lt;br /&gt;
 # Randomize kernel stack offset on syscall entry (since v5.13).&lt;br /&gt;
 CONFIG_RANDOMIZE_KSTACK_OFFSET_DEFAULT=y&lt;br /&gt;
&lt;br /&gt;
 # Modern libc no longer needs a fixed-position mapping in userspace, remove it as a possible target.&lt;br /&gt;
 CONFIG_LEGACY_VSYSCALL_NONE=y&lt;br /&gt;
 &lt;br /&gt;
 # Enable Kernel Page Table Isolation to remove an entire class of cache timing side-channels.&lt;br /&gt;
 CONFIG_PAGE_TABLE_ISOLATION=y&lt;br /&gt;
 &lt;br /&gt;
 # Remove additional attack surface, unless you really need them.&lt;br /&gt;
 # CONFIG_IA32_EMULATION is not set&lt;br /&gt;
 # CONFIG_X86_X32 is not set&lt;br /&gt;
 # CONFIG_MODIFY_LDT_SYSCALL is not set&lt;br /&gt;
&lt;br /&gt;
== arm64 ==&lt;br /&gt;
&lt;br /&gt;
 # Disallow allocating the first 32k of memory (cannot be 64k due to ARM loader).&lt;br /&gt;
 CONFIG_DEFAULT_MMAP_MIN_ADDR=32768&lt;br /&gt;
 &lt;br /&gt;
 # Randomize position of kernel (requires UEFI RNG or bootloader support for /chosen/kaslr-seed DT property).&lt;br /&gt;
 CONFIG_RANDOMIZE_BASE=y&lt;br /&gt;
 &lt;br /&gt;
 # Randomize kernel stack offset on syscall entry (since v5.13).&lt;br /&gt;
 CONFIG_RANDOMIZE_KSTACK_OFFSET_DEFAULT=y&lt;br /&gt;
&lt;br /&gt;
 # Make sure PAN emulation is enabled.&lt;br /&gt;
 CONFIG_ARM64_SW_TTBR0_PAN=y&lt;br /&gt;
 &lt;br /&gt;
 # Enable Kernel Page Table Isolation to remove an entire class of cache timing side-channels.&lt;br /&gt;
 CONFIG_UNMAP_KERNEL_AT_EL0=y&lt;br /&gt;
&lt;br /&gt;
== x86_32 ==&lt;br /&gt;
&lt;br /&gt;
 # On 32-bit kernels, require PAE for NX bit support.&lt;br /&gt;
 # CONFIG_M486 is not set&lt;br /&gt;
 # CONFIG_HIGHMEM4G is not set&lt;br /&gt;
 CONFIG_HIGHMEM64G=y&lt;br /&gt;
 CONFIG_X86_PAE=y&lt;br /&gt;
 &lt;br /&gt;
 # Disallow allocating the first 64k of memory.&lt;br /&gt;
 CONFIG_DEFAULT_MMAP_MIN_ADDR=65536&lt;br /&gt;
 &lt;br /&gt;
 # Disable Model-Specific Register writes.&lt;br /&gt;
 # CONFIG_X86_MSR is not set&lt;br /&gt;
 &lt;br /&gt;
 # Randomize position of kernel.&lt;br /&gt;
 CONFIG_RANDOMIZE_BASE=y&lt;br /&gt;
 &lt;br /&gt;
 # Randomize kernel stack offset on syscall entry (since v5.13).&lt;br /&gt;
 CONFIG_RANDOMIZE_KSTACK_OFFSET_DEFAULT=y&lt;br /&gt;
&lt;br /&gt;
 # Enable Kernel Page Table Isolation to remove an entire class of cache timing side-channels.&lt;br /&gt;
 CONFIG_PAGE_TABLE_ISOLATION=y&lt;br /&gt;
 &lt;br /&gt;
 # Don't allow for 16-bit program emulation and associated LDT tricks.&lt;br /&gt;
 # CONFIG_MODIFY_LDT_SYSCALL is not set&lt;br /&gt;
&lt;br /&gt;
== arm ==&lt;br /&gt;
&lt;br /&gt;
 # Disallow allocating the first 32k of memory (cannot be 64k due to ARM loader).&lt;br /&gt;
 CONFIG_DEFAULT_MMAP_MIN_ADDR=32768&lt;br /&gt;
 &lt;br /&gt;
 # For maximal userspace memory area (and maximum ASLR).&lt;br /&gt;
 CONFIG_VMSPLIT_3G=y&lt;br /&gt;
 &lt;br /&gt;
 # If building an old out-of-tree Qualcomm kernel, this is similar to CONFIG_STRICT_KERNEL_RWX.&lt;br /&gt;
 CONFIG_STRICT_MEMORY_RWX=y&lt;br /&gt;
 &lt;br /&gt;
 # Make sure PXN/PAN emulation is enabled.&lt;br /&gt;
 CONFIG_CPU_SW_DOMAIN_PAN=y&lt;br /&gt;
 &lt;br /&gt;
 # Dangerous; old interfaces and needless additional attack surface.&lt;br /&gt;
 # CONFIG_OABI_COMPAT is not set&lt;br /&gt;
&lt;br /&gt;
= kernel command line options =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 # Wipe slab and page allocations (Since v5.3; supersedes &amp;quot;slub_debug=P&amp;quot; and &amp;quot;page_poison=1&amp;quot; below)&lt;br /&gt;
 # See CONFIG_INIT_ON_ALLOC_DEFAULT_ON=y and CONFIG_INIT_ON_FREE_DEFAULT_ON=y above.&lt;br /&gt;
 init_on_alloc=1&lt;br /&gt;
 init_on_free=1&lt;br /&gt;
 &lt;br /&gt;
 # Randomize kernel stack offset on syscall entry (since v5.13).&lt;br /&gt;
 # See CONFIG_RANDOMIZE_KSTACK_OFFSET_DEFAULT above.&lt;br /&gt;
 randomize_kstack_offset=on&lt;br /&gt;
&lt;br /&gt;
 # Disable slab merging (makes many heap overflow attacks more difficult).&lt;br /&gt;
 slab_nomerge&lt;br /&gt;
 &lt;br /&gt;
 # Always enable Kernel Page Table Isolation, even if the CPU claims it is safe from Meltdown.&lt;br /&gt;
 pti=on&lt;br /&gt;
 &lt;br /&gt;
 # To prevent against L1TF, at the cost of losing hyper threading ('''slow''').&lt;br /&gt;
 nosmt&lt;br /&gt;
 &lt;br /&gt;
 # Enable SLUB redzoning and sanity checking ('''slow'''; requires CONFIG_SLUB_DEBUG=y above).&lt;br /&gt;
 slub_debug=ZF&lt;br /&gt;
 &lt;br /&gt;
 # (Before v5.3 without &amp;quot;init_on_free=1&amp;quot;) Enable slub/slab allocator free poisoning (requires CONFIG_SLUB_DEBUG=y above).&lt;br /&gt;
 slub_debug=P&lt;br /&gt;
 &lt;br /&gt;
 # (Before v5.3 without &amp;quot;init_on_free=1&amp;quot;) Enable buddy allocator free poisoning (requires CONFIG_PAGE_POISONING=y above).&lt;br /&gt;
 page_poison=1&lt;br /&gt;
 &lt;br /&gt;
== x86_64 ==&lt;br /&gt;
&lt;br /&gt;
 # Remove vsyscall entirely to avoid it being a fixed-position ROP target of any kind.&lt;br /&gt;
 # (Same as CONFIG_LEGACY_VSYSCALL_NONE=y above.)&lt;br /&gt;
 vsyscall=none&lt;br /&gt;
&lt;br /&gt;
= sysctls =&lt;br /&gt;
&lt;br /&gt;
 # Try to keep kernel address exposures out of various /proc files (kallsyms, modules, etc). (There is [https://lore.kernel.org/lkml/20101217164431.08f3e730.akpm@linux-foundation.org/ no CONFIG] for the changing the initial value.)&lt;br /&gt;
 kernel.kptr_restrict = 1&lt;br /&gt;
 &lt;br /&gt;
 # Avoid kernel memory address exposures via dmesg (this value can also be set by CONFIG_SECURITY_DMESG_RESTRICT).&lt;br /&gt;
 kernel.dmesg_restrict = 1&lt;br /&gt;
 &lt;br /&gt;
 # Block non-uid-0 profiling (needs [https://patchwork.kernel.org/patch/9249919/ distro patch], otherwise this is the same as &amp;quot;= 2&amp;quot;)&lt;br /&gt;
 kernel.perf_event_paranoid = 3&lt;br /&gt;
 &lt;br /&gt;
 # Turn off kexec, even if it's built in.&lt;br /&gt;
 kernel.kexec_load_disabled = 1&lt;br /&gt;
 &lt;br /&gt;
 # Avoid non-ancestor ptrace access to running processes and their credentials.&lt;br /&gt;
 kernel.yama.ptrace_scope = 1&lt;br /&gt;
 &lt;br /&gt;
 # Disable User Namespaces, as it opens up a large attack surface to unprivileged users.&lt;br /&gt;
 user.max_user_namespaces = 0&lt;br /&gt;
 &lt;br /&gt;
 # Turn off unprivileged eBPF access.&lt;br /&gt;
 kernel.unprivileged_bpf_disabled = 1&lt;br /&gt;
 &lt;br /&gt;
 # Turn on BPF JIT hardening, if the JIT is enabled.&lt;br /&gt;
 net.core.bpf_jit_harden = 2&lt;/div&gt;</summary>
		<author><name>Anthraxx</name></author>
	</entry>
</feed>