From: Seung-Woo Kim Date: Mon, 25 Jan 2021 06:44:20 +0000 (+0900) Subject: kmemleak: Fix bad memory access with scan stack for amlogic vmap X-Git-Tag: submit/tizen/20210204.012538~15 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F72%2F252172%2F1;p=platform%2Fkernel%2Flinux-amlogic.git kmemleak: Fix bad memory access with scan stack for amlogic vmap When AMLOGIC_VMAP is enabled, try_get_task_stack() returns address of stasck instead of page address. This causes bad memory access during kmemleak scan stack. Fix the bad memory access by using aml_task_stack(). Note: Maybe, get_task_stack() needs to call aml_task_stack() is required, but aml_task_stack() has no consideration for kmalloced task stack, so just fix from kmemleak. Change-Id: I58a2e324cb92cd692d2260c675e81d7d0715e96c Fixes: commit 4d6ae4359385 ("mm: optimize thread stack usage on arm64 [1/1]") Signed-off-by: Seung-Woo Kim --- diff --git a/mm/kmemleak.c b/mm/kmemleak.c index d05133b37b17..7eeb84a73c94 100644 --- a/mm/kmemleak.c +++ b/mm/kmemleak.c @@ -112,6 +112,10 @@ #include #include +#ifdef CONFIG_AMLOGIC_VMAP +#include +#endif + /* * Kmemleak configuration and common defines. */ @@ -1456,11 +1460,17 @@ static void kmemleak_scan(void) read_lock(&tasklist_lock); do_each_thread(g, p) { +#ifdef CONFIG_AMLOGIC_VMAP + void *stack = aml_task_stack(p); + if (stack) + scan_block(stack, stack + THREAD_SIZE, NULL); +#else void *stack = try_get_task_stack(p); if (stack) { scan_block(stack, stack + THREAD_SIZE, NULL); put_task_stack(p); } +#endif } while_each_thread(g, p); read_unlock(&tasklist_lock); }