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 <sw0312.kim@samsung.com>
#include <linux/kmemleak.h>
#include <linux/memory_hotplug.h>
+#ifdef CONFIG_AMLOGIC_VMAP
+#include <linux/amlogic/vmap_stack.h>
+#endif
+
/*
* Kmemleak configuration and common defines.
*/
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);
}