1b2441318SGreg Kroah-Hartman // SPDX-License-Identifier: GPL-2.0
2c0803799SAl Viro #include <linux/init.h>
3c0803799SAl Viro #include <linux/types.h>
4c0803799SAl Viro #include <linux/audit.h>
5c0803799SAl Viro #include <asm/unistd.h>
6c0803799SAl Viro
7*54f30b83SArnd Bergmann #include "audit_32.h"
8*54f30b83SArnd Bergmann
9c0803799SAl Viro static unsigned dir_class[] = {
10c0803799SAl Viro #include <asm-generic/audit_dir_write.h>
11c0803799SAl Viro ~0U
12c0803799SAl Viro };
13c0803799SAl Viro
14dc104fb3SAl Viro static unsigned read_class[] = {
15dc104fb3SAl Viro #include <asm-generic/audit_read.h>
16dc104fb3SAl Viro ~0U
17dc104fb3SAl Viro };
18dc104fb3SAl Viro
19dc104fb3SAl Viro static unsigned write_class[] = {
20dc104fb3SAl Viro #include <asm-generic/audit_write.h>
21dc104fb3SAl Viro ~0U
22dc104fb3SAl Viro };
23dc104fb3SAl Viro
24c0803799SAl Viro static unsigned chattr_class[] = {
25c0803799SAl Viro #include <asm-generic/audit_change_attr.h>
26c0803799SAl Viro ~0U
27c0803799SAl Viro };
28c0803799SAl Viro
297f13da40SAmy Griffis static unsigned signal_class[] = {
307f13da40SAmy Griffis #include <asm-generic/audit_signal.h>
317f13da40SAmy Griffis ~0U
327f13da40SAmy Griffis };
337f13da40SAmy Griffis
audit_classify_arch(int arch)34e54dc243SAmy Griffis int audit_classify_arch(int arch)
35e54dc243SAmy Griffis {
36e54dc243SAmy Griffis #ifdef CONFIG_PPC64
37e54dc243SAmy Griffis if (arch == AUDIT_ARCH_PPC)
38e54dc243SAmy Griffis return 1;
39e54dc243SAmy Griffis #endif
40e54dc243SAmy Griffis return 0;
41e54dc243SAmy Griffis }
42e54dc243SAmy Griffis
audit_classify_syscall(int abi,unsigned syscall)4355669bfaSAl Viro int audit_classify_syscall(int abi, unsigned syscall)
4455669bfaSAl Viro {
4555669bfaSAl Viro #ifdef CONFIG_PPC64
4655669bfaSAl Viro if (abi == AUDIT_ARCH_PPC)
4755669bfaSAl Viro return ppc32_classify_syscall(syscall);
4855669bfaSAl Viro #endif
4955669bfaSAl Viro switch(syscall) {
5055669bfaSAl Viro case __NR_open:
5142f355efSRichard Guy Briggs return AUDITSC_OPEN;
5255669bfaSAl Viro case __NR_openat:
5342f355efSRichard Guy Briggs return AUDITSC_OPENAT;
5455669bfaSAl Viro case __NR_socketcall:
5542f355efSRichard Guy Briggs return AUDITSC_SOCKETCALL;
5655669bfaSAl Viro case __NR_execve:
5742f355efSRichard Guy Briggs return AUDITSC_EXECVE;
581c30e3afSRichard Guy Briggs case __NR_openat2:
591c30e3afSRichard Guy Briggs return AUDITSC_OPENAT2;
6055669bfaSAl Viro default:
6142f355efSRichard Guy Briggs return AUDITSC_NATIVE;
6255669bfaSAl Viro }
6355669bfaSAl Viro }
6455669bfaSAl Viro
audit_classes_init(void)65c0803799SAl Viro static int __init audit_classes_init(void)
66c0803799SAl Viro {
67c0803799SAl Viro #ifdef CONFIG_PPC64
68c0803799SAl Viro extern __u32 ppc32_dir_class[];
69dc104fb3SAl Viro extern __u32 ppc32_write_class[];
70dc104fb3SAl Viro extern __u32 ppc32_read_class[];
71c0803799SAl Viro extern __u32 ppc32_chattr_class[];
727f13da40SAmy Griffis extern __u32 ppc32_signal_class[];
73dc104fb3SAl Viro audit_register_class(AUDIT_CLASS_WRITE_32, ppc32_write_class);
74dc104fb3SAl Viro audit_register_class(AUDIT_CLASS_READ_32, ppc32_read_class);
75c0803799SAl Viro audit_register_class(AUDIT_CLASS_DIR_WRITE_32, ppc32_dir_class);
76c0803799SAl Viro audit_register_class(AUDIT_CLASS_CHATTR_32, ppc32_chattr_class);
777f13da40SAmy Griffis audit_register_class(AUDIT_CLASS_SIGNAL_32, ppc32_signal_class);
78c0803799SAl Viro #endif
79dc104fb3SAl Viro audit_register_class(AUDIT_CLASS_WRITE, write_class);
80dc104fb3SAl Viro audit_register_class(AUDIT_CLASS_READ, read_class);
81c0803799SAl Viro audit_register_class(AUDIT_CLASS_DIR_WRITE, dir_class);
82c0803799SAl Viro audit_register_class(AUDIT_CLASS_CHATTR, chattr_class);
837f13da40SAmy Griffis audit_register_class(AUDIT_CLASS_SIGNAL, signal_class);
84c0803799SAl Viro return 0;
85c0803799SAl Viro }
86c0803799SAl Viro
87c0803799SAl Viro __initcall(audit_classes_init);
88