From patchwork Fri Nov 7 07:47:23 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 40376 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f197.google.com (mail-wi0-f197.google.com [209.85.212.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 10A7524237 for ; Fri, 7 Nov 2014 07:48:08 +0000 (UTC) Received: by mail-wi0-f197.google.com with SMTP id ex7sf1556502wid.0 for ; Thu, 06 Nov 2014 23:48:07 -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:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=uGTV3UOwcHOU45lldBDsf359m+WiLT4gRam6PhzKtmY=; b=Q38LwuDPqiavrDXEOcGalrxsRx+sVIjHBHLfVMa9ra751rtSg1uDJ00vlid7i2zSyh /m1rJkiFhKIQ7iy/qzUEtqFfuzlUcGITSdMmsYwVWQFiNkNZ2O7LIGvHJMfWPFblWMN1 /7givh6sAxm0LB6wg0ab5Zikkp0gdUsy8rHyCJvIxlUkNw0IqW0bC+P1YzRau0eLX3jH 5XAlMbXvIR8eT6ESaHQoT+nwC5KH68zCvV2SA3pPhBfDMswOnHQkKKF/ZOAIg0X/uUdm yu5WYgik0x/wMSqqEyXnG8Ql3JtsMMwpby2vUYL15/apLTJFbfLh4XUlwDmqVh/TF3iw yYlA== X-Gm-Message-State: ALoCoQkzFHC03AUDC4NGlknNQcrWHPwwdyzAPnOw0aNbsGachFW+wJExqA3RhMGlO0k8zYMYr5ql X-Received: by 10.152.37.37 with SMTP id v5mr901laj.9.1415346487316; Thu, 06 Nov 2014 23:48:07 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.1.169 with SMTP id 9ls181283lan.109.gmail; Thu, 06 Nov 2014 23:48:06 -0800 (PST) X-Received: by 10.112.173.100 with SMTP id bj4mr1356331lbc.78.1415346486969; Thu, 06 Nov 2014 23:48:06 -0800 (PST) Received: from mail-lb0-f176.google.com (mail-lb0-f176.google.com. [209.85.217.176]) by mx.google.com with ESMTPS id mi5si14101186lbc.61.2014.11.06.23.48.06 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 06 Nov 2014 23:48:06 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.176 as permitted sender) client-ip=209.85.217.176; Received: by mail-lb0-f176.google.com with SMTP id 10so2201846lbg.21 for ; Thu, 06 Nov 2014 23:48:06 -0800 (PST) X-Received: by 10.112.202.104 with SMTP id kh8mr9760568lbc.46.1415346486857; Thu, 06 Nov 2014 23:48:06 -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 ew9csp161509lbc; Thu, 6 Nov 2014 23:48:06 -0800 (PST) X-Received: by 10.66.216.232 with SMTP id ot8mr10201417pac.19.1415346485251; Thu, 06 Nov 2014 23:48:05 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ha5si8279621pbb.93.2014.11.06.23.48.03 for ; Thu, 06 Nov 2014 23:48:05 -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 S1751474AbaKGHsC (ORCPT + 25 others); Fri, 7 Nov 2014 02:48:02 -0500 Received: from mail-pa0-f44.google.com ([209.85.220.44]:43418 "EHLO mail-pa0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751054AbaKGHr5 (ORCPT ); Fri, 7 Nov 2014 02:47:57 -0500 Received: by mail-pa0-f44.google.com with SMTP id bj1so3061453pad.3 for ; Thu, 06 Nov 2014 23:47:56 -0800 (PST) X-Received: by 10.66.246.196 with SMTP id xy4mr10425396pac.29.1415346476278; Thu, 06 Nov 2014 23:47:56 -0800 (PST) Received: from localhost.localdomain (KD182249089020.au-net.ne.jp. [182.249.89.20]) by mx.google.com with ESMTPSA id gy5sm7835407pbc.68.2014.11.06.23.47.50 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 06 Nov 2014 23:47:55 -0800 (PST) From: AKASHI Takahiro To: roland@hack.frob.com, oleg@redhat.com Cc: linux@arm.linux.org.uk, will.deacon@arm.com, dsaxena@linaro.org, keescook@chromium.org, linux-arm-kernel@lists.infradead.org, linaro-kernel@lists.linaro.org, linux-kernel@vger.kernel.org, AKASHI Takahiro Subject: [RFC] ptrace: add generic SET_SYSCALL request Date: Fri, 7 Nov 2014 16:47:23 +0900 Message-Id: <1415346443-28915-1-git-send-email-takahiro.akashi@linaro.org> X-Mailer: git-send-email 1.9.1 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.176 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 patch adds a new generic ptrace request, PTRACE_SET_SYSCALL. It can be used to change a system call number as follows: ret = ptrace(pid, PTRACE_SET_SYSCALL, null, new_syscall_no); 'new_syscall_no' can be -1 to skip this system call, you need to modify a register's value, in arch-specific way, as return value though. Please note that we can't define PTRACE_SET_SYSCALL macro in uapi/linux/ptrace.h partly because its value on arm, 23, is used as another request on sparc. This patch also contains an example of change on arch side, arm. Only syscall_set_nr() is required to be defined in asm/syscall.h. Currently only arm has this request, while arm64 would also have it once my patch series of seccomp for arm64 is merged. It will also be usable for most of other arches. See the discussions in lak-ml: http://lists.infradead.org/pipermail/linux-arm-kernel/2014-November/300167.html Signed-off-by: AKASHI Takahiro --- arch/arm/include/asm/syscall.h | 7 +++++++ arch/arm/kernel/ptrace.c | 5 ----- kernel/ptrace.c | 6 ++++++ 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/arch/arm/include/asm/syscall.h b/arch/arm/include/asm/syscall.h index e86c985..3e1d9c0 100644 --- a/arch/arm/include/asm/syscall.h +++ b/arch/arm/include/asm/syscall.h @@ -24,6 +24,13 @@ static inline int syscall_get_nr(struct task_struct *task, return task_thread_info(task)->syscall; } +static inline int syscall_set_nr(struct task_struct *task, + struct pt_regs *regs, int syscall) +{ + task_thread_info(task)->syscall = syscall; + return 0; +} + static inline void syscall_rollback(struct task_struct *task, struct pt_regs *regs) { diff --git a/arch/arm/kernel/ptrace.c b/arch/arm/kernel/ptrace.c index ef9119f..908bae8 100644 --- a/arch/arm/kernel/ptrace.c +++ b/arch/arm/kernel/ptrace.c @@ -853,11 +853,6 @@ long arch_ptrace(struct task_struct *child, long request, datap); break; - case PTRACE_SET_SYSCALL: - task_thread_info(child)->syscall = data; - ret = 0; - break; - #ifdef CONFIG_CRUNCH case PTRACE_GETCRUNCHREGS: ret = ptrace_getcrunchregs(child, datap); diff --git a/kernel/ptrace.c b/kernel/ptrace.c index 54e7522..d7048fa 100644 --- a/kernel/ptrace.c +++ b/kernel/ptrace.c @@ -1001,6 +1001,12 @@ int ptrace_request(struct task_struct *child, long request, break; } #endif + +#ifdef PTRACE_SET_SYSCALL + case PTRACE_SET_SYSCALL: + ret = syscall_set_nr(child, task_pt_regs(child), data); + break; +#endif default: break; }