x86-64, compat: Test %rax for the syscall number, not %eax
On 64 bits, we always, by necessity, jump through the system call
table via %rax. For 32-bit system calls, in theory the system call
number is stored in %eax, and the code was testing %eax for a valid
system call number. At one point we loaded the stored value back from
the stack to enforce zero-extension, but that was removed in checkin
d4d6715016
. An actual 32-bit process
will not be able to introduce a non-zero-extended number, but it can
happen via ptrace.
Instead of re-introducing the zero-extension, test what we are
actually going to use, i.e. %rax. This only adds a handful of REX
prefixes to the code.
Reported-by: Ben Hawkes <hawkes@sota.gen.nz>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Cc: <stable@kernel.org>
Cc: Roland McGrath <roland@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
@@ -153,7 +153,7 @@ ENTRY(ia32_sysenter_target)
|
|||||||
testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r10)
|
testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r10)
|
||||||
CFI_REMEMBER_STATE
|
CFI_REMEMBER_STATE
|
||||||
jnz sysenter_tracesys
|
jnz sysenter_tracesys
|
||||||
cmpl $(IA32_NR_syscalls-1),%eax
|
cmpq $(IA32_NR_syscalls-1),%rax
|
||||||
ja ia32_badsys
|
ja ia32_badsys
|
||||||
sysenter_do_call:
|
sysenter_do_call:
|
||||||
IA32_ARG_FIXUP
|
IA32_ARG_FIXUP
|
||||||
@@ -195,7 +195,7 @@ sysexit_from_sys_call:
|
|||||||
movl $AUDIT_ARCH_I386,%edi /* 1st arg: audit arch */
|
movl $AUDIT_ARCH_I386,%edi /* 1st arg: audit arch */
|
||||||
call audit_syscall_entry
|
call audit_syscall_entry
|
||||||
movl RAX-ARGOFFSET(%rsp),%eax /* reload syscall number */
|
movl RAX-ARGOFFSET(%rsp),%eax /* reload syscall number */
|
||||||
cmpl $(IA32_NR_syscalls-1),%eax
|
cmpq $(IA32_NR_syscalls-1),%rax
|
||||||
ja ia32_badsys
|
ja ia32_badsys
|
||||||
movl %ebx,%edi /* reload 1st syscall arg */
|
movl %ebx,%edi /* reload 1st syscall arg */
|
||||||
movl RCX-ARGOFFSET(%rsp),%esi /* reload 2nd syscall arg */
|
movl RCX-ARGOFFSET(%rsp),%esi /* reload 2nd syscall arg */
|
||||||
@@ -248,7 +248,7 @@ sysenter_tracesys:
|
|||||||
call syscall_trace_enter
|
call syscall_trace_enter
|
||||||
LOAD_ARGS32 ARGOFFSET /* reload args from stack in case ptrace changed it */
|
LOAD_ARGS32 ARGOFFSET /* reload args from stack in case ptrace changed it */
|
||||||
RESTORE_REST
|
RESTORE_REST
|
||||||
cmpl $(IA32_NR_syscalls-1),%eax
|
cmpq $(IA32_NR_syscalls-1),%rax
|
||||||
ja int_ret_from_sys_call /* sysenter_tracesys has set RAX(%rsp) */
|
ja int_ret_from_sys_call /* sysenter_tracesys has set RAX(%rsp) */
|
||||||
jmp sysenter_do_call
|
jmp sysenter_do_call
|
||||||
CFI_ENDPROC
|
CFI_ENDPROC
|
||||||
@@ -314,7 +314,7 @@ ENTRY(ia32_cstar_target)
|
|||||||
testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r10)
|
testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r10)
|
||||||
CFI_REMEMBER_STATE
|
CFI_REMEMBER_STATE
|
||||||
jnz cstar_tracesys
|
jnz cstar_tracesys
|
||||||
cmpl $IA32_NR_syscalls-1,%eax
|
cmpq $IA32_NR_syscalls-1,%rax
|
||||||
ja ia32_badsys
|
ja ia32_badsys
|
||||||
cstar_do_call:
|
cstar_do_call:
|
||||||
IA32_ARG_FIXUP 1
|
IA32_ARG_FIXUP 1
|
||||||
@@ -367,7 +367,7 @@ cstar_tracesys:
|
|||||||
LOAD_ARGS32 ARGOFFSET, 1 /* reload args from stack in case ptrace changed it */
|
LOAD_ARGS32 ARGOFFSET, 1 /* reload args from stack in case ptrace changed it */
|
||||||
RESTORE_REST
|
RESTORE_REST
|
||||||
xchgl %ebp,%r9d
|
xchgl %ebp,%r9d
|
||||||
cmpl $(IA32_NR_syscalls-1),%eax
|
cmpq $(IA32_NR_syscalls-1),%rax
|
||||||
ja int_ret_from_sys_call /* cstar_tracesys has set RAX(%rsp) */
|
ja int_ret_from_sys_call /* cstar_tracesys has set RAX(%rsp) */
|
||||||
jmp cstar_do_call
|
jmp cstar_do_call
|
||||||
END(ia32_cstar_target)
|
END(ia32_cstar_target)
|
||||||
@@ -425,7 +425,7 @@ ENTRY(ia32_syscall)
|
|||||||
orl $TS_COMPAT,TI_status(%r10)
|
orl $TS_COMPAT,TI_status(%r10)
|
||||||
testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r10)
|
testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r10)
|
||||||
jnz ia32_tracesys
|
jnz ia32_tracesys
|
||||||
cmpl $(IA32_NR_syscalls-1),%eax
|
cmpq $(IA32_NR_syscalls-1),%rax
|
||||||
ja ia32_badsys
|
ja ia32_badsys
|
||||||
ia32_do_call:
|
ia32_do_call:
|
||||||
IA32_ARG_FIXUP
|
IA32_ARG_FIXUP
|
||||||
@@ -444,7 +444,7 @@ ia32_tracesys:
|
|||||||
call syscall_trace_enter
|
call syscall_trace_enter
|
||||||
LOAD_ARGS32 ARGOFFSET /* reload args from stack in case ptrace changed it */
|
LOAD_ARGS32 ARGOFFSET /* reload args from stack in case ptrace changed it */
|
||||||
RESTORE_REST
|
RESTORE_REST
|
||||||
cmpl $(IA32_NR_syscalls-1),%eax
|
cmpq $(IA32_NR_syscalls-1),%rax
|
||||||
ja int_ret_from_sys_call /* ia32_tracesys has set RAX(%rsp) */
|
ja int_ret_from_sys_call /* ia32_tracesys has set RAX(%rsp) */
|
||||||
jmp ia32_do_call
|
jmp ia32_do_call
|
||||||
END(ia32_syscall)
|
END(ia32_syscall)
|
||||||
|
Reference in New Issue
Block a user