Skip to content

Commit 67a454e

Browse files
committed
Merge tag 'memblock-6.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rppt/memblock
Pull memblock update from Mike Rapoport: "Introduce a 'check_pages' boot parameter to decouple simple checks for page state on allocation and free from CONFIG_DEBUG_VM. This allows enabling page checking without building kernel with CONFIG_DEBUG_VM or forcing init_on_{alloc, free} or other heavier mechanisms" * tag 'memblock-6.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rppt/memblock: mm/mm_init: Introduce a boot parameter for check_pages
2 parents bbbf7f3 + 83c8f7b commit 67a454e

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -767,6 +767,14 @@ Kernel parameters
767767
nokmem -- Disable kernel memory accounting.
768768
nobpf -- Disable BPF memory accounting.
769769

770+
check_pages= [MM,EARLY] Enable sanity checking of pages after
771+
allocations / before freeing. This adds checks to catch
772+
double-frees, use-after-frees, and other sources of
773+
page corruption by inspecting page internals (flags,
774+
mapcount/refcount, memcg_data, etc.).
775+
Format: { "0" | "1" }
776+
Default: 0 (1 if CONFIG_DEBUG_VM is set)
777+
770778
checkreqprot= [SELINUX] Set initial checkreqprot flag value.
771779
Format: { "0" | "1" }
772780
See security/selinux/Kconfig help text.

mm/mm_init.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2525,6 +2525,14 @@ early_param("init_on_free", early_init_on_free);
25252525

25262526
DEFINE_STATIC_KEY_MAYBE(CONFIG_DEBUG_VM, check_pages_enabled);
25272527

2528+
static bool check_pages_enabled_early __initdata;
2529+
2530+
static int __init early_check_pages(char *buf)
2531+
{
2532+
return kstrtobool(buf, &check_pages_enabled_early);
2533+
}
2534+
early_param("check_pages", early_check_pages);
2535+
25282536
/*
25292537
* Enable static keys related to various memory debugging and hardening options.
25302538
* Some override others, and depend on early params that are evaluated in the
@@ -2534,7 +2542,7 @@ DEFINE_STATIC_KEY_MAYBE(CONFIG_DEBUG_VM, check_pages_enabled);
25342542
static void __init mem_debugging_and_hardening_init(void)
25352543
{
25362544
bool page_poisoning_requested = false;
2537-
bool want_check_pages = false;
2545+
bool want_check_pages = check_pages_enabled_early;
25382546

25392547
#ifdef CONFIG_PAGE_POISONING
25402548
/*

0 commit comments

Comments
 (0)