]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
usercopy: Move enum for arch_within_stack_frames()
authorSahara <keun-o.park@darkmatter.ae>
Thu, 16 Feb 2017 18:29:15 +0000 (18:29 +0000)
committerKees Cook <keescook@chromium.org>
Tue, 4 Apr 2017 21:30:29 +0000 (14:30 -0700)
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>
arch/x86/include/asm/thread_info.h
include/linux/thread_info.h
mm/usercopy.c

index ad6f5eb07a95bd221fe4e13c8cdb3af0cd27aa37..920ca1f7adeacc022a00db78946cee8b25573299 100644 (file)
@@ -168,9 +168,9 @@ static inline unsigned long current_stack_pointer(void)
  * entirely contained by a single stack frame.
  *
  * Returns:
- *              1 if within a frame
- *             -1 if placed across a frame boundary (or outside stack)
- *              0 unable to determine (no frame pointers, etc)
+ *     GOOD_FRAME      if within a frame
+ *     BAD_STACK       if placed across a frame boundary (or outside stack)
+ *     NOT_STACK       unable to determine (no frame pointers, etc)
  */
 static inline int arch_within_stack_frames(const void * const stack,
                                           const void * const stackend,
@@ -197,13 +197,14 @@ static inline int arch_within_stack_frames(const void * const stack,
                 * the copy as invalid.
                 */
                if (obj + len <= frame)
-                       return obj >= oldframe + 2 * sizeof(void *) ? 1 : -1;
+                       return obj >= oldframe + 2 * sizeof(void *) ?
+                               GOOD_FRAME : BAD_STACK;
                oldframe = frame;
                frame = *(const void * const *)frame;
        }
-       return -1;
+       return BAD_STACK;
 #else
-       return 0;
+       return NOT_STACK;
 #endif
 }
 
index 58373875e8eec2aee668e5fdac4526796ebe78c8..0dbe41be6181bb2526f6be2caca89736692bc34a 100644 (file)
 #endif
 
 #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>
 
 #ifdef __KERNEL__
index d155e12563b139a9879bbc370902ea85a84bd0f3..1eba99baf1cf652eab70d85d592dc7e8e600944b 100644 (file)
 #include <linux/sched.h>
 #include <linux/sched/task.h>
 #include <linux/sched/task_stack.h>
+#include <linux/thread_info.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
  * stack frame (if possible).