usercopy: Move enum for arch_within_stack_frames()
This patch moves the arch_within_stack_frames() return value enum up in the header files so that per-architecture implementations can reuse the same return values. Signed-off-by: Sahara <keun-o.park@darkmatter.ae> Signed-off-by: James Morse <james.morse@arm.com> [kees: adjusted naming and commit log] Signed-off-by: Kees Cook <keescook@chromium.org>
This commit is contained in:
parent
4495c08e84
commit
96dc4f9fb6
@ -168,9 +168,9 @@ static inline unsigned long current_stack_pointer(void)
|
|||||||
* entirely contained by a single stack frame.
|
* entirely contained by a single stack frame.
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
* 1 if within a frame
|
* GOOD_FRAME if within a frame
|
||||||
* -1 if placed across a frame boundary (or outside stack)
|
* BAD_STACK if placed across a frame boundary (or outside stack)
|
||||||
* 0 unable to determine (no frame pointers, etc)
|
* NOT_STACK unable to determine (no frame pointers, etc)
|
||||||
*/
|
*/
|
||||||
static inline int arch_within_stack_frames(const void * const stack,
|
static inline int arch_within_stack_frames(const void * const stack,
|
||||||
const void * const stackend,
|
const void * const stackend,
|
||||||
@ -197,13 +197,14 @@ static inline int arch_within_stack_frames(const void * const stack,
|
|||||||
* the copy as invalid.
|
* the copy as invalid.
|
||||||
*/
|
*/
|
||||||
if (obj + len <= frame)
|
if (obj + len <= frame)
|
||||||
return obj >= oldframe + 2 * sizeof(void *) ? 1 : -1;
|
return obj >= oldframe + 2 * sizeof(void *) ?
|
||||||
|
GOOD_FRAME : BAD_STACK;
|
||||||
oldframe = frame;
|
oldframe = frame;
|
||||||
frame = *(const void * const *)frame;
|
frame = *(const void * const *)frame;
|
||||||
}
|
}
|
||||||
return -1;
|
return BAD_STACK;
|
||||||
#else
|
#else
|
||||||
return 0;
|
return NOT_STACK;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,6 +22,18 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <linux/bitops.h>
|
#include <linux/bitops.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* For per-arch arch_within_stack_frames() implementations, defined in
|
||||||
|
* asm/thread_info.h.
|
||||||
|
*/
|
||||||
|
enum {
|
||||||
|
BAD_STACK = -1,
|
||||||
|
NOT_STACK = 0,
|
||||||
|
GOOD_FRAME,
|
||||||
|
GOOD_STACK,
|
||||||
|
};
|
||||||
|
|
||||||
#include <asm/thread_info.h>
|
#include <asm/thread_info.h>
|
||||||
|
|
||||||
#ifdef __KERNEL__
|
#ifdef __KERNEL__
|
||||||
|
@ -19,15 +19,9 @@
|
|||||||
#include <linux/sched.h>
|
#include <linux/sched.h>
|
||||||
#include <linux/sched/task.h>
|
#include <linux/sched/task.h>
|
||||||
#include <linux/sched/task_stack.h>
|
#include <linux/sched/task_stack.h>
|
||||||
|
#include <linux/thread_info.h>
|
||||||
#include <asm/sections.h>
|
#include <asm/sections.h>
|
||||||
|
|
||||||
enum {
|
|
||||||
BAD_STACK = -1,
|
|
||||||
NOT_STACK = 0,
|
|
||||||
GOOD_FRAME,
|
|
||||||
GOOD_STACK,
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Checks if a given pointer and length is contained by the current
|
* Checks if a given pointer and length is contained by the current
|
||||||
* stack frame (if possible).
|
* stack frame (if possible).
|
||||||
|
Loading…
Reference in New Issue
Block a user