From patchwork Fri Nov 28 05:26:35 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 5401581 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 05B599F443 for ; Fri, 28 Nov 2014 05:30:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0042620123 for ; Fri, 28 Nov 2014 05:30:33 +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 240F720122 for ; Fri, 28 Nov 2014 05:30:32 +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 1XuE6T-0006p9-4E; Fri, 28 Nov 2014 05:28:25 +0000 Received: from mail-pd0-f181.google.com ([209.85.192.181]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XuE5o-0006T2-Pa for linux-arm-kernel@lists.infradead.org; Fri, 28 Nov 2014 05:27:45 +0000 Received: by mail-pd0-f181.google.com with SMTP id v10so711100pde.40 for ; Thu, 27 Nov 2014 21:27:24 -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=aQjycDWwJE9S+3JV2VfW25MsNR5jlIdzgomq1smdmME=; b=WBPZqt7eEAq2D6AjooHrbhezU7fm2k3ARruD3Kd4iLdmJsJh9nLH8/V6ccZbtFKdJ0 FGEhjIC4H1SRDJWjBaCJ75HvswraoQqkXkM5plDAj96x00J7WEYtmnrstzmkj6rMLfX+ DLOzXRHqIw8yO23F+mGxfPxvJQO9rzBlT2ONziccetzuDFHAAW3SQCKCmtL8qG3Qr4Wi oTNQnXniXkZtDECnrbJMYol7ZYuPk4A4KQdXfN0TFFUQn4Elgejzb1GRh4zCsuFEklNC KZa/wWf08MfISMBsCtXFuehZ0pwcGoC8p3dnTr5VPA72cIVLpgpqyHhg0Fg31HMOvoqh Kisw== X-Gm-Message-State: ALoCoQnvqvwmQzhsRI1pPj8C98VSmTDTuXryWV535yJ4EE4Yz5uH9+NF4GgSODzU9RynkNJccG8+ X-Received: by 10.66.246.130 with SMTP id xw2mr29314336pac.55.1417152443760; Thu, 27 Nov 2014 21:27:23 -0800 (PST) Received: from localhost.localdomain (KD182249096114.au-net.ne.jp. [182.249.96.114]) by mx.google.com with ESMTPSA id kp2sm8661866pdb.30.2014.11.27.21.27.18 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 27 Nov 2014 21:27:22 -0800 (PST) From: AKASHI Takahiro To: keescook@chromium.org, catalin.marinas@arm.com, will.deacon@arm.com Subject: [PATCH v10 2/6] arm64: ptrace: allow tracer to skip a system call Date: Fri, 28 Nov 2014 14:26:35 +0900 Message-Id: <1417152399-32717-3-git-send-email-takahiro.akashi@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1417152399-32717-1-git-send-email-takahiro.akashi@linaro.org> References: <1417152399-32717-1-git-send-email-takahiro.akashi@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141127_212744_892330_A789C97F X-CRM114-Status: GOOD ( 10.12 ) 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 | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S index 726b910..5d6a399 100644 --- a/arch/arm64/kernel/entry.S +++ b/arch/arm64/kernel/entry.S @@ -668,8 +668,15 @@ ENDPROC(el0_svc) * switches, and waiting for our parent to respond. */ __sys_trace: - mov x0, sp + mov w0, #-1 // set default errno for + cmp scno, x0 // user-issued syscall(-1) + b.ne 1f + mov x0, #-ENOSYS + str x0, [sp, #S_X0] +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 @@ -683,7 +690,8 @@ __sys_trace: br x16 // call sys_* routine __sys_trace_return: - str x0, [sp] // save returned x0 + str x0, [sp, #S_X0] // save returned x0 +__sys_trace_return_skipped: mov x0, sp bl syscall_trace_exit b ret_to_user