Skip to content

Commit 61b1e3e

Browse files
dvlasenkIngo Molnar
authored andcommitted
x86/asm/entry/32: Simplify the zeroing of pt_regs->r8..r11 in the int80 code path
32-bit syscall entry points do not save the complete pt_regs struct, they leave some fields uninitialized. However, they must be careful to not leak uninitialized data in pt_regs->r8..r11 to ptrace users. CLEAR_RREGS macro is used to zero these fields out when needed. However, in the int80 code path this zeroing is unconditional. This patch simplifies it by storing zeroes there right away, when pt_regs is constructed on stack. This uses shorter instructions: text data bss dec hex filename 1423 0 0 1423 58f ia32entry.o.before 1407 0 0 1407 57f ia32entry.o Compile-tested. Signed-off-by: Denys Vlasenko <[email protected]> Cc: Alexei Starovoitov <[email protected]> Cc: Andrew Morton <[email protected]> Cc: Andy Lutomirski <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Brian Gerst <[email protected]> Cc: Frederic Weisbecker <[email protected]> Cc: H. Peter Anvin <[email protected]> Cc: Kees Cook <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Oleg Nesterov <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Steven Rostedt <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Will Drewry <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent 5ca6f70 commit 61b1e3e

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

arch/x86/entry/ia32entry.S

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,10 @@ ia32_badarg:
421421
movq $-EFAULT,%rax
422422
jmp ia32_sysret
423423

424+
ia32_ret_from_sys_call:
425+
CLEAR_RREGS
426+
jmp int_ret_from_sys_call
427+
424428
/*
425429
* Emulated IA32 system calls via int 0x80.
426430
*
@@ -462,8 +466,12 @@ ENTRY(ia32_syscall)
462466
pushq %rdx /* pt_regs->dx */
463467
pushq %rcx /* pt_regs->cx */
464468
pushq $-ENOSYS /* pt_regs->ax */
469+
pushq $0 /* pt_regs->r8 */
470+
pushq $0 /* pt_regs->r9 */
471+
pushq $0 /* pt_regs->r10 */
472+
pushq $0 /* pt_regs->r11 */
465473
cld
466-
sub $(10*8),%rsp /* pt_regs->r8-11,bp,bx,r12-15 not saved */
474+
sub $(6*8),%rsp /* pt_regs->bp,bx,r12-15 not saved */
467475

468476
orl $TS_COMPAT, ASM_THREAD_INFO(TI_status, %rsp, SIZEOF_PTREGS)
469477
testl $_TIF_WORK_SYSCALL_ENTRY, ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
@@ -481,13 +489,10 @@ ia32_do_call:
481489
ia32_sysret:
482490
movq %rax,RAX(%rsp)
483491
1:
484-
ia32_ret_from_sys_call:
485-
CLEAR_RREGS
486492
jmp int_ret_from_sys_call
487493

488494
ia32_tracesys:
489495
SAVE_EXTRA_REGS
490-
CLEAR_RREGS
491496
movq %rsp,%rdi /* &pt_regs -> arg1 */
492497
call syscall_trace_enter
493498
LOAD_ARGS32 /* reload args from stack in case ptrace changed it */

0 commit comments

Comments
 (0)