From patchwork Wed Nov 26 04:49:46 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 41514 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f69.google.com (mail-wg0-f69.google.com [74.125.82.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 7F1E025E18 for ; Wed, 26 Nov 2014 04:50:36 +0000 (UTC) Received: by mail-wg0-f69.google.com with SMTP id k14sf1277237wgh.8 for ; Tue, 25 Nov 2014 20:50:35 -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=lQoli3CdcuzLmQBBSAvWFeiSRTFQw1wMtPPXKmmIJyEY9ZTeyLZ09/oQPIHOY+V41u G9UKarsszMTnv8/Ogwgl6nYOoIHNTl2yEruP78yiF7gQ6FO/CzHK36GPNzNiJ8D7Mhds JZLUhKrol0irl3oH8sS4cTWKk/EQSFojpQmxU1dCAy5gWh9lyz+aYYT6yipsyxLRbCDf 6wCr5jiySb18GZ4zzjRWicUFA/LYucmH9ZFpAssEMDAEQyJDpMq4vBhmpBFgOWoauune G9zv/saJts1sChURHltJ6IKrPAle3axD9VJMvjx/oenCNM15qQxATI2qG5EzpzMOA59B LI+Q== X-Gm-Message-State: ALoCoQmvm2a25OvEn6rUd195vvtifNvWwa4PAxQ62uECXirdCqTrV/VS81ia7hOPpbsQ8JnvZ8ZN X-Received: by 10.194.176.106 with SMTP id ch10mr21691wjc.6.1416977435842; Tue, 25 Nov 2014 20:50:35 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.6.72 with SMTP id y8ls377215lay.99.gmail; Tue, 25 Nov 2014 20:50:35 -0800 (PST) X-Received: by 10.153.7.170 with SMTP id dd10mr31579538lad.44.1416977435083; Tue, 25 Nov 2014 20:50:35 -0800 (PST) Received: from mail-lb0-f179.google.com (mail-lb0-f179.google.com. [209.85.217.179]) by mx.google.com with ESMTPS id t15si3167449laz.105.2014.11.25.20.50.34 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 25 Nov 2014 20:50:34 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.179 as permitted sender) client-ip=209.85.217.179; Received: by mail-lb0-f179.google.com with SMTP id z11so1755613lbi.24 for ; Tue, 25 Nov 2014 20:50:34 -0800 (PST) X-Received: by 10.152.8.170 with SMTP id s10mr31813091laa.56.1416977434650; Tue, 25 Nov 2014 20:50:34 -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 ew9csp567439lbc; Tue, 25 Nov 2014 20:50:33 -0800 (PST) X-Received: by 10.66.219.70 with SMTP id pm6mr49942485pac.126.1416977431679; Tue, 25 Nov 2014 20:50:31 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id jt2si1199656pbc.257.2014.11.25.20.50.30 for ; Tue, 25 Nov 2014 20:50:31 -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 S1752361AbaKZEu3 (ORCPT + 26 others); Tue, 25 Nov 2014 23:50:29 -0500 Received: from mail-pa0-f42.google.com ([209.85.220.42]:51310 "EHLO mail-pa0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752340AbaKZEu1 (ORCPT ); Tue, 25 Nov 2014 23:50:27 -0500 Received: by mail-pa0-f42.google.com with SMTP id et14so2082114pad.1 for ; Tue, 25 Nov 2014 20:50:26 -0800 (PST) X-Received: by 10.66.119.175 with SMTP id kv15mr50699534pab.30.1416977426568; Tue, 25 Nov 2014 20:50:26 -0800 (PST) Received: from localhost.localdomain (KD182249086035.au-net.ne.jp. [182.249.86.35]) by mx.google.com with ESMTPSA id yp8sm2962059pab.48.2014.11.25.20.50.20 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 25 Nov 2014 20:50:25 -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 v9 1/6] arm64: ptrace: add NT_ARM_SYSTEM_CALL regset Date: Wed, 26 Nov 2014 13:49:46 +0900 Message-Id: <1416977391-24231-2-git-send-email-takahiro.akashi@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1416977391-24231-1-git-send-email-takahiro.akashi@linaro.org> References: <1416977391-24231-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.179 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 */