From patchwork Mon Feb 3 06:56:30 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 24027 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qc0-f200.google.com (mail-qc0-f200.google.com [209.85.216.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D668020675 for ; Mon, 3 Feb 2014 06:57:22 +0000 (UTC) Received: by mail-qc0-f200.google.com with SMTP id e9sf17147699qcy.3 for ; Sun, 02 Feb 2014 22:57:21 -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:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=SeEG7Be9taaEqHRnUxIxltDMvkTGrEHHhXNiwS+rF3w=; b=OFCBmZwDj8nzFlc2hokQF26VRp/X+EZegcGReD052lWVKWIJL7ecdLb7gVmRKmQEVS /OwaFOuZ7E6Q5kWJ/ZfhNvxf38r9LtLZxbHSGZ93Draht8i31S+3KKkIFffbatnAbk4E 1k79GBpNDybkXSLcve3+MxFJ/rAFJX5b2PI7BQjv0/zddTjcFOPWP+XfaaGZV3LcGdc3 FNRPJ/FyqYOpDKUqhhfHnF0jV1UfmmYYpb8rdKHqEDy7bPvFVirg5UPq2kQfhRgoNWfS mENxdPv9leiqb7v/boMfSjAX+Se2OmEEpkgAaNhYxebDuKhap6f9uQnFK6uhA1xzJoSe bUGA== X-Gm-Message-State: ALoCoQkDvY3T498zzw8+EuopufilUc40oMYhJn1c8t1u5GvOS4cfJTx2NjiMlmenOY5SB01DLdfa X-Received: by 10.52.53.73 with SMTP id z9mr11502094vdo.4.1391410641865; Sun, 02 Feb 2014 22:57:21 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.21.136 with SMTP id 8ls1757143qgl.27.gmail; Sun, 02 Feb 2014 22:57:21 -0800 (PST) X-Received: by 10.220.95.139 with SMTP id d11mr3591947vcn.21.1391410641803; Sun, 02 Feb 2014 22:57:21 -0800 (PST) Received: from mail-vc0-f182.google.com (mail-vc0-f182.google.com [209.85.220.182]) by mx.google.com with ESMTPS id kl10si6552723vdb.155.2014.02.02.22.57.21 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 02 Feb 2014 22:57:21 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.182 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.182; Received: by mail-vc0-f182.google.com with SMTP id id10so4592784vcb.27 for ; Sun, 02 Feb 2014 22:57:21 -0800 (PST) X-Received: by 10.58.227.38 with SMTP id rx6mr28077122vec.10.1391410641736; Sun, 02 Feb 2014 22:57:21 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp136222vcz; Sun, 2 Feb 2014 22:57:21 -0800 (PST) X-Received: by 10.68.180.66 with SMTP id dm2mr5566503pbc.143.1391410640581; Sun, 02 Feb 2014 22:57:20 -0800 (PST) Received: from mail-pd0-f176.google.com (mail-pd0-f176.google.com [209.85.192.176]) by mx.google.com with ESMTPS id xu6si19340870pab.341.2014.02.02.22.57.20 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 02 Feb 2014 22:57:20 -0800 (PST) Received-SPF: neutral (google.com: 209.85.192.176 is neither permitted nor denied by best guess record for domain of takahiro.akashi@linaro.org) client-ip=209.85.192.176; Received: by mail-pd0-f176.google.com with SMTP id w10so6518866pde.7 for ; Sun, 02 Feb 2014 22:57:20 -0800 (PST) X-Received: by 10.66.150.69 with SMTP id ug5mr35456194pab.55.1391410640158; Sun, 02 Feb 2014 22:57:20 -0800 (PST) Received: from localhost.localdomain (KD182249091062.au-net.ne.jp. [182.249.91.62]) by mx.google.com with ESMTPSA id hb10sm52674868pbd.1.2014.02.02.22.57.15 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 02 Feb 2014 22:57:19 -0800 (PST) From: AKASHI Takahiro To: viro@zeniv.linux.org.uk, eparis@redhat.com, rgb@redhat.com, catalin.marinas@arm.com, will.deacon@arm.com Cc: arndb@arndb.de, linux-arm-kernel@lists.infradead.org, linaro-kernel@lists.linaro.org, linux-kernel@vger.kernel.org, linux-audit@redhat.com, patches@linaro.org, AKASHI Takahiro Subject: [PATCH v3 3/3] arm64: audit: Add audit hook in ptrace/syscall_trace Date: Mon, 3 Feb 2014 15:56:30 +0900 Message-Id: <1391410590-4884-4-git-send-email-takahiro.akashi@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1391410590-4884-1-git-send-email-takahiro.akashi@linaro.org> References: <1389946399-4525-1-git-send-email-takahiro.akashi@linaro.org> <1391410590-4884-1-git-send-email-takahiro.akashi@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: takahiro.akashi@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.182 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , This patch adds auditing functions on entry to or exit from every system call invocation. Signed-off-by: AKASHI Takahiro --- arch/arm64/include/asm/thread_info.h | 1 + arch/arm64/kernel/entry.S | 3 +++ arch/arm64/kernel/ptrace.c | 10 ++++++++++ 3 files changed, 14 insertions(+) diff --git a/arch/arm64/include/asm/thread_info.h b/arch/arm64/include/asm/thread_info.h index 720e70b..7468388 100644 --- a/arch/arm64/include/asm/thread_info.h +++ b/arch/arm64/include/asm/thread_info.h @@ -101,6 +101,7 @@ static inline struct thread_info *current_thread_info(void) #define TIF_NEED_RESCHED 1 #define TIF_NOTIFY_RESUME 2 /* callback before returning to user */ #define TIF_SYSCALL_TRACE 8 +#define TIF_SYSCALL_AUDIT 9 #define TIF_POLLING_NRFLAG 16 #define TIF_MEMDIE 18 /* is terminating due to OOM killer */ #define TIF_FREEZE 19 diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S index 827cbad..83c4b29 100644 --- a/arch/arm64/kernel/entry.S +++ b/arch/arm64/kernel/entry.S @@ -630,6 +630,9 @@ el0_svc_naked: // compat entry point get_thread_info tsk ldr x16, [tsk, #TI_FLAGS] // check for syscall tracing tbnz x16, #TIF_SYSCALL_TRACE, __sys_trace // are we tracing syscalls? +#ifdef CONFIG_AUDITSYSCALL + tbnz x16, #TIF_SYSCALL_AUDIT, __sys_trace // auditing syscalls? +#endif adr lr, ret_fast_syscall // return address cmp scno, sc_nr // check upper syscall limit b.hs ni_sys diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c index 6777a21..75a3f23 100644 --- a/arch/arm64/kernel/ptrace.c +++ b/arch/arm64/kernel/ptrace.c @@ -19,6 +19,7 @@ * along with this program. If not, see . */ +#include #include #include #include @@ -38,6 +39,7 @@ #include #include #include +#include #include #include @@ -1064,6 +1066,14 @@ asmlinkage int syscall_trace(int dir, struct pt_regs *regs) { unsigned long saved_reg; + if (dir) + audit_syscall_exit(regs); + else + audit_syscall_entry(syscall_get_arch(current, regs), + (int)regs->syscallno, + regs->orig_x0, regs->regs[1], + regs->regs[2], regs->regs[3]); + if (!test_thread_flag(TIF_SYSCALL_TRACE)) return regs->syscallno;