[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200929133814.2834621-8-elver@google.com>
Date: Tue, 29 Sep 2020 15:38:10 +0200
From: Marco Elver <elver@...gle.com>
To: elver@...gle.com, akpm@...ux-foundation.org, glider@...gle.com
Cc: hpa@...or.com, paulmck@...nel.org, andreyknvl@...gle.com,
aryabinin@...tuozzo.com, luto@...nel.org, bp@...en8.de,
catalin.marinas@....com, cl@...ux.com, dave.hansen@...ux.intel.com,
rientjes@...gle.com, dvyukov@...gle.com, edumazet@...gle.com,
gregkh@...uxfoundation.org, hdanton@...a.com, mingo@...hat.com,
jannh@...gle.com, Jonathan.Cameron@...wei.com, corbet@....net,
iamjoonsoo.kim@....com, keescook@...omium.org,
mark.rutland@....com, penberg@...nel.org, peterz@...radead.org,
sjpark@...zon.com, tglx@...utronix.de, vbabka@...e.cz,
will@...nel.org, x86@...nel.org, linux-doc@...r.kernel.org,
linux-kernel@...r.kernel.org, kasan-dev@...glegroups.com,
linux-arm-kernel@...ts.infradead.org, linux-mm@...ck.org
Subject: [PATCH v4 07/11] kfence, kmemleak: make KFENCE compatible with KMEMLEAK
From: Alexander Potapenko <glider@...gle.com>
Add compatibility with KMEMLEAK, by making KMEMLEAK aware of the KFENCE
memory pool. This allows building debug kernels with both enabled, which
also helped in debugging KFENCE.
Reviewed-by: Dmitry Vyukov <dvyukov@...gle.com>
Co-developed-by: Marco Elver <elver@...gle.com>
Signed-off-by: Marco Elver <elver@...gle.com>
Signed-off-by: Alexander Potapenko <glider@...gle.com>
---
v2:
* Rework using delete_object_part() [suggested by Catalin Marinas].
---
mm/kmemleak.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/mm/kmemleak.c b/mm/kmemleak.c
index 5e252d91eb14..feff16068e8e 100644
--- a/mm/kmemleak.c
+++ b/mm/kmemleak.c
@@ -97,6 +97,7 @@
#include <linux/atomic.h>
#include <linux/kasan.h>
+#include <linux/kfence.h>
#include <linux/kmemleak.h>
#include <linux/memory_hotplug.h>
@@ -1948,6 +1949,11 @@ void __init kmemleak_init(void)
KMEMLEAK_GREY, GFP_ATOMIC);
create_object((unsigned long)__bss_start, __bss_stop - __bss_start,
KMEMLEAK_GREY, GFP_ATOMIC);
+#if defined(CONFIG_KFENCE) && defined(CONFIG_HAVE_ARCH_KFENCE_STATIC_POOL)
+ /* KFENCE objects are located in .bss, which may confuse kmemleak. Skip them. */
+ delete_object_part((unsigned long)__kfence_pool, KFENCE_POOL_SIZE);
+#endif
+
/* only register .data..ro_after_init if not within .data */
if (&__start_ro_after_init < &_sdata || &__end_ro_after_init > &_edata)
create_object((unsigned long)__start_ro_after_init,
--
2.28.0.709.gb0816b6eb0-goog
Powered by blists - more mailing lists