Commit 9b064fc3f95a8e44e929fdf4d6037334ea03d15b
1 parent
5c49574ffd
Exists in
smarc-l5.0.0_1.0.0-ga
and in
5 other branches
new helper: compat_user_stack_pointer()
Compat counterpart of current_user_stack_pointer(); for most of the biarch architectures those two are identical, but e.g. arm64 and arm use different registers for stack pointer... Note that amd64 variants of current_user_stack_pointer/compat_user_stack_pointer do *not* rely on pt_regs having been through FIXUP_TOP_OF_STACK. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Showing 3 changed files with 13 additions and 2 deletions Side-by-side Diff
arch/arm64/include/asm/compat.h
... | ... | @@ -209,10 +209,11 @@ |
209 | 209 | return (u32)(unsigned long)uptr; |
210 | 210 | } |
211 | 211 | |
212 | +#define compat_user_stack_pointer() (current_pt_regs()->compat_sp) | |
213 | + | |
212 | 214 | static inline void __user *arch_compat_alloc_user_space(long len) |
213 | 215 | { |
214 | - struct pt_regs *regs = task_pt_regs(current); | |
215 | - return (void __user *)regs->compat_sp - len; | |
216 | + return (void __user *)compat_user_stack_pointer() - len; | |
216 | 217 | } |
217 | 218 | |
218 | 219 | struct compat_ipc64_perm { |
arch/x86/include/asm/ptrace.h
... | ... | @@ -203,6 +203,13 @@ |
203 | 203 | return regs->cs == __USER_CS || regs->cs == pv_info.extra_user_64bit_cs; |
204 | 204 | #endif |
205 | 205 | } |
206 | + | |
207 | +#define current_user_stack_pointer() this_cpu_read(old_rsp) | |
208 | +/* ia32 vs. x32 difference */ | |
209 | +#define compat_user_stack_pointer() \ | |
210 | + (test_thread_flag(TIF_IA32) \ | |
211 | + ? current_pt_regs()->sp \ | |
212 | + : this_cpu_read(old_rsp)) | |
206 | 213 | #endif |
207 | 214 | |
208 | 215 | #ifdef CONFIG_X86_32 |
include/linux/compat.h
... | ... | @@ -65,6 +65,9 @@ |
65 | 65 | |
66 | 66 | #endif /* CONFIG_HAVE_SYSCALL_WRAPPERS */ |
67 | 67 | |
68 | +#ifndef compat_user_stack_pointer | |
69 | +#define compat_user_stack_pointer() current_user_stack_pointer() | |
70 | +#endif | |
68 | 71 | #define compat_jiffies_to_clock_t(x) \ |
69 | 72 | (((unsigned long)(x) * COMPAT_USER_HZ) / HZ) |
70 | 73 |