From patchwork Wed Nov 6 10:25:46 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 3146231 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 C22689F432 for ; Wed, 6 Nov 2013 10:29:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4937D20381 for ; Wed, 6 Nov 2013 10:29:06 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F075620454 for ; Wed, 6 Nov 2013 10:29:04 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Ve0Kr-0007kj-5p; Wed, 06 Nov 2013 10:27:41 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Ve0KQ-0002pr-FD; Wed, 06 Nov 2013 10:27:14 +0000 Received: from mail-pa0-f44.google.com ([209.85.220.44]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Ve0KI-0002me-CR for linux-arm-kernel@lists.infradead.org; Wed, 06 Nov 2013 10:27:08 +0000 Received: by mail-pa0-f44.google.com with SMTP id fb1so10367480pad.3 for ; Wed, 06 Nov 2013 02:26:44 -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=HR2/eNHbtIEQrHDIdTnCagZU/M09NmneAk8/NGRF6WM=; b=jlDg3OcUvGGDoQJbZSG6oiVhoDEbjVifERgryw+5UFUcKX6x0CgWF12qCXBgO0k4N8 BwhDiXrlceRwTPVPZvAyMeoeEoAe6eKaA5q88LKUgZjPjiXKwr6Or3XC6ROmRoGZ4Z3L FvulA8vIKAFQnAFC1P2RxlVZ1WamkWPGolskDKkVQHFk2jJf1mlJJbyuHJg9KLIa0TB8 XxPqUlKviOmevHJ79uNy0sYI6UZnc4vgeT42LJsTc18ut39pV2ABKZ+vGa0oko5k78/m sMzH4iW0dSpFbbVnOKusHg6A5QQ5EOtQZj3mFW3NmkAN7kaiEEB2wTuaSduUn+1ks1fN xLJQ== X-Gm-Message-State: ALoCoQnZKhRnkXqPFHXmibWqG3BB8b0+EFGSs35Q8TdEw3M44Paa67o6FgX5e8qmZfX59zckMvah X-Received: by 10.68.130.169 with SMTP id of9mr2461158pbb.79.1383733604624; Wed, 06 Nov 2013 02:26:44 -0800 (PST) Received: from localhost.localdomain (KD182249092064.au-net.ne.jp. [182.249.92.64]) by mx.google.com with ESMTPSA id qz9sm40405465pbc.3.2013.11.06.02.26.41 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 06 Nov 2013 02:26:43 -0800 (PST) From: AKASHI Takahiro To: catalin.marinas@arm.com, will.deacon@arm.com, linux-arm-kernel@lists.infradead.org, linux-audit@redhat.com Subject: [PATCH 4/4] arm64: audit: Add audit hook in ptrace/syscall_trace Date: Wed, 6 Nov 2013 19:25:46 +0900 Message-Id: <1383733546-2846-5-git-send-email-takahiro.akashi@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1383733546-2846-1-git-send-email-takahiro.akashi@linaro.org> References: <1383733546-2846-1-git-send-email-takahiro.akashi@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20131106_052706_605664_5D24176F X-CRM114-Status: GOOD ( 11.92 ) X-Spam-Score: -2.6 (--) Cc: AKASHI Takahiro , linaro-kernel@lists.linaro.org, patches@linaro.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 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=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, 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 --- arch/arm64/include/asm/thread_info.h | 1 + arch/arm64/kernel/entry.S | 3 +++ arch/arm64/kernel/ptrace.c | 12 ++++++++++++ 3 files changed, 16 insertions(+) diff --git a/arch/arm64/include/asm/thread_info.h b/arch/arm64/include/asm/thread_info.h index 23a3c47..782097a 100644 --- a/arch/arm64/include/asm/thread_info.h +++ b/arch/arm64/include/asm/thread_info.h @@ -107,6 +107,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 3881fd1..5bf1bdf 100644 --- a/arch/arm64/kernel/entry.S +++ b/arch/arm64/kernel/entry.S @@ -646,6 +646,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 fecdbf7..7cdfa76 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 @@ -1066,6 +1068,16 @@ asmlinkage int syscall_trace(int dir, struct pt_regs *regs) { unsigned long saved_reg; +#ifdef CONFIG_AUDITSYSCALL + if (dir) + audit_syscall_exit(regs); + else + audit_syscall_entry(syscall_get_arch(current, regs), + regs->syscallno, + regs->regs[0], regs->regs[1], + regs->regs[2], regs->regs[3]); +#endif /* CONFIG_AUDITSYSCALL */ + if (!test_thread_flag(TIF_SYSCALL_TRACE)) return regs->syscallno;