Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

x86/asm/entry/32: Revert 'Do not use R9 in SYSCALL32' commit

This change reverts most of commit 53e9accf0f 'Do not use R9 in
SYSCALL32'. I don't yet understand how, but code in that commit
sometimes fails to preserve EBP.

See https://bugzilla.kernel.org/show_bug.cgi?id=101061
"Problems while executing 32-bit code on AMD64"

Reported-and-tested-by: Krzysztof A. Sobiecki <sobkas@gmail.com>
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Alexei Starovoitov <ast@plumgrid.com>
Cc: Will Drewry <wad@chromium.org>
Cc: Kees Cook <keescook@chromium.org>
CC: x86@kernel.org
Link: http://lkml.kernel.org/r/1437740203-11552-1-git-send-email-dvlasenk@redhat.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

authored by

Denys Vlasenko and committed by
Thomas Gleixner
c0c3322e 8a0a5da6

+9 -5
+9 -5
arch/x86/entry/entry_64_compat.S
··· 205 205 movl RDX(%rsp), %edx /* arg3 */ 206 206 movl RSI(%rsp), %ecx /* arg4 */ 207 207 movl RDI(%rsp), %r8d /* arg5 */ 208 - movl %ebp, %r9d /* arg6 */ 209 208 .endm 210 209 211 210 .macro auditsys_exit exit ··· 235 236 236 237 sysenter_auditsys: 237 238 auditsys_entry_common 239 + movl %ebp, %r9d /* reload 6th syscall arg */ 238 240 jmp sysenter_dispatch 239 241 240 242 sysexit_audit: ··· 336 336 * 32-bit zero extended: 337 337 */ 338 338 ASM_STAC 339 - 1: movl (%r8), %ebp 339 + 1: movl (%r8), %r9d 340 340 _ASM_EXTABLE(1b, ia32_badarg) 341 341 ASM_CLAC 342 342 orl $TS_COMPAT, ASM_THREAD_INFO(TI_status, %rsp, SIZEOF_PTREGS) ··· 346 346 cstar_do_call: 347 347 /* 32-bit syscall -> 64-bit C ABI argument conversion */ 348 348 movl %edi, %r8d /* arg5 */ 349 - movl %ebp, %r9d /* arg6 */ 349 + /* r9 already loaded */ /* arg6 */ 350 350 xchg %ecx, %esi /* rsi:arg2, rcx:arg4 */ 351 351 movl %ebx, %edi /* arg1 */ 352 352 movl %edx, %edx /* arg3 (zero extension) */ ··· 358 358 call *ia32_sys_call_table(, %rax, 8) 359 359 movq %rax, RAX(%rsp) 360 360 1: 361 - movl RCX(%rsp), %ebp 362 361 DISABLE_INTERRUPTS(CLBR_NONE) 363 362 TRACE_IRQS_OFF 364 363 testl $_TIF_ALLWORK_MASK, ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS) ··· 391 392 392 393 #ifdef CONFIG_AUDITSYSCALL 393 394 cstar_auditsys: 395 + movl %r9d, R9(%rsp) /* register to be clobbered by call */ 394 396 auditsys_entry_common 397 + movl R9(%rsp), %r9d /* reload 6th syscall arg */ 395 398 jmp cstar_dispatch 396 399 397 400 sysretl_audit: ··· 405 404 testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT), ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS) 406 405 jz cstar_auditsys 407 406 #endif 407 + xchgl %r9d, %ebp 408 408 SAVE_EXTRA_REGS 409 409 xorl %eax, %eax /* Do not leak kernel information */ 410 410 movq %rax, R11(%rsp) 411 411 movq %rax, R10(%rsp) 412 - movq %rax, R9(%rsp) 412 + movq %r9, R9(%rsp) 413 413 movq %rax, R8(%rsp) 414 414 movq %rsp, %rdi /* &pt_regs -> arg1 */ 415 415 call syscall_trace_enter 416 + movl R9(%rsp), %r9d 416 417 417 418 /* Reload arg registers from stack. (see sysenter_tracesys) */ 418 419 movl RCX(%rsp), %ecx ··· 424 421 movl %eax, %eax /* zero extension */ 425 422 426 423 RESTORE_EXTRA_REGS 424 + xchgl %ebp, %r9d 427 425 jmp cstar_do_call 428 426 END(entry_SYSCALL_compat) 429 427