From patchwork Tue Nov 18 01:10:33 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 40987 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f72.google.com (mail-la0-f72.google.com [209.85.215.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 1CD9B24035 for ; Tue, 18 Nov 2014 01:13:06 +0000 (UTC) Received: by mail-la0-f72.google.com with SMTP id gm9sf1650541lab.3 for ; Mon, 17 Nov 2014 17:13:05 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=KeqMmjTr+eC6D04lc6TwtHSwSpdpwS26rbYTYI9Qu7I=; b=XyA4qhB0i2lroRoMzSF6w80Z4/jWvzHBFvgGbui0rqjD4sFvKalfI2RSH1hX5rBk9/ B9WBJL2NvjdhuYDCiZfpNZh+5znxrz+S7JZ4kYGlBldHw5uTqXyKF/QzM3RDPgBEEZV9 I15gv7videj62LpvMbYcWcdd5c3+xQDcEnWoxBDtChdLzNZ7f7JC1ZcOGXaEQFxxmq79 Sr3XnNFQcpMVQfuxFEJKAVk8MpNC3k28+bdGiTLeIO+x1BT39sQxat/uuTqDX83rrFkW CZvp+B2hFp2g6AvwQnV0eAiHX4r1C0fV1rJnMos6CUcaS1BVEU9FwxlhjdHxMvl7faeK xYHw== X-Gm-Message-State: ALoCoQnNLURssNrZtjlZsJNWFAPaHSqFZh//O8RfBovHydbuVzd0INwE6wQL0FqBjD+JRxFsuv1R X-Received: by 10.180.182.164 with SMTP id ef4mr5026670wic.0.1416273185002; Mon, 17 Nov 2014 17:13:05 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.2.40 with SMTP id 8ls1282567lar.61.gmail; Mon, 17 Nov 2014 17:13:04 -0800 (PST) X-Received: by 10.152.9.136 with SMTP id z8mr31949147laa.2.1416273184519; Mon, 17 Nov 2014 17:13:04 -0800 (PST) Received: from mail-lb0-f177.google.com (mail-lb0-f177.google.com. [209.85.217.177]) by mx.google.com with ESMTPS id oq4si7043206lbb.16.2014.11.17.17.13.04 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 17 Nov 2014 17:13:04 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.177 as permitted sender) client-ip=209.85.217.177; Received: by mail-lb0-f177.google.com with SMTP id z12so9974179lbi.22 for ; Mon, 17 Nov 2014 17:13:04 -0800 (PST) X-Received: by 10.152.42.226 with SMTP id r2mr31819558lal.29.1416273184393; Mon, 17 Nov 2014 17:13:04 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.184.201 with SMTP id ew9csp1257054lbc; Mon, 17 Nov 2014 17:13:03 -0800 (PST) X-Received: by 10.70.32.197 with SMTP id l5mr23325094pdi.67.1416273182691; Mon, 17 Nov 2014 17:13:02 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ml1si19965542pdb.20.2014.11.17.17.13.01 for ; Mon, 17 Nov 2014 17:13:02 -0800 (PST) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753548AbaKRBLh (ORCPT + 26 others); Mon, 17 Nov 2014 20:11:37 -0500 Received: from mail-pa0-f54.google.com ([209.85.220.54]:65099 "EHLO mail-pa0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753129AbaKRBLe (ORCPT ); Mon, 17 Nov 2014 20:11:34 -0500 Received: by mail-pa0-f54.google.com with SMTP id hz1so12119972pad.41 for ; Mon, 17 Nov 2014 17:11:34 -0800 (PST) X-Received: by 10.70.43.78 with SMTP id u14mr32497pdl.166.1416273093989; Mon, 17 Nov 2014 17:11:33 -0800 (PST) Received: from localhost.localdomain (KD182249087116.au-net.ne.jp. [182.249.87.116]) by mx.google.com with ESMTPSA id cf12sm36225005pdb.77.2014.11.17.17.11.28 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 17 Nov 2014 17:11:32 -0800 (PST) From: AKASHI Takahiro To: keescook@chromium.org, catalin.marinas@arm.com, will.deacon@arm.com Cc: dsaxena@linaro.org, arndb@arndb.de, linux-arm-kernel@lists.infradead.org, linaro-kernel@lists.linaro.org, linux-kernel@vger.kernel.org, AKASHI Takahiro Subject: [PATCH v8 1/6] arm64: ptrace: add NT_ARM_SYSTEM_CALL regset Date: Tue, 18 Nov 2014 10:10:33 +0900 Message-Id: <1416273038-15590-2-git-send-email-takahiro.akashi@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1416273038-15590-1-git-send-email-takahiro.akashi@linaro.org> References: <1416273038-15590-1-git-send-email-takahiro.akashi@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: takahiro.akashi@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.177 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , This regeset is intended to be used to get and set a system call number while tracing. There was some discussion about possible approaches to do so: (1) modify x8 register with ptrace(PTRACE_SETREGSET) indirectly, and update regs->syscallno later on in syscall_trace_enter(), or (2) define a dedicated regset for this purpose as on s390, or (3) support ptrace(PTRACE_SET_SYSCALL) as on arch/arm Thinking of the fact that user_pt_regs doesn't expose 'syscallno' to tracer as well as that secure_computing() expects a changed syscall number, especially case of -1, to be visible before this function returns in syscall_trace_enter(), (1) doesn't work well. We will take (2) since it looks much cleaner. Signed-off-by: AKASHI Takahiro --- arch/arm64/kernel/ptrace.c | 35 +++++++++++++++++++++++++++++++++++ include/uapi/linux/elf.h | 1 + 2 files changed, 36 insertions(+) diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c index 8a4ae8e..8b98781 100644 --- a/arch/arm64/kernel/ptrace.c +++ b/arch/arm64/kernel/ptrace.c @@ -551,6 +551,32 @@ static int tls_set(struct task_struct *target, const struct user_regset *regset, return ret; } +static int system_call_get(struct task_struct *target, + const struct user_regset *regset, + unsigned int pos, unsigned int count, + void *kbuf, void __user *ubuf) +{ + struct pt_regs *regs = task_pt_regs(target); + + return user_regset_copyout(&pos, &count, &kbuf, &ubuf, + ®s->syscallno, 0, -1); +} + +static int system_call_set(struct task_struct *target, + const struct user_regset *regset, + unsigned int pos, unsigned int count, + const void *kbuf, const void __user *ubuf) +{ + int syscallno, ret; + + ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &syscallno, 0, -1); + if (ret) + return ret; + + task_pt_regs(target)->syscallno = syscallno; + return ret; +} + enum aarch64_regset { REGSET_GPR, REGSET_FPR, @@ -559,6 +585,7 @@ enum aarch64_regset { REGSET_HW_BREAK, REGSET_HW_WATCH, #endif + REGSET_SYSTEM_CALL, }; static const struct user_regset aarch64_regsets[] = { @@ -608,6 +635,14 @@ static const struct user_regset aarch64_regsets[] = { .set = hw_break_set, }, #endif + [REGSET_SYSTEM_CALL] = { + .core_note_type = NT_ARM_SYSTEM_CALL, + .n = 1, + .size = sizeof(int), + .align = sizeof(int), + .get = system_call_get, + .set = system_call_set, + }, }; static const struct user_regset_view user_aarch64_view = { diff --git a/include/uapi/linux/elf.h b/include/uapi/linux/elf.h index ea9bf25..71e1d0e 100644 --- a/include/uapi/linux/elf.h +++ b/include/uapi/linux/elf.h @@ -397,6 +397,7 @@ typedef struct elf64_shdr { #define NT_ARM_TLS 0x401 /* ARM TLS register */ #define NT_ARM_HW_BREAK 0x402 /* ARM hardware breakpoint registers */ #define NT_ARM_HW_WATCH 0x403 /* ARM hardware watchpoint registers */ +#define NT_ARM_SYSTEM_CALL 0x404 /* ARM system call number */ #define NT_METAG_CBUF 0x500 /* Metag catch buffer registers */ #define NT_METAG_RPIPE 0x501 /* Metag read pipeline state */ #define NT_METAG_TLS 0x502 /* Metag TLS pointer */