To: | Ralf Baechle <ralf@linux-mips.org>, James Hogan <jhogan@kernel.org> |
---|---|
Subject: | [RFC PATCH 08/16] MIPS: compat: Don't use current_thread_info for stack base |
From: | Matt Redfearn <matt.redfearn@mips.com> |
Date: | Tue, 12 Dec 2017 09:57:54 +0000 |
Cc: | <linux-mips@linux-mips.org> |
In-reply-to: | <1513072682-1371-1-git-send-email-matt.redfearn@mips.com> |
List-archive: | <http://www.linux-mips.org/archives/linux-mips/> |
List-help: | <mailto:ecartis@linux-mips.org?Subject=help> |
List-id: | linux-mips <linux-mips.eddie.linux-mips.org> |
List-owner: | <mailto:ralf@linux-mips.org> |
List-post: | <mailto:linux-mips@linux-mips.org> |
List-software: | Ecartis version 1.0.0 |
List-subscribe: | <mailto:ecartis@linux-mips.org?subject=subscribe%20linux-mips> |
List-unsubscribe: | <mailto:ecartis@linux-mips.org?subject=unsubscribe%20linux-mips> |
Original-recipient: | rfc822;linux-mips@linux-mips.org |
References: | <1513072682-1371-1-git-send-email-matt.redfearn@mips.com> |
Sender: | linux-mips-bounce@linux-mips.org |
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@mips.com> --- 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 |
Previous by Date: | [RFC PATCH 09/16] MIPS: Introduce setup_kernel_mode macro, Matt Redfearn |
---|---|
Next by Date: | [RFC PATCH 10/16] MIPS: Move the CONFIG_CPU_JUMP_WORKAROUNDS into setup_kernel_mode, Matt Redfearn |
Previous by Thread: | [RFC PATCH 09/16] MIPS: Introduce setup_kernel_mode macro, Matt Redfearn |
Next by Thread: | [RFC PATCH 10/16] MIPS: Move the CONFIG_CPU_JUMP_WORKAROUNDS into setup_kernel_mode, Matt Redfearn |
Indexes: | [Date] [Thread] [Top] [All Lists] |