From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758188AbbCDDbv (ORCPT ); Tue, 3 Mar 2015 22:31:51 -0500 Received: from mail-yk0-f170.google.com ([209.85.160.170]:45584 "EHLO mail-yk0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758099AbbCDDbs (ORCPT ); Tue, 3 Mar 2015 22:31:48 -0500 From: Brian Gerst To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, mingo@kernel.org, hpa@zytor.com Subject: [PATCH 4/5] x86: Use generic compat audit code Date: Tue, 3 Mar 2015 22:31:35 -0500 Message-Id: <1425439896-8322-5-git-send-email-brgerst@gmail.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1425439896-8322-1-git-send-email-brgerst@gmail.com> References: <1425439896-8322-1-git-send-email-brgerst@gmail.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use the generic compat syscall audit code instead of an x86 specific implementation. Signed-off-by: Brian Gerst --- arch/x86/Kconfig | 5 +-- arch/x86/ia32/Makefile | 3 -- arch/x86/ia32/audit.c | 43 --------------------- arch/x86/include/asm/unistd32.h | 2 + arch/x86/kernel/Makefile | 2 - arch/x86/kernel/audit_64.c | 82 ----------------------------------------- 6 files changed, 3 insertions(+), 134 deletions(-) delete mode 100644 arch/x86/ia32/audit.c create mode 100644 arch/x86/include/asm/unistd32.h delete mode 100644 arch/x86/kernel/audit_64.c diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index c2fb8a8..ce75862 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -135,6 +135,7 @@ config X86 select HAVE_CC_STACKPROTECTOR select GENERIC_CPU_AUTOPROBE select HAVE_ARCH_AUDITSYSCALL + select AUDIT_ARCH_COMPAT_GENERIC select ARCH_SUPPORTS_ATOMIC_RMW select HAVE_ACPI_APEI if ACPI select HAVE_ACPI_APEI_NMI if ACPI @@ -238,10 +239,6 @@ config ZONE_DMA32 bool default X86_64 -config AUDIT_ARCH - bool - default X86_64 - config ARCH_SUPPORTS_OPTIMIZED_INLINING def_bool y diff --git a/arch/x86/ia32/Makefile b/arch/x86/ia32/Makefile index bb635c6..88ac1dd 100644 --- a/arch/x86/ia32/Makefile +++ b/arch/x86/ia32/Makefile @@ -5,6 +5,3 @@ obj-$(CONFIG_IA32_EMULATION) := ia32entry.o sys_ia32.o ia32_signal.o obj-$(CONFIG_IA32_AOUT) += ia32_aout.o - -audit-class-$(CONFIG_AUDIT) := audit.o -obj-$(CONFIG_IA32_EMULATION) += $(audit-class-y) diff --git a/arch/x86/ia32/audit.c b/arch/x86/ia32/audit.c deleted file mode 100644 index 2eccc89..0000000 --- a/arch/x86/ia32/audit.c +++ /dev/null @@ -1,43 +0,0 @@ -#include - -unsigned ia32_dir_class[] = { -#include -~0U -}; - -unsigned ia32_chattr_class[] = { -#include -~0U -}; - -unsigned ia32_write_class[] = { -#include -~0U -}; - -unsigned ia32_read_class[] = { -#include -~0U -}; - -unsigned ia32_signal_class[] = { -#include -~0U -}; - -int ia32_classify_syscall(unsigned syscall) -{ - switch (syscall) { - case __NR_open: - return 2; - case __NR_openat: - return 3; - case __NR_socketcall: - return 4; - case __NR_execve: - case __NR_execveat: - return 5; - default: - return 1; - } -} diff --git a/arch/x86/include/asm/unistd32.h b/arch/x86/include/asm/unistd32.h new file mode 100644 index 0000000..3653918 --- /dev/null +++ b/arch/x86/include/asm/unistd32.h @@ -0,0 +1,2 @@ +/* Generic code expects this header to be named unistd32.h */ +#include diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile index c887cd9..280eb3b 100644 --- a/arch/x86/kernel/Makefile +++ b/arch/x86/kernel/Makefile @@ -115,8 +115,6 @@ obj-$(CONFIG_PMC_ATOM) += pmc_atom.o ### # 64 bit specific files ifeq ($(CONFIG_X86_64),y) - obj-$(CONFIG_AUDIT) += audit_64.o - obj-$(CONFIG_GART_IOMMU) += amd_gart_64.o aperture_64.o obj-$(CONFIG_CALGARY_IOMMU) += pci-calgary_64.o tce_64.o diff --git a/arch/x86/kernel/audit_64.c b/arch/x86/kernel/audit_64.c deleted file mode 100644 index f367250..0000000 --- a/arch/x86/kernel/audit_64.c +++ /dev/null @@ -1,82 +0,0 @@ -#include -#include -#include -#include - -static unsigned dir_class[] = { -#include -~0U -}; - -static unsigned read_class[] = { -#include -~0U -}; - -static unsigned write_class[] = { -#include -~0U -}; - -static unsigned chattr_class[] = { -#include -~0U -}; - -static unsigned signal_class[] = { -#include -~0U -}; - -int audit_classify_arch(int arch) -{ -#ifdef CONFIG_IA32_EMULATION - if (arch == AUDIT_ARCH_I386) - return 1; -#endif - return 0; -} - -int audit_classify_syscall(int abi, unsigned syscall) -{ -#ifdef CONFIG_IA32_EMULATION - extern int ia32_classify_syscall(unsigned); - if (abi == AUDIT_ARCH_I386) - return ia32_classify_syscall(syscall); -#endif - switch(syscall) { - case __NR_open: - return 2; - case __NR_openat: - return 3; - case __NR_execve: - case __NR_execveat: - return 5; - default: - return 0; - } -} - -static int __init audit_classes_init(void) -{ -#ifdef CONFIG_IA32_EMULATION - extern __u32 ia32_dir_class[]; - extern __u32 ia32_write_class[]; - extern __u32 ia32_read_class[]; - extern __u32 ia32_chattr_class[]; - extern __u32 ia32_signal_class[]; - audit_register_class(AUDIT_CLASS_WRITE_32, ia32_write_class); - audit_register_class(AUDIT_CLASS_READ_32, ia32_read_class); - audit_register_class(AUDIT_CLASS_DIR_WRITE_32, ia32_dir_class); - audit_register_class(AUDIT_CLASS_CHATTR_32, ia32_chattr_class); - audit_register_class(AUDIT_CLASS_SIGNAL_32, ia32_signal_class); -#endif - audit_register_class(AUDIT_CLASS_WRITE, write_class); - audit_register_class(AUDIT_CLASS_READ, read_class); - audit_register_class(AUDIT_CLASS_DIR_WRITE, dir_class); - audit_register_class(AUDIT_CLASS_CHATTR, chattr_class); - audit_register_class(AUDIT_CLASS_SIGNAL, signal_class); - return 0; -} - -__initcall(audit_classes_init); -- 2.1.0