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: 41660 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f71.google.com (mail-wg0-f71.google.com [74.125.82.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id BC6CA244C2 for ; Fri, 28 Nov 2014 05:27:36 +0000 (UTC) Received: by mail-wg0-f71.google.com with SMTP id l18sf3664137wgh.2 for ; Thu, 27 Nov 2014 21:27:36 -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: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=SLZPDGmPV1bHH+NFpwN3eEdP8tMfjSUWkZOq0c4XTio=; b=AYaq5IkgGpmVyLLnZdh/i1zUxHk4cGCeJHNFTPeptTswypotbg/2F6QMiHHXTrDvDn P5Y1iZrKt3mxehtyaoaqVlUvtEu3KjmBVQVwRBAZCPt0cS/aVFhJNjmmLqQqESL/FCC6 kV4gdWOUt+eetFM/+eL75Rpr2N/yJeIgdouzxGaZx90/VWRLxa1Flth0wVHty3B4Cx6T PsXTc9qPFjHB6b/JAcn9gjHyepMhu1OSlSwvO49nvigzS1HKvIJCxjW5Gg+nthqUUfEN N/L+9x3DZgiwESGJVYy/fE/lCuZjLjiYAp63UvtUhLD54OOtkZk+AoRAMGFThBGmfCk2 gLKw== X-Gm-Message-State: ALoCoQnecsWla2lCwGHKKWThhJ1bFkFvs4+ShrtHhbK9AYV2mVK31HKMiK2BI+FK6PJIrYI3WdFB X-Received: by 10.194.95.74 with SMTP id di10mr1953382wjb.0.1417152456089; Thu, 27 Nov 2014 21:27:36 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.27.9 with SMTP id p9ls920857lag.80.gmail; Thu, 27 Nov 2014 21:27:35 -0800 (PST) X-Received: by 10.112.45.228 with SMTP id q4mr42553425lbm.35.1417152455303; Thu, 27 Nov 2014 21:27:35 -0800 (PST) Received: from mail-la0-f53.google.com (mail-la0-f53.google.com. [209.85.215.53]) by mx.google.com with ESMTPS id dc7si8912807lad.91.2014.11.27.21.27.35 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 27 Nov 2014 21:27:35 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.53 as permitted sender) client-ip=209.85.215.53; Received: by mail-la0-f53.google.com with SMTP id gm9so5046525lab.26 for ; Thu, 27 Nov 2014 21:27:35 -0800 (PST) X-Received: by 10.112.14.69 with SMTP id n5mr41989956lbc.34.1417152455211; Thu, 27 Nov 2014 21:27:35 -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 ew9csp35172lbc; Thu, 27 Nov 2014 21:27:34 -0800 (PST) X-Received: by 10.70.138.37 with SMTP id qn5mr70593547pdb.118.1417152453436; Thu, 27 Nov 2014 21:27:33 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id kl5si14607027pdb.36.2014.11.27.21.27.32 for ; Thu, 27 Nov 2014 21:27:33 -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 S1751344AbaK1F11 (ORCPT + 26 others); Fri, 28 Nov 2014 00:27:27 -0500 Received: from mail-pa0-f52.google.com ([209.85.220.52]:51444 "EHLO mail-pa0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750910AbaK1F1Y (ORCPT ); Fri, 28 Nov 2014 00:27:24 -0500 Received: by mail-pa0-f52.google.com with SMTP id eu11so6136792pac.39 for ; Thu, 27 Nov 2014 21:27:24 -0800 (PST) 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 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 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> 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.215.53 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: , 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