From patchwork Fri Nov 28 05:26:34 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 41659 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 229C8244C2 for ; Fri, 28 Nov 2014 05:27:26 +0000 (UTC) Received: by mail-la0-f72.google.com with SMTP id gq15sf3683311lab.3 for ; Thu, 27 Nov 2014 21:27:25 -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=BRjP25vgM57vldpjosFRn2Z0xeRP7+PcxLTBehmahoU=; b=RUHTmh9PNvdIN2LjKmGmbMpUteCUzJ03Q3PEoEu+zuyRRB/v65a+WG5N4W81Rv1bpq 1syicfb9dcWLs8pTAuYFLjm1s43tyDExumzMT6n9nd+2zO43Cx6VL5IO3QTzzUlXnaGr HqPdkHSGDxJGjGBkqD4Pe4lHuZA/CYTZNm3zI5fEOuakfnpyJLaAqwu9PrEWHzN7x5/8 o8fvnmMSqKnjf/FN8IAk2VUtzexgMmQTzv8Fg/dDWh4iSRlYp7TiOh+w2AJOU/ofX3q1 GvaeUvZtswDr/P+xRrZOkDuN73lj8jCsfiy0TP3TRL3JcMQBl1Tvj0kU8Z3Rm635iddd PNDQ== X-Gm-Message-State: ALoCoQmNEIudav5j25dLvBfTyGnljfE82iQgMRgMOF4icECpF4lPTcArV7LS9/xeTQ53ixgzNrBJ X-Received: by 10.152.8.67 with SMTP id p3mr11556774laa.4.1417152445011; Thu, 27 Nov 2014 21:27:25 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.5.72 with SMTP id q8ls728141laq.98.gmail; Thu, 27 Nov 2014 21:27:24 -0800 (PST) X-Received: by 10.112.42.198 with SMTP id q6mr41827623lbl.69.1417152444510; Thu, 27 Nov 2014 21:27:24 -0800 (PST) Received: from mail-la0-f46.google.com (mail-la0-f46.google.com. [209.85.215.46]) by mx.google.com with ESMTPS id ml2si8983479lbc.7.2014.11.27.21.27.24 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 27 Nov 2014 21:27:24 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.46 as permitted sender) client-ip=209.85.215.46; Received: by mail-la0-f46.google.com with SMTP id q1so212365lam.5 for ; Thu, 27 Nov 2014 21:27:24 -0800 (PST) X-Received: by 10.153.7.170 with SMTP id dd10mr41594478lad.44.1417152444408; Thu, 27 Nov 2014 21:27:24 -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 ew9csp35154lbc; Thu, 27 Nov 2014 21:27:23 -0800 (PST) X-Received: by 10.67.12.236 with SMTP id et12mr70541670pad.31.1417152442472; Thu, 27 Nov 2014 21:27:22 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id xu8si14497790pab.121.2014.11.27.21.27.21 for ; Thu, 27 Nov 2014 21:27:22 -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 S1751304AbaK1F1T (ORCPT + 26 others); Fri, 28 Nov 2014 00:27:19 -0500 Received: from mail-pa0-f50.google.com ([209.85.220.50]:56875 "EHLO mail-pa0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750888AbaK1F1R (ORCPT ); Fri, 28 Nov 2014 00:27:17 -0500 Received: by mail-pa0-f50.google.com with SMTP id bj1so6121947pad.37 for ; Thu, 27 Nov 2014 21:27:16 -0800 (PST) X-Received: by 10.68.65.112 with SMTP id w16mr69500735pbs.114.1417152436427; Thu, 27 Nov 2014 21:27:16 -0800 (PST) Received: from localhost.localdomain (KD182249096114.au-net.ne.jp. [182.249.96.114]) by mx.google.com with ESMTPSA id kp2sm8661866pdb.30.2014.11.27.21.27.11 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 27 Nov 2014 21:27:15 -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 v10 1/6] arm64: ptrace: add NT_ARM_SYSTEM_CALL regset Date: Fri, 28 Nov 2014 14:26:34 +0900 Message-Id: <1417152399-32717-2-git-send-email-takahiro.akashi@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1417152399-32717-1-git-send-email-takahiro.akashi@linaro.org> References: <1417152399-32717-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.215.46 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..f576781 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) +{ + int syscallno = task_pt_regs(target)->syscallno; + + return user_regset_copyout(&pos, &count, &kbuf, &ubuf, + &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 */