From db70df8dd9cf100031cbc4fec1955ca558235ab4 Mon Sep 17 00:00:00 2001 From: Alexander Potapenko Date: Tue, 13 Apr 2021 16:22:45 +0200 Subject: [PATCH] arm64: configs: vendor: reduce KFENCE pool size CONFIG_KFENCE_NUM_OBJECTS controls the constant memory overhead that KFENCE introduces for its memory pool. By default it is 255 objects (2Mb extra memory), but since concerns have been raised that low-memory devices may not afford that, we are lowering the number of objects to 63 (512Kb extra memory). So far we haven't seen Android devices allocate more than 50 KFENCE objects. Should the kernel exhaust the pool, KFENCE will stop allocating new objects and fall back to SLAB/SLUB until one of the objects is freed. An immediate consequence of reducing the pool size is that a freed KFENCE object will be reused 4x times faster, effectively reducing the probability of detecting a use-after-free. Since KFENCE is a best-effort error detection tool, not a use-after-free mitigation mechanism, we believe this should not be problematic. Bug: 181822795 Test: run KFENCE on an Android device Signed-off-by: Alexander Potapenko Change-Id: I88fca80eea8b382115de03dbb104fd305b35476f --- arch/arm64/configs/vendor/bengal-perf_defconfig | 1 + arch/arm64/configs/vendor/kona-perf_defconfig | 1 + arch/arm64/configs/vendor/lito-perf_defconfig | 1 + 3 files changed, 3 insertions(+) diff --git a/arch/arm64/configs/vendor/bengal-perf_defconfig b/arch/arm64/configs/vendor/bengal-perf_defconfig index d3dc3d215e28..7d0b68d050b5 100644 --- a/arch/arm64/configs/vendor/bengal-perf_defconfig +++ b/arch/arm64/configs/vendor/bengal-perf_defconfig @@ -672,6 +672,7 @@ CONFIG_DEBUG_INFO=y CONFIG_MAGIC_SYSRQ=y CONFIG_KFENCE=y CONFIG_KFENCE_SAMPLE_INTERVAL=500 +CONFIG_KFENCE_NUM_OBJECTS=63 CONFIG_PANIC_TIMEOUT=5 CONFIG_SCHEDSTATS=y CONFIG_SCHED_STACK_END_CHECK=y diff --git a/arch/arm64/configs/vendor/kona-perf_defconfig b/arch/arm64/configs/vendor/kona-perf_defconfig index eb96cba41484..43ec9e36ca4b 100644 --- a/arch/arm64/configs/vendor/kona-perf_defconfig +++ b/arch/arm64/configs/vendor/kona-perf_defconfig @@ -717,6 +717,7 @@ CONFIG_DEBUG_INFO=y CONFIG_MAGIC_SYSRQ=y CONFIG_KFENCE=y CONFIG_KFENCE_SAMPLE_INTERVAL=500 +CONFIG_KFENCE_NUM_OBJECTS=63 CONFIG_PANIC_TIMEOUT=-1 CONFIG_SCHEDSTATS=y CONFIG_SCHED_STACK_END_CHECK=y diff --git a/arch/arm64/configs/vendor/lito-perf_defconfig b/arch/arm64/configs/vendor/lito-perf_defconfig index 92319efeaf04..678f9d36338f 100644 --- a/arch/arm64/configs/vendor/lito-perf_defconfig +++ b/arch/arm64/configs/vendor/lito-perf_defconfig @@ -687,6 +687,7 @@ CONFIG_DEBUG_INFO=y CONFIG_MAGIC_SYSRQ=y CONFIG_KFENCE=y CONFIG_KFENCE_SAMPLE_INTERVAL=500 +CONFIG_KFENCE_NUM_OBJECTS=63 CONFIG_PANIC_TIMEOUT=5 CONFIG_SCHEDSTATS=y CONFIG_SCHED_STACK_END_CHECK=y