All of lore.kernel.org
 help / color / mirror / Atom feed
From: Brian Gerst <brgerst@gmail.com>
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	[thread overview]
Message-ID: <1425439896-8322-5-git-send-email-brgerst@gmail.com> (raw)
In-Reply-To: <1425439896-8322-1-git-send-email-brgerst@gmail.com>

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

Signed-off-by: Brian Gerst <brgerst@gmail.com>
---
 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


  parent reply	other threads:[~2015-03-04  3:31 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-04  3:31 [PATCH 0/5] x86: IA32 emulation cleanups Brian Gerst
2015-03-04  3:31 ` [PATCH 1/5] x86: Remove compat_ni_syscall() Brian Gerst
2015-03-04  5:27   ` [tip:x86/asm] x86/compat: " tip-bot for Brian Gerst
2015-03-04  3:31 ` [PATCH 2/5] x86: Merge native and compat 32-bit syscall tables Brian Gerst
2015-03-04  5:27   ` [tip:x86/asm] x86/compat: " tip-bot for Brian Gerst
2015-03-04  3:31 ` [PATCH 3/5] x86: Remove sys32_vm86_warning Brian Gerst
2015-03-04  5:28   ` [tip:x86/asm] x86/compat: " tip-bot for Brian Gerst
2015-03-04  3:31 ` Brian Gerst [this message]
2015-03-04  5:14   ` [PATCH 4/5] x86: Use generic compat audit code Ingo Molnar
2015-03-04  6:39     ` Brian Gerst
2015-03-04  7:09       ` Ingo Molnar
2015-03-04 14:52       ` David Drysdale
2015-03-04  3:31 ` [PATCH 5/5] x86: Clean up ia32/Makefile Brian Gerst
2015-03-04  5:24 ` [PATCH 0/5] x86: IA32 emulation cleanups Ingo Molnar
2015-03-04  6:22   ` Brian Gerst
2015-03-05 22:38     ` H. Peter Anvin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1425439896-8322-5-git-send-email-brgerst@gmail.com \
    --to=brgerst@gmail.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.