From: Peter Collingbourne <pcc@google.com>
To: Marco Elver <elver@google.com>,
Dmitry Vyukov <dvyukov@google.com>,
Alexander Potapenko <glider@google.com>
Cc: Peter Collingbourne <pcc@google.com>,
Evgenii Stepanov <eugenis@google.com>,
Andrey Konovalov <andreyknvl@gmail.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: [PATCH] kfence: unpoison pool region before use
Date: Fri, 2 Apr 2021 22:13:25 -0700 [thread overview]
Message-ID: <20210403051325.683071-1-pcc@google.com> (raw)
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
next reply other threads:[~2021-04-03 5:13 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-03 5:13 Peter Collingbourne [this message]
2021-04-03 10:03 ` [PATCH] kfence: unpoison pool region before use 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210403051325.683071-1-pcc@google.com \
--to=pcc@google.com \
--cc=andreyknvl@gmail.com \
--cc=dvyukov@google.com \
--cc=elver@google.com \
--cc=eugenis@google.com \
--cc=glider@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.