[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200912070553.330622-3-krisman@collabora.com>
Date: Sat, 12 Sep 2020 03:05:49 -0400
From: Gabriel Krisman Bertazi <krisman@...labora.com>
To: luto@...nel.org, tglx@...utronix.de
Cc: hpa@...or.com, bp@...en8.de, rric@...nel.org, peterz@...radead.org,
mingo@...hat.com, x86@...nel.org, linux-kernel@...r.kernel.org,
Gabriel Krisman Bertazi <krisman@...labora.com>,
kernel@...labora.com, Christoph Hellwig <hch@....de>
Subject: [PATCH 2/6] x86: Simplify compat syscall userspace allocation
When allocating user memory space for a compat system call, don't
consider whether the originating code is IA32 or X32, just allocate from
a safe region for both, beyond the redzone. This should be safe for
IA32, and has the benefit of avoiding TIF_IA32, which we want to drop.
Suggested-by: Andy Lutomirski <luto@...nel.org>
Cc: Christoph Hellwig <hch@....de>
Signed-off-by: Gabriel Krisman Bertazi <krisman@...labora.com>
---
arch/x86/include/asm/compat.h | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/arch/x86/include/asm/compat.h b/arch/x86/include/asm/compat.h
index d4edf281fff4..a4b5126dff4e 100644
--- a/arch/x86/include/asm/compat.h
+++ b/arch/x86/include/asm/compat.h
@@ -179,14 +179,13 @@ typedef struct user_regs_struct compat_elf_gregset_t;
static inline void __user *arch_compat_alloc_user_space(long len)
{
- compat_uptr_t sp;
-
- if (test_thread_flag(TIF_IA32)) {
- sp = task_pt_regs(current)->sp;
- } else {
- /* -128 for the x32 ABI redzone */
- sp = task_pt_regs(current)->sp - 128;
- }
+ compat_uptr_t sp = task_pt_regs(current)->sp;
+
+ /*
+ * -128 for the x32 ABI redzone. For IA32, it is not strictly
+ * necessary, but not harmful.
+ */
+ sp -= 128;
return (void __user *)round_down(sp - len, 16);
}
--
2.28.0
Powered by blists - more mailing lists