Contributors: 34
Author Tokens Token Proportion Commits Commit Proportion
Ingo Molnar 194 43.60% 7 13.21%
Chuck Ebbert 36 8.09% 1 1.89%
Andrew Lutomirski 33 7.42% 3 5.66%
FUJITA Tomonori 30 6.74% 1 1.89%
Linus Torvalds (pre-git) 24 5.39% 8 15.09%
Al Viro 14 3.15% 1 1.89%
Aaron Tomlin 13 2.92% 2 3.77%
Eric Sandeen 11 2.47% 1 1.89%
Qun-Wei Lin 10 2.25% 1 1.89%
Sebastian Andrzej Siewior 8 1.80% 2 3.77%
Thomas Gleixner 7 1.57% 1 1.89%
Ralf Baechle 6 1.35% 2 3.77%
Dhaval Giani 6 1.35% 1 1.89%
Paul Burton 6 1.35% 2 3.77%
Helge Deller 5 1.12% 1 1.89%
Jiri Slaby 5 1.12% 1 1.89%
Pavel Emelyanov 5 1.12% 1 1.89%
Benjamin Herrenschmidt 4 0.90% 1 1.89%
Pavel Tatashin 4 0.90% 1 1.89%
Roman Zippel 3 0.67% 1 1.89%
Kent Overstreet 3 0.67% 1 1.89%
Adrian Bunk 3 0.67% 1 1.89%
Srivatsa Vaddagiri 2 0.45% 1 1.89%
Anton Blanchard 2 0.45% 1 1.89%
David Disseldorp 2 0.45% 1 1.89%
Gregory Haskins 1 0.22% 1 1.89%
Greg Kroah-Hartman 1 0.22% 1 1.89%
Borislav Petkov 1 0.22% 1 1.89%
David Howells 1 0.22% 1 1.89%
Josh Poimboeuf 1 0.22% 1 1.89%
Sascha Hauer 1 0.22% 1 1.89%
Keith Owens 1 0.22% 1 1.89%
Linus Torvalds 1 0.22% 1 1.89%
Elena Reshetova 1 0.22% 1 1.89%
Total 445 53


/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _LINUX_SCHED_TASK_STACK_H
#define _LINUX_SCHED_TASK_STACK_H

/*
 * task->stack (kernel stack) handling interfaces:
 */

#include <linux/sched.h>
#include <linux/magic.h>
#include <linux/refcount.h>
#include <linux/kasan.h>

#ifdef CONFIG_THREAD_INFO_IN_TASK

/*
 * When accessing the stack of a non-current task that might exit, use
 * try_get_task_stack() instead.  task_stack_page will return a pointer
 * that could get freed out from under you.
 */
static __always_inline void *task_stack_page(const struct task_struct *task)
{
	return task->stack;
}

#define setup_thread_stack(new,old)	do { } while(0)

static __always_inline unsigned long *end_of_stack(const struct task_struct *task)
{
#ifdef CONFIG_STACK_GROWSUP
	return (unsigned long *)((unsigned long)task->stack + THREAD_SIZE) - 1;
#else
	return task->stack;
#endif
}

#else

#define task_stack_page(task)	((void *)(task)->stack)

static inline void setup_thread_stack(struct task_struct *p, struct task_struct *org)
{
	*task_thread_info(p) = *task_thread_info(org);
	task_thread_info(p)->task = p;
}

/*
 * Return the address of the last usable long on the stack.
 *
 * When the stack grows down, this is just above the thread
 * info struct. Going any lower will corrupt the threadinfo.
 *
 * When the stack grows up, this is the highest address.
 * Beyond that position, we corrupt data on the next page.
 */
static inline unsigned long *end_of_stack(struct task_struct *p)
{
#ifdef CONFIG_STACK_GROWSUP
	return (unsigned long *)((unsigned long)task_thread_info(p) + THREAD_SIZE) - 1;
#else
	return (unsigned long *)(task_thread_info(p) + 1);
#endif
}

#endif

#ifdef CONFIG_THREAD_INFO_IN_TASK
static inline void *try_get_task_stack(struct task_struct *tsk)
{
	return refcount_inc_not_zero(&tsk->stack_refcount) ?
		task_stack_page(tsk) : NULL;
}

extern void put_task_stack(struct task_struct *tsk);
#else
static inline void *try_get_task_stack(struct task_struct *tsk)
{
	return task_stack_page(tsk);
}

static inline void put_task_stack(struct task_struct *tsk) {}
#endif

void exit_task_stack_account(struct task_struct *tsk);

#define task_stack_end_corrupted(task) \
		(*(end_of_stack(task)) != STACK_END_MAGIC)

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

	obj = kasan_reset_tag(obj);
	return (obj >= stack) && (obj < (stack + THREAD_SIZE));
}

extern void thread_stack_cache_init(void);

#ifdef CONFIG_DEBUG_STACK_USAGE
unsigned long stack_not_used(struct task_struct *p);
#else
static inline unsigned long stack_not_used(struct task_struct *p)
{
	return 0;
}
#endif
extern void set_task_stack_end_magic(struct task_struct *tsk);

#ifndef __HAVE_ARCH_KSTACK_END
static inline int kstack_end(void *addr)
{
	/* Reliable end of stack detection:
	 * Some APM bios versions misalign the stack
	 */
	return !(((unsigned long)addr+sizeof(void*)-1) & (THREAD_SIZE-sizeof(void*)));
}
#endif

#endif /* _LINUX_SCHED_TASK_STACK_H */