[PATCH 4/5] x86: Use generic compat audit code

From: Brian Gerst
Date: Tue Mar 03 2015 - 22:32:28 EST


Use the generic compat syscall audit code instead of an x86 specific
implementation.

Signed-off-by: Brian Gerst <brgerst@xxxxxxxxx>
---
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 <asm/unistd_32.h>
-
-unsigned ia32_dir_class[] = {
-#include <asm-generic/audit_dir_write.h>
-~0U
-};
-
-unsigned ia32_chattr_class[] = {
-#include <asm-generic/audit_change_attr.h>
-~0U
-};
-
-unsigned ia32_write_class[] = {
-#include <asm-generic/audit_write.h>
-~0U
-};
-
-unsigned ia32_read_class[] = {
-#include <asm-generic/audit_read.h>
-~0U
-};
-
-unsigned ia32_signal_class[] = {
-#include <asm-generic/audit_signal.h>
-~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 <asm/unistd_32.h>
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 <linux/init.h>
-#include <linux/types.h>
-#include <linux/audit.h>
-#include <asm/unistd.h>
-
-static unsigned dir_class[] = {
-#include <asm-generic/audit_dir_write.h>
-~0U
-};
-
-static unsigned read_class[] = {
-#include <asm-generic/audit_read.h>
-~0U
-};
-
-static unsigned write_class[] = {
-#include <asm-generic/audit_write.h>
-~0U
-};
-
-static unsigned chattr_class[] = {
-#include <asm-generic/audit_change_attr.h>
-~0U
-};
-
-static unsigned signal_class[] = {
-#include <asm-generic/audit_signal.h>
-~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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/