x86/compat: 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 is about to be removed. Suggested-by: Andy Lutomirski <luto@kernel.org> Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Link: https://lore.kernel.org/r/20201004032536.1229030-3-krisman@collabora.com
This commit is contained in:
parent
375d4bfda5
commit
214f0e8043
|
@ -177,14 +177,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;
|
||||
compat_uptr_t sp = task_pt_regs(current)->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;
|
||||
}
|
||||
/*
|
||||
* -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue