From: Andrey Konovalov <andreyknvl@google.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com>,
Alexander Potapenko <glider@google.com>,
Dmitry Vyukov <dvyukov@google.com>,
Marco Elver <elver@google.com>,
kasan-dev@googlegroups.com, linux-mm@kvack.org,
linux-kernel@vger.kernel.org,
Walter Wu <walter-zh.wu@mediatek.com>,
Elena Petrova <lenaptr@google.com>,
Vincenzo Frascino <vincenzo.frascino@arm.com>,
Catalin Marinas <catalin.marinas@arm.com>,
Andrey Konovalov <andreyknvl@google.com>
Subject: [PATCH 1/4] kasan: don't tag stacks allocated with pagealloc
Date: Fri, 31 Jul 2020 15:20:38 +0200 [thread overview]
Message-ID: <01c678b877755bcf29009176592402cdf6f2cb15.1596199677.git.andreyknvl@google.com> (raw)
In-Reply-To: <cover.1596199677.git.andreyknvl@google.com>
This patch prepares Software Tag-Based KASAN for stack tagging support.
With Tag-Based KASAN when kernel stacks are allocated via pagealloc
(which happens when CONFIG_VMAP_STACK is not enabled), they get tagged.
KASAN instrumentation doesn't expect the sp register to be tagged, and
this leads to false-positive reports.
Fix by resetting the tag of kernel stack pointers after allocation.
Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
---
kernel/fork.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/kernel/fork.c b/kernel/fork.c
index d03c9586d342..9cea2265e677 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -261,7 +261,7 @@ static unsigned long *alloc_thread_stack_node(struct task_struct *tsk, int node)
THREAD_SIZE_ORDER);
if (likely(page)) {
- tsk->stack = page_address(page);
+ tsk->stack = kasan_reset_tag(page_address(page));
return tsk->stack;
}
return NULL;
@@ -302,6 +302,7 @@ static unsigned long *alloc_thread_stack_node(struct task_struct *tsk,
{
unsigned long *stack;
stack = kmem_cache_alloc_node(thread_stack_cache, THREADINFO_GFP, node);
+ stack = kasan_reset_tag(stack);
tsk->stack = stack;
return stack;
}
--
2.28.0.163.g6104cc2f0b6-goog
next prev parent reply other threads:[~2020-07-31 13:20 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-31 13:20 [PATCH 0/4] kasan: support stack instrumentation for tag-based mode Andrey Konovalov
2020-07-31 13:20 ` Andrey Konovalov [this message]
2020-07-31 13:20 ` [PATCH 2/4] kasan, arm64: don't instrument functions that enable kasan Andrey Konovalov
2020-07-31 14:21 ` Catalin Marinas
2020-07-31 13:20 ` [PATCH 3/4] kasan: allow enabling stack tagging for tag-based mode Andrey Konovalov
2020-07-31 13:20 ` [PATCH 4/4] kasan: adjust kasan_stack_oob " Andrey Konovalov
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=01c678b877755bcf29009176592402cdf6f2cb15.1596199677.git.andreyknvl@google.com \
--to=andreyknvl@google.com \
--cc=akpm@linux-foundation.org \
--cc=aryabinin@virtuozzo.com \
--cc=catalin.marinas@arm.com \
--cc=dvyukov@google.com \
--cc=elver@google.com \
--cc=glider@google.com \
--cc=kasan-dev@googlegroups.com \
--cc=lenaptr@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=vincenzo.frascino@arm.com \
--cc=walter-zh.wu@mediatek.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox