v2 2026-10-29

slab 加固特性启动可选 · v2

默认启用SLAB freelist加固与随机化,并为buckets和kmalloc分区加启动开关。

原始补丁链接

子 Patch(6)

1/6
mm/slab: Enable SLAB_FREELIST_HARDENED by default
默认开启 SLAB_FREELIST_HARDENED,混淆空闲对象指针以检测简单 double free/错 cache free;因 sheaves 快路径不碰 freelist 且发行版已启用,成本低,并联动默认开 SLAB_BUCKETS。
2/6
mm/slab: Enable SLAB_FREELIST_RANDOM by default
默认开启 SLAB_FREELIST_RANDOM,随机化新 slab 对象发放顺序,增加利用难度;成本只在新 slab 建立时,基准无明显变化,并使 SHUFFLE_PAGE_ALLOCATOR 默认满足依赖但仍需参数启用。
3/6
mm/slab: Support disabling SLAB_BUCKETS at boot
新增 slab_buckets= 早期参数,在 CONFIG_SLAB_BUCKETS=y 时可启动时关闭专用 kmalloc bucket cache,避免只想用通用 kmalloc cache 的主机需单独编译内核,并节省 bucket cache 内存。
4/6
slub_kunit: Add a test for the slab_buckets boot parameter
在 slub_kunit 增加测试:默认 memdup_user() 应分配到 memdup_user bucket,slab_buckets=0 时应回落到普通 kmalloc cache;为此增加内部查询辅助。
5/6
mm/slab: Support disabling KMALLOC_PARTITION_CACHES at boot
KMALLOC_PARTITION_CACHES creates several copies of each normal kmalloc cache and spreads allocations across them. That costs a fair bit of memory: Harry measured about 18 MiB more slab memory after bo
6/6
slub_kunit: Add a test for the kmalloc_partition boot parameter
Check that the kmalloc partitions are separate caches by default, and alias the normal kmalloc caches when they’re turned off with kmalloc_partition=0. Signed-off-by: Chris Down <chris@chrisdown.name