From patchwork Wed Nov 26 04:49:47 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 5384021 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id ADAE49F39B for ; Wed, 26 Nov 2014 04:53:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D44D3201EF for ; Wed, 26 Nov 2014 04:53:25 +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 0152F200D0 for ; Wed, 26 Nov 2014 04:53:25 +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 1XtUZR-0004hX-Gz; Wed, 26 Nov 2014 04:51:17 +0000 Received: from mail-pa0-f50.google.com ([209.85.220.50]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XtUZ7-0004WU-Ka for linux-arm-kernel@lists.infradead.org; Wed, 26 Nov 2014 04:50:58 +0000 Received: by mail-pa0-f50.google.com with SMTP id bj1so2083662pad.9 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:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Pt+CzdgvQdo6Ye1h9YkW/Lar4RPu41dW1Gz1/Sg85e0=; b=jvsBCtSufK5pn4O9MbG9jyCjjPCgi18FZ9kE3dS0M3Y29ZMUUWCczd5JwNfYdsgYaQ SINl9/dKi9fYGJBP28d5T9VCOXUx/AzlIU1PgRmV0Hrle1Ov4WY978Y71HjO9krtGJ3B Q/k6lnqhMheH5xZoJ8ncBVm/z1kI2PUwhKJ2d1Ek5mcsc59uqPFX+Jo4tgkN2i2pKaCr ue+HAFfQdW4Lw2p4q2eUAPJ8qaq/hfC8r4T2d2okQymWs/+mucaFREznMewd3S+k/BMb eByY68jSAMzNROP6Zh5hbdtF+9zaTDqFPjjKSo1Z15B2fJ1Ov39G0/yROZOO3RtQa7pW grcA== X-Gm-Message-State: ALoCoQlDvhC8xwzKmv25HopHFZJp2teCJRRYaZG3DnDUHV61HnBn3YhpTe+5OSR1yDnCpWVC+rkV X-Received: by 10.70.93.104 with SMTP id ct8mr49764450pdb.72.1416977435490; Tue, 25 Nov 2014 20:50:35 -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.29 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 25 Nov 2014 20:50:34 -0800 (PST) From: AKASHI Takahiro To: keescook@chromium.org, catalin.marinas@arm.com, will.deacon@arm.com Subject: [PATCH v9 2/6] arm64: ptrace: allow tracer to skip a system call Date: Wed, 26 Nov 2014 13:49:47 +0900 Message-Id: <1416977391-24231-3-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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141125_205057_751279_12BCB5A2 X-CRM114-Status: GOOD ( 10.18 ) X-Spam-Score: -0.7 (/) 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_LOW, T_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 If tracer modifies a syscall number to -1, this traced system call should be skipped with a return value specified in x0. This patch implements this semantics. Please note: * syscall entry tracing and syscall exit tracing (ftrace tracepoint and audit) are always executed, if enabled, even when skipping a system call (that is, -1). In this way, we can avoid a potential bug where audit_syscall_entry() might be called without audit_syscall_exit() at the previous system call being called, that would cause OOPs in audit_syscall_entry(). Signed-off-by: AKASHI Takahiro --- arch/arm64/kernel/entry.S | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S index 726b910..946ec52 100644 --- a/arch/arm64/kernel/entry.S +++ b/arch/arm64/kernel/entry.S @@ -161,6 +161,7 @@ */ sc_nr .req x25 // number of system calls scno .req x26 // syscall number +scno_w .req w26 // syscall number (lower 32 bits) stbl .req x27 // syscall table pointer tsk .req x28 // current thread_info @@ -668,8 +669,14 @@ ENDPROC(el0_svc) * switches, and waiting for our parent to respond. */ __sys_trace: - mov x0, sp + cmp scno_w, #-1 // set default errno for + b.ne 1f // user-issued syscall(-1) + mov x0, #-ENOSYS + str x0, [sp] +1: mov x0, sp bl syscall_trace_enter + cmp w0, #-1 // skip the syscall? + b.eq __sys_trace_return_skipped adr lr, __sys_trace_return // return address uxtw scno, w0 // syscall number (possibly new) mov x1, sp // pointer to regs @@ -684,6 +691,7 @@ __sys_trace: __sys_trace_return: str x0, [sp] // save returned x0 +__sys_trace_return_skipped: mov x0, sp bl syscall_trace_exit b ret_to_user