Kernel Electric-Fence: Linux 5.12 Merges KFence For Low-Overhead Memory Safety Feature
Linus Torvalds just merged a set of patches that includes KFence. Short for the Kernel Electric Fence, KFence is a low-overhead memory safety error detector/validator that is suitable for use in production kernel builds.
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.
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.
6 Comments