mm/slab: Support selecting slab hardening features at boot
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v3 Latest6 patches 4 repliesIn review
- v26 patches 13 repliesSuperseded
- v18 patches 6 repliesSuperseded
Changes in v3 from the cover letter
- Rebase onto slab/for-next.
- Always build the slab_buckets and kmalloc_partition tests and skip them at runtime when the option isn't built in, instead of leaving them out with #ifdef (Kees).
- Declare slab_buckets_enabled and kmalloc_partition_enabled in mm/slab.h without any #if (Kees).
- Drop the remaining #ifdefs around slab_buckets= and kmalloc_partition=. Both are now always registered and ignored when the option isn't built in (Kees).
- Keep both flags as plain __ro_after_init bools rather than static keys, since they're only read when caches are created and not on the allocation path.
Patches in v3 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/6 | mm/slab: Enable SLAB_FREELIST_HARDENED by defaultmm/ | +1 | 0 replies | |
| 2/6 | mm/slab: Enable SLAB_FREELIST_RANDOM by defaultmm/ | +1 | 0 replies | |
| 3/6 | mm/slab: Support disabling SLAB_BUCKETS at bootDocumentation/ mm/ mm/ | +33 | 0 replies | |
| 4/6 | slub_kunit: Add a test for the slab_buckets boot parameterlib/ mm/ mm/ | +45 | 0 replies | |
| 5/6 | mm/slab: Support disabling KMALLOC_PARTITION_CACHES at bootDocumentation/ mm/ mm/ | +31 | 0 replies | |
| 6/6 | slub_kunit: Add a test for the kmalloc_partition boot parameterlib/ mm/ mm/ | +48 | 0 replies |
Reviews trailers per patch
2 of 6 patches have a Reviewed-by or Acked-by.
| Patch | Kees Cook |
|---|---|
| 1/6 | R-b |
| 2/6 | R-b |
| 3/6 | |
| 4/6 | |
| 5/6 | |
| 6/6 |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH v3 0/6] mm/slab: Support selecting slab hardening features at boot
Slab hardening settings are currently all build time choices. This means that, unfortunately, hosts with different requirements end up needing separate kernel images. At Meta, for example, some hosts are built with these options and the rest of the fleet isn't, and that's one of the things that keeps those kernels apart.
This series does two things:
- SLAB_FREELIST_HARDENED and SLAB_FREELIST_RANDOM are cheap enough with sheaves that it makes more sense to just enable them by default than to make them switchable. With both on, system level benchmarks didn't change measurably, only slowpath heavy microbenchmarks did [1].
- SLAB_BUCKETS and KMALLOC_PARTITION_CACHES cost memory (Harry measured about 1 MiB and 18 MiB respectively after boot on a 64 CPU VM [2]), so they get slab_buckets= and kmalloc_partition= boot parameters, which default to on when the option is built in.
Whether those two should be folded into a single slab_hardening= is still open [3].
v3:
- Rebase onto slab/for-next.
- Always build the slab_buckets and kmalloc_partition tests and skip them at runtime when the option isn't built in, instead of leaving them out with #ifdef (Kees).
- Declare slab_buckets_enabled and kmalloc_partition_enabled in mm/slab.h without any #if (Kees).
- Drop the remaining #ifdefs around slab_buckets= and kmalloc_partition=. Both are now always registered and ignored when the option isn't built in (Kees).
- Keep both flags as plain __ro_after_init bools rather than static keys, since they're only read when caches are created and not on the allocation path.
v2:
- Make SLAB_FREELIST_HARDENED and SLAB_FREELIST_RANDOM default y instead of adding boot parameters for them (Vlastimil).
- Skip the memdup_user() part of the slab_buckets test on !MMU (Sashiko).
- Keep slab_buckets= and kmalloc_partition= separate for now. We can discuss whether to merge them into slab_hardening= or similar, as Harry suggested.
v2: https://lore.kernel.org/r/[email protected]
v1: https://lore.kernel.org/r/[email protected]
[1] https://lore.kernel.org/r/[email protected]
[2] https://lore.kernel.org/r/[email protected]
[3] https://lore.kernel.org/r/aud4gPOUzvHtLYnJ@thinkstation
Chris Down (6):
mm/slab: Enable SLAB_FREELIST_HARDENED by default mm/slab: Enable SLAB_FREELIST_RANDOM by default mm/slab: Support disabling SLAB_BUCKETS at boot
slub_kunit: Add a test for the slab_buckets boot parameter mm/slab: Support disabling KMALLOC_PARTITION_CACHES at boot
slub_kunit: Add a test for the kmalloc_partition boot parameter
.../admin-guide/kernel-parameters.txt | 15 ++++ lib/tests/slub_kunit.c | 85 +++++++++++++++++++ mm/Kconfig | 11 +++ mm/slab.h | 3 + mm/slab_common.c | 52 ++++++++++-- 5 files changed, 157 insertions(+), 9 deletions(-)
base-commit: ce6518e61e3b4bf4f97f7ac6204049b9eba7eb75
Signature · 1 line
2.56.1