Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965056AbbDJQIy (ORCPT ); Fri, 10 Apr 2015 12:08:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38086 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934058AbbDJQIx (ORCPT ); Fri, 10 Apr 2015 12:08:53 -0400 Message-ID: <5527F576.8030709@redhat.com> Date: Fri, 10 Apr 2015 18:08:22 +0200 From: Denys Vlasenko User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 To: Andy Lutomirski CC: Ingo Molnar , Linus Torvalds , Steven Rostedt , Borislav Petkov , "H. Peter Anvin" , Oleg Nesterov , Frederic Weisbecker , Alexei Starovoitov , Will Drewry , Kees Cook , X86 ML , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH] x86/asm/entry/32: Update ENOSYS handling to match 64-bit logic References: <1428679988-9592-1-git-send-email-dvlasenk@redhat.com> <1428679988-9592-2-git-send-email-dvlasenk@redhat.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1938 Lines: 44 On 04/10/2015 05:44 PM, Andy Lutomirski wrote: > On Fri, Apr 10, 2015 at 8:33 AM, Denys Vlasenko wrote: >> Sometime ago Andy changed 64-bit syscall logic so that pt_regs->ax is >> initially set to -ENOSYS, and on exit from syscall, it is updated with >> actual return value. This simplified logic there. >> >> This patch does the same for 32-bit syscall entry points. >> >> The check for %rax being too big is moved to be just before >> the call insn which dispatches execution through syscall table. >> There is no way to accidentally skip this check now by jumping >> to a label after it. This allows to remove redundant checks >> after e.g. ptrace. >> >> If %rax is too big, we just skip over the (call, write %rax to pt_regs->ax) >> insn pair. pt_regs->ax remains set to -ENOSYS, and it gets returned >> to userspace. > > This looks okay, but I'll read it again later today. Unfortunately, there is a mistake. >> @@ -247,9 +248,7 @@ sysexit_from_sys_call: >> movl %ebx,%esi /* 2nd arg: 1st syscall arg */ >> movl %eax,%edi /* 1st arg: syscall number */ >> call __audit_syscall_entry >> - movl RAX(%rsp),%eax /* reload syscall number */ >> - cmpq $(IA32_NR_syscalls-1),%rax >> - ja ia32_badsys >> + movl ORIG_RAX(%rsp),%eax /* reload syscall number */ this is correct, now syscall# is only in orig_ax, not in ax... >> call __audit_syscall_exit >> - movq RAX(%rsp),%rax /* reload syscall return value */ >> + movq ORIG_RAX(%rsp),%rax /* reload syscall return value */ but here I'm wrong, this line should not be changed. Will send v2 now. -- 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/