From patchwork Tue Aug 21 08:27:35 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Deacon X-Patchwork-Id: 1352701 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id 19910DFB34 for ; Tue, 21 Aug 2012 08:31:43 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1T3joW-00070h-On; Tue, 21 Aug 2012 08:27:52 +0000 Received: from cam-admin0.cambridge.arm.com ([217.140.96.50]) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1T3joS-0006zd-GP for linux-arm-kernel@lists.infradead.org; Tue, 21 Aug 2012 08:27:49 +0000 Received: from mudshark.cambridge.arm.com (mudshark.cambridge.arm.com [10.1.79.58]) by cam-admin0.cambridge.arm.com (8.12.6/8.12.6) with ESMTP id q7L8RcE7006207; Tue, 21 Aug 2012 09:27:38 +0100 (BST) Date: Tue, 21 Aug 2012 09:27:35 +0100 From: Will Deacon To: Wade Farnsworth Subject: Re: [PATCH v3] ARM: support syscall tracing Message-ID: <20120821082734.GA28660@mudshark.cambridge.arm.com> References: <50324BED.9000500@mentor.com> <20120820172559.GW25864@mudshark.cambridge.arm.com> <5032A1D6.6010605@mentor.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <5032A1D6.6010605@mentor.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Spam-Note: CRM114 invocation failed X-Spam-Score: -7.1 (-------) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-7.1 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high trust [217.140.96.50 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.2 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Russell King - ARM Linux , "linux-arm-kernel@lists.infradead.org" X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org On Mon, Aug 20, 2012 at 09:45:10PM +0100, Wade Farnsworth wrote: > Will Deacon wrote: > > > > I think that trace_sys_{enter,exit} should take ret rather than scno. A > > debugger could change the syscall number if TIF_SYSCALL_TRACE is set and > > that new number should be the one that we use. > > > > The style, however, is much better and I think the code is fairly clear now > > so we just need to wait for my fix to the core code to get merged (it got > > picked up by Steve Rostedt) and I think we can use ret directly. It might be > > worth dropping the local variable and using scno for everything, so that > > it's obvious where the syscall number is stored. > > > > I agree that your patch needs to get merged before mine gets picked up > so that we don't introduce a new bug. I've sent v4 with the changes you > suggest. Would you like me to modify syscall_trace_* to remove the > local variable in this patch as well? It seems to me that such a rework > is better handled separately, but let me know if you think otherwise. Don't worry about the scno rework -- I'll do that as a separate patch because I think that the audit calls need updating to use the return value from ptrace_syscall_trace too (otherwise you could use a debugger to execute syscalls that you shouldn't be allowed to make). So, if it's ok with you, I'll take this into my tree and then send it to Russell along with the scno change once the core fix has been merged into mainline. Cheers, Will --- >8 diff --git a/arch/arm/kernel/ptrace.c b/arch/arm/kernel/ptrace.c index 3e0fc5f..90396a6 100644 --- a/arch/arm/kernel/ptrace.c +++ b/arch/arm/kernel/ptrace.c @@ -941,15 +941,15 @@ static int ptrace_syscall_trace(struct pt_regs *regs, int scno, asmlinkage int syscall_trace_enter(struct pt_regs *regs, int scno) { - int ret = ptrace_syscall_trace(regs, scno, PTRACE_SYSCALL_ENTER); + scno = ptrace_syscall_trace(regs, scno, PTRACE_SYSCALL_ENTER); audit_syscall_entry(AUDIT_ARCH_ARM, scno, regs->ARM_r0, regs->ARM_r1, regs->ARM_r2, regs->ARM_r3); - return ret; + return scno; } asmlinkage int syscall_trace_exit(struct pt_regs *regs, int scno) { - int ret = ptrace_syscall_trace(regs, scno, PTRACE_SYSCALL_EXIT); + scno = ptrace_syscall_trace(regs, scno, PTRACE_SYSCALL_EXIT); audit_syscall_exit(regs); - return ret; + return scno; }