From patchwork Thu Aug 21 08:56:40 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 35727 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pa0-f72.google.com (mail-pa0-f72.google.com [209.85.220.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 1833E20540 for ; Thu, 21 Aug 2014 08:58:03 +0000 (UTC) Received: by mail-pa0-f72.google.com with SMTP id eu11sf72848541pac.3 for ; Thu, 21 Aug 2014 01:58:02 -0700 (PDT) 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=OFZe1bVgahOwbUbUUs1MeA2T3mmTjz5IGwCGuEGCeSI=; b=UMKLycHGSg4w7qXljDG8pRtDClZx+EX/aYT4oId7N22pRl2o93Rl3UEpmbgDfUTjuw Wqb+NSpq6jDTlT14jt8ZL/8rQxHB0zSZwhUlv/pjr3olYgU8+42vTHc49gBOWuC/FFWr pIj8OFNC0611KU74hvYmM6BM1ByiAAWuVZCAxfOREQhx9Qq1hkZFjk3BNFmpKWQSMSOm 2JkzY6mnnWFUCgSv/o7f7+sNVnse4ptrrz8L4FzqzYGvTrR0B/c3MzJb2KCZIpS+lQb7 L6+8QOov8vtKqMEc6O0umPjQYhIhKWC8Bn6JU4qVlW4x/q6a6aNQUqruH5jdqFWqnYGD GvxQ== X-Gm-Message-State: ALoCoQkr5Umv7u+ZZvS7aQXVf/CE0qOtljQ+BmqNhoTpRtX0pH2i4uOm+pu7OPJDYVIJJJaqGPBt X-Received: by 10.66.196.70 with SMTP id ik6mr3690666pac.44.1408611482417; Thu, 21 Aug 2014 01:58:02 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.42.87 with SMTP id b81ls596305qga.19.gmail; Thu, 21 Aug 2014 01:58:02 -0700 (PDT) X-Received: by 10.220.167.9 with SMTP id o9mr41148867vcy.8.1408611482249; Thu, 21 Aug 2014 01:58:02 -0700 (PDT) Received: from mail-vc0-f177.google.com (mail-vc0-f177.google.com [209.85.220.177]) by mx.google.com with ESMTPS id dz10si12128957vdb.57.2014.08.21.01.58.02 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 21 Aug 2014 01:58:02 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.177 as permitted sender) client-ip=209.85.220.177; Received: by mail-vc0-f177.google.com with SMTP id hy4so10227680vcb.22 for ; Thu, 21 Aug 2014 01:58:02 -0700 (PDT) X-Received: by 10.52.30.2 with SMTP id o2mr5139974vdh.12.1408611482163; Thu, 21 Aug 2014 01:58:02 -0700 (PDT) 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.221.45.67 with SMTP id uj3csp118493vcb; Thu, 21 Aug 2014 01:58:01 -0700 (PDT) X-Received: by 10.68.69.71 with SMTP id c7mr59897231pbu.43.1408611480389; Thu, 21 Aug 2014 01:58:00 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e5si35597913pds.124.2014.08.21.01.57.59 for ; Thu, 21 Aug 2014 01:58:00 -0700 (PDT) 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 S1753943AbaHUI5r (ORCPT + 26 others); Thu, 21 Aug 2014 04:57:47 -0400 Received: from mail-pd0-f178.google.com ([209.85.192.178]:52790 "EHLO mail-pd0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753882AbaHUI5h (ORCPT ); Thu, 21 Aug 2014 04:57:37 -0400 Received: by mail-pd0-f178.google.com with SMTP id w10so13458671pde.23 for ; Thu, 21 Aug 2014 01:57:37 -0700 (PDT) X-Received: by 10.66.178.231 with SMTP id db7mr58962465pac.63.1408611457540; Thu, 21 Aug 2014 01:57:37 -0700 (PDT) Received: from localhost.localdomain (KD182249099030.au-net.ne.jp. [182.249.99.30]) by mx.google.com with ESMTPSA id q5sm37734708pdf.70.2014.08.21.01.57.32 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 21 Aug 2014 01:57:36 -0700 (PDT) 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 v6 1/6] arm64: ptrace: add PTRACE_SET_SYSCALL Date: Thu, 21 Aug 2014 17:56:40 +0900 Message-Id: <1408611405-8943-2-git-send-email-takahiro.akashi@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1408611405-8943-1-git-send-email-takahiro.akashi@linaro.org> References: <1408611405-8943-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.220.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: , To allow tracer to be able to change/skip a system call by re-writing a syscall number, there are several approaches: (1) modify x8 register with ptrace(PTRACE_SETREGSET), and handle this case later on in syscall_trace_enter(), or (2) support ptrace(PTRACE_SET_SYSCALL) as on 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 to be visible, especially case of -1, before this function returns in syscall_trace_enter(), we'd better take (2). Signed-off-by: AKASHI Takahiro Reviewed-by: Kees Cook --- arch/arm64/include/uapi/asm/ptrace.h | 1 + arch/arm64/kernel/ptrace.c | 14 +++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/arch/arm64/include/uapi/asm/ptrace.h b/arch/arm64/include/uapi/asm/ptrace.h index 6913643..49c6174 100644 --- a/arch/arm64/include/uapi/asm/ptrace.h +++ b/arch/arm64/include/uapi/asm/ptrace.h @@ -23,6 +23,7 @@ #include +#define PTRACE_SET_SYSCALL 23 /* * PSR bits diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c index 0310811..8876049 100644 --- a/arch/arm64/kernel/ptrace.c +++ b/arch/arm64/kernel/ptrace.c @@ -1077,7 +1077,19 @@ const struct user_regset_view *task_user_regset_view(struct task_struct *task) long arch_ptrace(struct task_struct *child, long request, unsigned long addr, unsigned long data) { - return ptrace_request(child, request, addr, data); + int ret; + + switch (request) { + case PTRACE_SET_SYSCALL: + task_pt_regs(child)->syscallno = data; + ret = 0; + break; + default: + ret = ptrace_request(child, request, addr, data); + break; + } + + return ret; } enum ptrace_syscall_dir {