From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751520AbbLUJAu (ORCPT ); Mon, 21 Dec 2015 04:00:50 -0500 Received: from a.ns.miles-group.at ([95.130.255.143]:11951 "EHLO radon.swed.at" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751079AbbLUJAs (ORCPT ); Mon, 21 Dec 2015 04:00:48 -0500 Subject: Re: [PATCH v1 1/4] um: Fix ptrace GETREGS/SETREGS bugs To: =?UTF-8?Q?Micka=c3=abl_Sala=c3=bcn?= , linux-kernel@vger.kernel.org References: <1450656209-2676-1-git-send-email-mic@digikod.net> <1450656209-2676-2-git-send-email-mic@digikod.net> <567745E3.1030509@nod.at> <5677BD23.4060602@digikod.net> Cc: Jonathan Corbet , Jeff Dike , Thomas Gleixner , Ingo Molnar , "H . Peter Anvin" , x86@kernel.org, Kees Cook , Andy Lutomirski , Will Drewry , Shuah Khan , Chris Metcalf , Michael Ellerman , Andrew Morton , James Hogan , Thomas Meyer , Nicolas Iooss , Anton Ivanov , linux-doc@vger.kernel.org, user-mode-linux-devel@lists.sourceforge.net, user-mode-linux-user@lists.sourceforge.net, linux-api@vger.kernel.org, Meredydd Luff , David Drysdale From: Richard Weinberger Message-ID: <5677BFBD.3090200@nod.at> Date: Mon, 21 Dec 2015 10:00:45 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0 MIME-Version: 1.0 In-Reply-To: <5677BD23.4060602@digikod.net> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [sending the mail again, Thunderbird crashed :-\] Am 21.12.2015 um 09:49 schrieb Mickaël Salaün: > > On 21/12/2015 01:20, Richard Weinberger wrote: >> Am 21.12.2015 um 01:03 schrieb Mickaël Salaün: >>> diff --git a/arch/um/kernel/skas/syscall.c b/arch/um/kernel/skas/syscall.c >>> index 1683b8e..65f0d1a 100644 >>> --- a/arch/um/kernel/skas/syscall.c >>> +++ b/arch/um/kernel/skas/syscall.c >>> @@ -7,6 +7,7 @@ >>> #include >>> #include >>> #include >>> +#include >>> #include >>> #include >>> >>> @@ -16,12 +17,16 @@ void handle_syscall(struct uml_pt_regs *r) >>> long result; >>> int syscall; >>> >>> + /* Save the syscall register. */ >>> + UPT_SYSCALL_NR(r) = PT_SYSCALL_NR(r->gp); >>> + >>> if (syscall_trace_enter(regs)) { >>> result = -ENOSYS; >>> goto out; >>> } >>> >>> - syscall = get_syscall(r); >>> + /* Get the syscall after being potentially updated with ptrace. */ >>> + syscall = UPT_SYSCALL_NR(r); >> >> Doesn't this break the support for changing syscall numbers using PTRACE_SETREGS? > > The logic is unchanged except updating the UPT_SYSCALL_NR before syscall_trace_enter(). I did my last tests with the x86_32 subarchitecture and all tests (from selftest/seccomp), including PTRACE_SETREGS for syscall numbers tests, passed. However, 2 of this tests still fail for x86_64 (only). No, the logic is different. syscall_trace_enter(regs) enters the ptrace() path and here registers can be changed. Hence "syscall = UPT_SYSCALL_NR(r);" will see the old syscall number. UPT_SYSCALL_NR() returns the syscall number before the ptrace() path... Thanks, //richard