Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions arch/lkl/include/asm/thread_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,23 @@
#include <asm/processor.h>
#include <asm/host_ops.h>

#define __HAVE_ARCH_OBJECT_IS_ON_STACK
static inline int arch_object_is_on_stack(const void *obj)
{
unsigned long addr = (unsigned long)obj;
unsigned long stack_size;
unsigned long stack;

if (!lkl_ops || !lkl_ops->thread_stack)
return 0;

stack = (unsigned long)lkl_ops->thread_stack(&stack_size);
if (!stack)
return 0;

return addr >= stack && addr - stack < stack_size;
}

struct thread_info {
struct task_struct *task;
unsigned long flags;
Expand Down
7 changes: 7 additions & 0 deletions include/linux/sched/task_stack.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,17 @@ void exit_task_stack_account(struct task_struct *tsk);

static inline int object_is_on_stack(const void *obj)
{
#ifndef __HAVE_ARCH_OBJECT_IS_ON_STACK
void *stack = task_stack_page(current);
#endif

obj = kasan_reset_tag(obj);

#ifdef __HAVE_ARCH_OBJECT_IS_ON_STACK
return arch_object_is_on_stack(obj);
#else
return (obj >= stack) && (obj < (stack + THREAD_SIZE));
#endif
}

extern void thread_stack_cache_init(void);
Expand Down
Loading