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: 3568221 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 45B74C02DC for ; Mon, 3 Feb 2014 06:59:45 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7996B201BA for ; Mon, 3 Feb 2014 06:59:44 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8A4E1201B9 for ; Mon, 3 Feb 2014 06:59:43 +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 1WADU0-0007p1-Mv; Mon, 03 Feb 2014 06:58:17 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WADTX-0007GZ-00; Mon, 03 Feb 2014 06:57:47 +0000 Received: from mail-pa0-f54.google.com ([209.85.220.54]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WADTR-0007BX-Kn for linux-arm-kernel@lists.infradead.org; Mon, 03 Feb 2014 06:57:43 +0000 Received: by mail-pa0-f54.google.com with SMTP id fa1so6695734pad.41 for ; Sun, 02 Feb 2014 22:57:20 -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=SeEG7Be9taaEqHRnUxIxltDMvkTGrEHHhXNiwS+rF3w=; b=cuxNr/nOo4eJBqqcSrA6rFPwsxHaTBtdysUu6NiBeldR+Nab1GRspTkXsse542pP/y /xveWWQn4G2HWGrgI27z7l3UFDQFUEE8CPlsSNpIdKkMZHQnn0uJVBhtGnP7079Ty99s i7BvFyi+/J0fVx27c7emb70gCHzC89+3UnMTDa3+dX4nQb5iqznCKf8HqlwJGbroD/9l v9KDbZHJrN+KniUIAD2Fx/g7MMKMTuruhz0enKwfm27LqLCF+PuUSjNHlFe8KAIqC7iA lieZqQ/CdEu5JK9t7MizpaRJ8hEZbhzj0CyUA3qEfp4m9oUTyoZiXddSHJz9z7w6bdrx wVBg== X-Gm-Message-State: ALoCoQnGTZMFBI/15fWEk2G1+o43h+Y6Ayv0+DINtKhGf9p7AxgJn61o9DbrU8SvoHcvJAbjjSMp 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 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140203_015741_849139_E120B052 X-CRM114-Status: GOOD ( 11.86 ) X-Spam-Score: -2.6 (--) Cc: linaro-kernel@lists.linaro.org, patches@linaro.org, arndb@arndb.de, linux-kernel@vger.kernel.org, AKASHI Takahiro , linux-audit@redhat.com, linux-arm-kernel@lists.infradead.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.7 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 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;