LKML Archive mirror
 help / color / mirror / Atom feed
* [PATCH] kfence: unpoison pool region before use
@ 2021-04-03  5:13 Peter Collingbourne
  2021-04-03 10:03 ` Marco Elver
  2021-04-03 14:05 ` Andrey Konovalov
  0 siblings, 2 replies; 9+ messages in thread
From: Peter Collingbourne @ 2021-04-03  5:13 UTC (permalink / raw)
  To: Marco Elver, Dmitry Vyukov, Alexander Potapenko
  Cc: Peter Collingbourne, Evgenii Stepanov, Andrey Konovalov, linux-mm,
	linux-kernel

If the memory region allocated by KFENCE had previously been poisoned,
any validity checks done using kasan_byte_accessible() will fail. Fix
it by unpoisoning the memory before using it as the pool region.

Link: https://linux-review.googlesource.com/id/I0af99e9f1c25eaf7e1ec295836b5d148d76940c5
Signed-off-by: Peter Collingbourne <pcc@google.com>
---
 mm/kfence/core.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/mm/kfence/core.c b/mm/kfence/core.c
index d53c91f881a4..bb22b0cf77aa 100644
--- a/mm/kfence/core.c
+++ b/mm/kfence/core.c
@@ -633,13 +633,19 @@ static DECLARE_DELAYED_WORK(kfence_timer, toggle_allocation_gate);
 
 void __init kfence_alloc_pool(void)
 {
+	void *pool;
+
 	if (!kfence_sample_interval)
 		return;
 
-	__kfence_pool = memblock_alloc(KFENCE_POOL_SIZE, PAGE_SIZE);
-
-	if (!__kfence_pool)
+	pool = memblock_alloc(KFENCE_POOL_SIZE, PAGE_SIZE);
+	if (!pool) {
 		pr_err("failed to allocate pool\n");
+		return;
+	}
+
+	kasan_unpoison_range(pool, KFENCE_POOL_SIZE);
+	__kfence_pool = pool;
 }
 
 void __init kfence_init(void)
-- 
2.31.0.208.g409f899ff0-goog


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2021-04-05 19:04 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-03  5:13 [PATCH] kfence: unpoison pool region before use Peter Collingbourne
2021-04-03 10:03 ` Marco Elver
2021-04-03 20:40   ` Peter Collingbourne
2021-04-03 22:30     ` Marco Elver
2021-04-03 23:52       ` Andrey Konovalov
2021-04-04 12:09         ` Andrey Konovalov
2021-04-05 19:04         ` Peter Collingbourne
2021-04-03 14:05 ` Andrey Konovalov
2021-04-03 14:45   ` Marco Elver

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).