[PATCH] lib/stackdeopt: use original shadow
From: Joonsoo Kim
Date: Wed May 17 2017 - 02:34:43 EST
Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@xxxxxxx>
---
lib/stackdepot.c | 7 ++++++-
mm/kasan/kasan.c | 12 ++++++++++++
2 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/lib/stackdepot.c b/lib/stackdepot.c
index f87d138..cc98ce2 100644
--- a/lib/stackdepot.c
+++ b/lib/stackdepot.c
@@ -80,6 +80,8 @@ static int next_slab_inited;
static size_t depot_offset;
static DEFINE_SPINLOCK(depot_lock);
+extern void kasan_map_shadow_private(const void *addr, size_t size, gfp_t flags);
+
static bool init_stack_slab(void **prealloc)
{
if (!*prealloc)
@@ -245,8 +247,11 @@ depot_stack_handle_t depot_save_stack(struct stack_trace *trace,
alloc_flags &= (GFP_ATOMIC | GFP_KERNEL);
alloc_flags |= __GFP_NOWARN;
page = alloc_pages(alloc_flags, STACK_ALLOC_ORDER);
- if (page)
+ if (page) {
prealloc = page_address(page);
+ kasan_map_shadow_private(prealloc,
+ PAGE_SIZE << STACK_ALLOC_ORDER, alloc_flags);
+ }
}
spin_lock_irqsave(&depot_lock, flags);
diff --git a/mm/kasan/kasan.c b/mm/kasan/kasan.c
index fd6b7d4..3c18d18 100644
--- a/mm/kasan/kasan.c
+++ b/mm/kasan/kasan.c
@@ -247,6 +247,18 @@ static int kasan_map_shadow(const void *addr, size_t size, gfp_t flags)
return err;
}
+void kasan_map_shadow_private(const void *addr, size_t size, gfp_t flags)
+{
+ int err;
+
+ err = kasan_map_shadow(addr, size, flags);
+ if (err)
+ return;
+
+ kasan_unpoison_shadow(addr, size);
+ kasan_poison_pshadow(addr, size);
+}
+
static int kasan_unmap_shadow_pte(pte_t *ptep, pgtable_t token,
unsigned long addr, void *data)
{
--
2.7.4