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: 41515 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f71.google.com (mail-ee0-f71.google.com [74.125.83.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 5962725E18 for ; Wed, 26 Nov 2014 04:50:44 +0000 (UTC) Received: by mail-ee0-f71.google.com with SMTP id c13sf1445165eek.6 for ; Tue, 25 Nov 2014 20:50:43 -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=OKVPUCO27vsvQ9YAVbaaN1RJ1OCyABOiC5tSgEpcfaw=; b=lNUw5PDY5Z099yIRctqVXdlmCNO/HfqHMJPJ+2mxpUVcLbUotRW3gu/za9WdmWuixR +dYEhNY8X/M9p0ZInh4XRnGLYwKHt2LP7pgs9UUeMaUXYU/BrzzyamNrROuBzuF/mrBs q4MV8/e3pFTaIMimeLLeaAx+PhYV+0duVHw4SG0j+m870Yq7gCXdA4Ksu4lgsjoCQpoG 1Xc4GtE5jdkRZPEMiRJpHpWyRk/wFcSZKZCF7Y62P/O6/hFJLnsRVzwhkKDCAd6lK1+L N3QRPXzWIIsk2RPSAuqfAKfwwFXIZLejCJu3bJup++dKaqRwuMJaKe361yaKi4GCb5vv 1UCA== X-Gm-Message-State: ALoCoQmCgqv79vXo1217P9D8fPvbxLScZXhXVw72b8ijy5+D+S7LwZuUSpi4DPseLm6WruUB/NCJ X-Received: by 10.180.106.67 with SMTP id gs3mr6488954wib.3.1416977443549; Tue, 25 Nov 2014 20:50:43 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.5.202 with SMTP id u10ls528190lau.68.gmail; Tue, 25 Nov 2014 20:50:42 -0800 (PST) X-Received: by 10.152.20.72 with SMTP id l8mr32221035lae.43.1416977442915; Tue, 25 Nov 2014 20:50:42 -0800 (PST) Received: from mail-la0-f43.google.com (mail-la0-f43.google.com. [209.85.215.43]) by mx.google.com with ESMTPS id c1si3235204lbv.23.2014.11.25.20.50.42 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 25 Nov 2014 20:50:42 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.43 as permitted sender) client-ip=209.85.215.43; Received: by mail-la0-f43.google.com with SMTP id q1so1843532lam.16 for ; Tue, 25 Nov 2014 20:50:42 -0800 (PST) X-Received: by 10.152.6.228 with SMTP id e4mr31887604laa.71.1416977442802; Tue, 25 Nov 2014 20:50:42 -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 ew9csp567451lbc; Tue, 25 Nov 2014 20:50:41 -0800 (PST) X-Received: by 10.68.135.229 with SMTP id pv5mr50172785pbb.23.1416977441033; Tue, 25 Nov 2014 20:50:41 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id mt1si4971086pbb.128.2014.11.25.20.50.39 for ; Tue, 25 Nov 2014 20:50:41 -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 S1752397AbaKZEui (ORCPT + 26 others); Tue, 25 Nov 2014 23:50:38 -0500 Received: from mail-pa0-f49.google.com ([209.85.220.49]:33377 "EHLO mail-pa0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752369AbaKZEuf (ORCPT ); Tue, 25 Nov 2014 23:50:35 -0500 Received: by mail-pa0-f49.google.com with SMTP id eu11so2044925pac.8 for ; Tue, 25 Nov 2014 20:50:35 -0800 (PST) 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 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 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> 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.43 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 | 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