From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759249AbaGCQOm (ORCPT ); Thu, 3 Jul 2014 12:14:42 -0400 Received: from cam-admin0.cambridge.arm.com ([217.140.96.50]:58808 "EHLO cam-admin0.cambridge.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932258AbaGCQMa (ORCPT ); Thu, 3 Jul 2014 12:12:30 -0400 Date: Thu, 3 Jul 2014 17:11:54 +0100 From: Will Deacon To: Andy Lutomirski Cc: AKASHI Takahiro , Kees Cook , =?iso-8859-1?Q?Andr=E9?= Hentschel , Russell King , Jonathan Austin , "linux-kernel@vger.kernel.org" , Oleg Nesterov , Andrew Morton , "linux-arm-kernel@lists.infradead.org" , Ricky Zhou Subject: Re: [PATCH] arm: ptrace: fix syscall modification under PTRACE_O_TRACESECCOMP Message-ID: <20140703161154.GF14305@arm.com> References: <20140620172330.GA30656@arm.com> <20140623084608.GA9316@arm.com> <20140624085405.GA26013@arm.com> <53B5098B.9050801@linaro.org> <20140703102450.GD12958@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jul 03, 2014 at 04:39:21PM +0100, Andy Lutomirski wrote: > On Thu, Jul 3, 2014 at 3:24 AM, Will Deacon wrote: > > On Thu, Jul 03, 2014 at 08:43:07AM +0100, AKASHI Takahiro wrote: > >> On 06/24/2014 05:54 PM, Will Deacon wrote: > >> > On Mon, Jun 23, 2014 at 08:46:52PM +0100, Kees Cook wrote: > >> >> What's the state of seccomp on arm64? I saw a series back in March, > >> >> but nothing since then? It looked complete, but I haven't set up a > >> >> test environment yet to verify. > >> > > >> > I think Akashi was going to repost `real soon now' so we can include them > >> > for 3.17. He missed the merge window last time around. > >> > >> I took a quick look at the current implementation of ptrace. > >> ptrace(PTRACE_GETREGSET/SETREGSET), eventually gpr_get/set(), handles only > >> 'struct user_pt_regs', and we have no way to modify orig_x0 nor syscallno > >> in 'struct pt_regs' directly. > >> So it seems to me that we can't change a system call by ptrace(). > >> Do I misunderstand anything? > > > > No, it looks like you have a point here. I don't think userspace has any > > business with orig_x0, but changing syscallno is certainly useful. I can > > think of two ways to fix this: > > > > (1) Updating syscallno based on w8, but this ties us to the current ABI > > and could get messy if this register changes in the future. > > > > (2) Adding a PTRACE_SET_SYSCALL request, like we have for arch/arm/, > > but that means adding arch-specific stuff to arch_ptrace (which > > currently goes straight to ptrace_request on arm64). > > > > It looks like x86 uses orig_ax, which I *think* means we would go with > > (1) above if we followed their lead. > > w8 is a real register, right? On x86, at least orig_ax isn't a real > register, so it's quite unlikely to conflict with hardware stuff. Yeah, w8 is the hardware register which the Linux ABI uses for the system call number. I was thinking We could allow the debugger/tracer to update the syscall number by updating that register, or do you see an issue with that? (other than tying us to the current ABI). > On x86, the "user_struct" thing has nothing to do with any real kernel > data structure, so it's extensible. Can you just add syscallno to it? I'm really not keen on changing user-facing structures like that. For example, KVM embeds user_pt_regs into kvm_regs. We can add a new ptrace request if we have to. Will