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: 4756121 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 83B5CC0338 for ; Thu, 21 Aug 2014 09:00:09 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 70F4D20155 for ; Thu, 21 Aug 2014 09:00:08 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 47E3820136 for ; Thu, 21 Aug 2014 09:00:07 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XKOC1-000733-3r; Thu, 21 Aug 2014 08:58:01 +0000 Received: from mail-pd0-f177.google.com ([209.85.192.177]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XKOBy-000702-Sr for linux-arm-kernel@lists.infradead.org; Thu, 21 Aug 2014 08:57:59 +0000 Received: by mail-pd0-f177.google.com with SMTP id p10so13056593pdj.8 for ; Thu, 21 Aug 2014 01:57:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ZjX0YzxNzddLOm9Y+RS5cZlMhzFfcvRO4QejxuNTE3Q=; b=T8pQx6WxFUAx1YflOJPUyO4gkqWrWkKzVrUhyR21qJlmXIMCmgvDgexm8a/PmY3Afi R3mkF3740W/QyMVN8eLj62h08zDKHem+MVaR9NZVTNYPnPjqsGHXy9jdNvPyUDVDIBSa 7Pot7vR1lZQdwW2oLSqCVdz+ZPBsZ3oPW+2BBOI8NjydVKUynaBrnrLHomDVbTlWaOpK GNz2WkfB8gPO8th8m5qwsmcMr8bqxgWhiAsMfECaycRVT7TooXSLBdClSQ8+lKggsn6A zBYWp4fzh8QCi7kNQ9CKEL9Ouiq1MDHFU0C1xIpNkYVuyOyt2s7K7GNzbYmMGwWKUe1p tPSg== X-Gm-Message-State: ALoCoQnPTWUxf4jgEv+SLX9u/9Ua0DK5P0MqIBWqZOGT5DvDdgaDZF+31ULg1zsSvc35mSIG3Slq 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140821_015758_947077_5B653B51 X-CRM114-Status: GOOD ( 11.96 ) X-Spam-Score: -1.4 (-) Cc: linaro-kernel@lists.linaro.org, arndb@arndb.de, linux-kernel@vger.kernel.org, AKASHI Takahiro , dsaxena@linaro.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 {