[PATCH] arm: ptrace: fix syscall modification under PTRACE_O_TRACESECCOMP

Andy Lutomirski luto at amacapital.net
Thu Jul 3 08:39:21 PDT 2014


On Thu, Jul 3, 2014 at 3:24 AM, Will Deacon <will.deacon at arm.com> wrote:
> On Thu, Jul 03, 2014 at 08:43:07AM +0100, AKASHI Takahiro wrote:
>> Hi Will,
>
> Hi Akashi,
>
>> 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.

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?

--Andy



More information about the linux-arm-kernel mailing list