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     if (audit_is_compat(arch))
0035         return 1;
0036     else
0037         return 0;
0038 }
0039 
0040 int audit_classify_syscall(int abi, unsigned syscall)
0041 {
0042     if (audit_is_compat(abi))
0043         return audit_classify_compat_syscall(abi, syscall);
0044 
0045     switch(syscall) {
0046 #ifdef __NR_open
0047     case __NR_open:
0048         return AUDITSC_OPEN;
0049 #endif
0050 #ifdef __NR_openat
0051     case __NR_openat:
0052         return AUDITSC_OPENAT;
0053 #endif
0054 #ifdef __NR_socketcall
0055     case __NR_socketcall:
0056         return AUDITSC_SOCKETCALL;
0057 #endif
0058 #ifdef __NR_execveat
0059     case __NR_execveat:
0060 #endif
0061     case __NR_execve:
0062         return AUDITSC_EXECVE;
0063 #ifdef __NR_openat2
0064     case __NR_openat2:
0065         return AUDITSC_OPENAT2;
0066 #endif
0067     default:
0068         return AUDITSC_NATIVE;
0069     }
0070 }
0071 
0072 static int __init audit_classes_init(void)
0073 {
0074 #ifdef CONFIG_AUDIT_COMPAT_GENERIC
0075     audit_register_class(AUDIT_CLASS_WRITE_32, compat_write_class);
0076     audit_register_class(AUDIT_CLASS_READ_32, compat_read_class);
0077     audit_register_class(AUDIT_CLASS_DIR_WRITE_32, compat_dir_class);
0078     audit_register_class(AUDIT_CLASS_CHATTR_32, compat_chattr_class);
0079     audit_register_class(AUDIT_CLASS_SIGNAL_32, compat_signal_class);
0080 #endif
0081     audit_register_class(AUDIT_CLASS_WRITE, write_class);
0082     audit_register_class(AUDIT_CLASS_READ, read_class);
0083     audit_register_class(AUDIT_CLASS_DIR_WRITE, dir_class);
0084     audit_register_class(AUDIT_CLASS_CHATTR, chattr_class);
0085     audit_register_class(AUDIT_CLASS_SIGNAL, signal_class);
0086     return 0;
0087 }
0088 
0089 __initcall(audit_classes_init);