Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 #include <linux/init.h>
0003 #include <linux/types.h>
0004 #include <linux/audit.h>
0005 #include <asm/unistd.h>
0006 
0007 static unsigned dir_class[] = {
0008 #include <asm-generic/audit_dir_write.h>
0009 ~0U
0010 };
0011 
0012 static unsigned read_class[] = {
0013 #include <asm-generic/audit_read.h>
0014 ~0U
0015 };
0016 
0017 static unsigned write_class[] = {
0018 #include <asm-generic/audit_write.h>
0019 ~0U
0020 };
0021 
0022 static unsigned chattr_class[] = {
0023 #include <asm-generic/audit_change_attr.h>
0024 ~0U
0025 };
0026 
0027 static unsigned signal_class[] = {
0028 #include <asm-generic/audit_signal.h>
0029 ~0U
0030 };
0031 
0032 int audit_classify_arch(int arch)
0033 {
0034 #ifdef CONFIG_PPC64
0035     if (arch == AUDIT_ARCH_PPC)
0036         return 1;
0037 #endif
0038     return 0;
0039 }
0040 
0041 int audit_classify_syscall(int abi, unsigned syscall)
0042 {
0043 #ifdef CONFIG_PPC64
0044     extern int ppc32_classify_syscall(unsigned);
0045     if (abi == AUDIT_ARCH_PPC)
0046         return ppc32_classify_syscall(syscall);
0047 #endif
0048     switch(syscall) {
0049     case __NR_open:
0050         return AUDITSC_OPEN;
0051     case __NR_openat:
0052         return AUDITSC_OPENAT;
0053     case __NR_socketcall:
0054         return AUDITSC_SOCKETCALL;
0055     case __NR_execve:
0056         return AUDITSC_EXECVE;
0057     case __NR_openat2:
0058         return AUDITSC_OPENAT2;
0059     default:
0060         return AUDITSC_NATIVE;
0061     }
0062 }
0063 
0064 static int __init audit_classes_init(void)
0065 {
0066 #ifdef CONFIG_PPC64
0067     extern __u32 ppc32_dir_class[];
0068     extern __u32 ppc32_write_class[];
0069     extern __u32 ppc32_read_class[];
0070     extern __u32 ppc32_chattr_class[];
0071     extern __u32 ppc32_signal_class[];
0072     audit_register_class(AUDIT_CLASS_WRITE_32, ppc32_write_class);
0073     audit_register_class(AUDIT_CLASS_READ_32, ppc32_read_class);
0074     audit_register_class(AUDIT_CLASS_DIR_WRITE_32, ppc32_dir_class);
0075     audit_register_class(AUDIT_CLASS_CHATTR_32, ppc32_chattr_class);
0076     audit_register_class(AUDIT_CLASS_SIGNAL_32, ppc32_signal_class);
0077 #endif
0078     audit_register_class(AUDIT_CLASS_WRITE, write_class);
0079     audit_register_class(AUDIT_CLASS_READ, read_class);
0080     audit_register_class(AUDIT_CLASS_DIR_WRITE, dir_class);
0081     audit_register_class(AUDIT_CLASS_CHATTR, chattr_class);
0082     audit_register_class(AUDIT_CLASS_SIGNAL, signal_class);
0083     return 0;
0084 }
0085 
0086 __initcall(audit_classes_init);