Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932742AbbFGIcs (ORCPT ); Sun, 7 Jun 2015 04:32:48 -0400 Received: from terminus.zytor.com ([198.137.202.10]:53015 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751663AbbFGIc2 (ORCPT ); Sun, 7 Jun 2015 04:32:28 -0400 Date: Sun, 7 Jun 2015 01:30:59 -0700 From: tip-bot for Denys Vlasenko Message-ID: Cc: luto@amacapital.net, hpa@zytor.com, peterz@infradead.org, linux-kernel@vger.kernel.org, bp@alien8.de, torvalds@linux-foundation.org, fweisbec@gmail.com, rostedt@goodmis.org, brgerst@gmail.com, ast@plumgrid.com, tglx@linutronix.de, mingo@kernel.org, keescook@chromium.org, wad@chromium.org, oleg@redhat.com, dvlasenk@redhat.com, akpm@linux-foundation.org Reply-To: torvalds@linux-foundation.org, fweisbec@gmail.com, rostedt@goodmis.org, bp@alien8.de, linux-kernel@vger.kernel.org, hpa@zytor.com, peterz@infradead.org, luto@amacapital.net, keescook@chromium.org, mingo@kernel.org, oleg@redhat.com, akpm@linux-foundation.org, dvlasenk@redhat.com, wad@chromium.org, tglx@linutronix.de, ast@plumgrid.com, brgerst@gmail.com In-Reply-To: <1433266510-2938-1-git-send-email-dvlasenk@redhat.com> References: <1433266510-2938-1-git-send-email-dvlasenk@redhat.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/asm] x86/asm/entry/32: Simplify the zeroing of pt_regs-> r8..r11 in the int80 code path Git-Commit-ID: 61b1e3e782d6784b714c0d80de529e0737d0e79c X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3373 Lines: 97 Commit-ID: 61b1e3e782d6784b714c0d80de529e0737d0e79c Gitweb: http://git.kernel.org/tip/61b1e3e782d6784b714c0d80de529e0737d0e79c Author: Denys Vlasenko AuthorDate: Tue, 2 Jun 2015 19:35:10 +0200 Committer: Ingo Molnar CommitDate: Fri, 5 Jun 2015 13:22:21 +0200 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 Cc: Alexei Starovoitov Cc: Andrew Morton Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Brian Gerst Cc: Frederic Weisbecker Cc: H. Peter Anvin Cc: Kees Cook Cc: Linus Torvalds Cc: Oleg Nesterov Cc: Peter Zijlstra Cc: Steven Rostedt Cc: Thomas Gleixner Cc: Will Drewry Link: http://lkml.kernel.org/r/1433266510-2938-1-git-send-email-dvlasenk@redhat.com Signed-off-by: Ingo Molnar --- arch/x86/entry/ia32entry.S | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/arch/x86/entry/ia32entry.S b/arch/x86/entry/ia32entry.S index f167674..f00a409 100644 --- a/arch/x86/entry/ia32entry.S +++ b/arch/x86/entry/ia32entry.S @@ -421,6 +421,10 @@ ia32_badarg: movq $-EFAULT,%rax jmp ia32_sysret +ia32_ret_from_sys_call: + CLEAR_RREGS + jmp int_ret_from_sys_call + /* * Emulated IA32 system calls via int 0x80. * @@ -462,8 +466,12 @@ ENTRY(ia32_syscall) pushq %rdx /* pt_regs->dx */ pushq %rcx /* pt_regs->cx */ pushq $-ENOSYS /* pt_regs->ax */ + pushq $0 /* pt_regs->r8 */ + pushq $0 /* pt_regs->r9 */ + pushq $0 /* pt_regs->r10 */ + pushq $0 /* pt_regs->r11 */ cld - sub $(10*8),%rsp /* pt_regs->r8-11,bp,bx,r12-15 not saved */ + sub $(6*8),%rsp /* pt_regs->bp,bx,r12-15 not saved */ orl $TS_COMPAT, ASM_THREAD_INFO(TI_status, %rsp, SIZEOF_PTREGS) testl $_TIF_WORK_SYSCALL_ENTRY, ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS) @@ -481,13 +489,10 @@ ia32_do_call: ia32_sysret: movq %rax,RAX(%rsp) 1: -ia32_ret_from_sys_call: - CLEAR_RREGS jmp int_ret_from_sys_call ia32_tracesys: SAVE_EXTRA_REGS - CLEAR_RREGS movq %rsp,%rdi /* &pt_regs -> arg1 */ call syscall_trace_enter LOAD_ARGS32 /* reload args from stack in case ptrace changed it */ -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/