From patchwork Thu Oct 2 09:46:11 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 38278 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f198.google.com (mail-lb0-f198.google.com [209.85.217.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B7A5920549 for ; Thu, 2 Oct 2014 09:47:16 +0000 (UTC) Received: by mail-lb0-f198.google.com with SMTP id 10sf937866lbg.9 for ; Thu, 02 Oct 2014 02:47:15 -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=XhVz19SJZeisGt2i1Hoz4Aflp1/O3Hg2H1HBvYZ5IJY=; b=OTnQ906e37yioFiBWB5gJui8V87KoG72xmZYlxEe2NlxKAoArL5lm7Bwmyg4bZNdx0 cLh+03ABXLwnEzp2+31/29/C8rf00dl7A1rTGNVUwgIETHqyj2HAcKH63IeWIpzZkI4h 1x7kxZUVuY+z6fy7mRAnhTSm8hMhB9ruT3nlKKy5aqaAnAjddK/DYbCo9btxft5oIMq+ NuB+DS0Xmh8sHuZKALeLgapItAcYOX9bFbSsVufPZTyroynHWTvkKFqLYpZxi7Rqhzdm hGPd8W/vadGNpsj4Wh23YR9Y1XNpN4j0WgEsYnZoEoZKWm6JPO/Me2g7GdI7xAXtMHUp LSKQ== X-Gm-Message-State: ALoCoQlD7UY3xukHSZRFaOvmsrn30hVW58aWbyXJgHRPMD0nRN9KaMvnyfpB/kqRUnGlwWV4MVhB X-Received: by 10.180.74.14 with SMTP id p14mr431421wiv.6.1412243235086; Thu, 02 Oct 2014 02:47:15 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.203.136 with SMTP id kq8ls247007lac.94.gmail; Thu, 02 Oct 2014 02:47:14 -0700 (PDT) X-Received: by 10.112.78.38 with SMTP id y6mr24227355lbw.94.1412243234705; Thu, 02 Oct 2014 02:47:14 -0700 (PDT) Received: from mail-lb0-f179.google.com (mail-lb0-f179.google.com [209.85.217.179]) by mx.google.com with ESMTPS id m10si5677588lam.90.2014.10.02.02.47.14 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 02 Oct 2014 02:47:14 -0700 (PDT) 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 l4so1852006lbv.24 for ; Thu, 02 Oct 2014 02:47:14 -0700 (PDT) X-Received: by 10.153.6.36 with SMTP id cr4mr27425891lad.40.1412243234211; Thu, 02 Oct 2014 02:47:14 -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.112.130.169 with SMTP id of9csp23567lbb; Thu, 2 Oct 2014 02:47:13 -0700 (PDT) X-Received: by 10.66.165.36 with SMTP id yv4mr84940916pab.23.1412243232471; Thu, 02 Oct 2014 02:47:12 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id mb10si3201569pdb.251.2014.10.02.02.47.11 for ; Thu, 02 Oct 2014 02:47:12 -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 S1751573AbaJBJrH (ORCPT + 27 others); Thu, 2 Oct 2014 05:47:07 -0400 Received: from mail-pd0-f176.google.com ([209.85.192.176]:57306 "EHLO mail-pd0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751159AbaJBJrF (ORCPT ); Thu, 2 Oct 2014 05:47:05 -0400 Received: by mail-pd0-f176.google.com with SMTP id fp1so1755634pdb.7 for ; Thu, 02 Oct 2014 02:47:05 -0700 (PDT) X-Received: by 10.66.90.137 with SMTP id bw9mr85459574pab.7.1412243225309; Thu, 02 Oct 2014 02:47:05 -0700 (PDT) Received: from localhost.localdomain (KD182249093205.au-net.ne.jp. [182.249.93.205]) by mx.google.com with ESMTPSA id w7sm3013036pbs.4.2014.10.02.02.47.00 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 02 Oct 2014 02:47:04 -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 v7 1/6] arm64: ptrace: add PTRACE_SET_SYSCALL Date: Thu, 2 Oct 2014 18:46:11 +0900 Message-Id: <1412243176-16192-2-git-send-email-takahiro.akashi@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1412243176-16192-1-git-send-email-takahiro.akashi@linaro.org> References: <1412243176-16192-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: , 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). Reviewed-by: Kees Cook Signed-off-by: AKASHI Takahiro --- 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 fe63ac5..2842f9f 100644 --- a/arch/arm64/kernel/ptrace.c +++ b/arch/arm64/kernel/ptrace.c @@ -1082,7 +1082,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 {