[RFC PATCH 08/16] MIPS: compat: Don't use current_thread_info for stack base

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Once CONFIG_THREAD_INFO_IN_TASK is active, current_thread_info() will no
longer return the base of the stack. As such
arch_compat_alloc_user_space, which uses manual arithmetic based on it
to find the user PT_REGS at the top, will stop working. Replace the open
coded manipulation of the stack address to find the user stack pointer
from PT_REGS with user_stack_pointer(task_pt_regs(current)), which is
tidier anyway.

Signed-off-by: Matt Redfearn <matt.redfearn@xxxxxxxx>
---

 arch/mips/include/asm/compat.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/mips/include/asm/compat.h b/arch/mips/include/asm/compat.h
index 49691331ada4..17d74ea00455 100644
--- a/arch/mips/include/asm/compat.h
+++ b/arch/mips/include/asm/compat.h
@@ -6,6 +6,7 @@
  */
 #include <linux/thread_info.h>
 #include <linux/types.h>
+#include <linux/sched/task_stack.h>
 #include <asm/page.h>
 #include <asm/ptrace.h>
 
@@ -219,12 +220,11 @@ static inline compat_uptr_t ptr_to_compat(void __user *uptr)
 	return (u32)(unsigned long)uptr;
 }
 
+#define compat_user_stack_pointer() (user_stack_pointer(task_pt_regs(current)))
+
 static inline void __user *arch_compat_alloc_user_space(long len)
 {
-	struct pt_regs *regs = (struct pt_regs *)
-		((unsigned long) current_thread_info() + THREAD_SIZE - 32) - 1;
-
-	return (void __user *) (regs->regs[29] - len);
+	return (void __user *)compat_user_stack_pointer() - len;
 }
 
 struct compat_ipc64_perm {
-- 
2.7.4



[Index of Archives]     [Linux MIPS Home]     [LKML Archive]     [Linux ARM Kernel]     [Linux ARM]     [Linux]     [Git]     [Yosemite News]     [Linux SCSI]     [Linux Hams]

  Powered by Linux