Show Your Support: Have you heard of Phoronix Premium? It's what complements advertisements on this site for our premium ad-free service. For less than $4 USD per month, you can help support our site while the funds generated allow us to keep doing Linux hardware reviews, performance benchmarking, maintain our community forums, and much more.
Kernel Electric-Fence: Linux 5.12 Merges KFence For Low-Overhead Memory Safety Feature
While there has long been KASAN as the Kernel Address Sanitizer for a dynamic memory error detector for discovering use-after-free and out-of-bounds bugs within the Linux kernel, KFence aims to provide a lower-overhead solution.
The Kernel Electric-Fence is a sampling-based memory safety error detector for uncovering similar out-of-bounds / use-after-free / invalid-free errors but because it's lower overhead can be used for production kernel builds with "near zero performance overhead". The hope is that KFence can uncover bugs not previously found by KASAN due to the difference focus of production vs. testing/non-production workloads.
KFence can be configured with the new CONFIG_KFENCE Kconfig switch. At boot-time, the kfence.sample_interval parameter can be used for controlling the sampling interval or a value of 0 to disable the functionality. Discovered bugs are reported to the kernel log. There is also a DebugFS interface for run-time statistics.
The Kernel Electric-Fence is backed by Google engineers and so far -- like KASAN -- is focused on x86_64 and ARM64 support. KFence has been under review the past number of months while today was merged as part of the latest AKPM patches.