Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4) #include <linux/audit.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5) #include <asm/unistd.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7) static unsigned dir_class[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8) #include <asm-generic/audit_dir_write.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) ~0U
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) static unsigned read_class[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <asm-generic/audit_read.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) ~0U
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) static unsigned write_class[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <asm-generic/audit_write.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) ~0U
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) static unsigned chattr_class[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #include <asm-generic/audit_change_attr.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) ~0U
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) static unsigned signal_class[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) #include <asm-generic/audit_signal.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) ~0U
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) int audit_classify_arch(int arch)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) #ifdef CONFIG_PPC64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) 	if (arch == AUDIT_ARCH_PPC)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) 		return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) int audit_classify_syscall(int abi, unsigned syscall)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) #ifdef CONFIG_PPC64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) 	extern int ppc32_classify_syscall(unsigned);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) 	if (abi == AUDIT_ARCH_PPC)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) 		return ppc32_classify_syscall(syscall);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) 	switch(syscall) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) 	case __NR_open:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) 		return 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) 	case __NR_openat:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) 		return 3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) 	case __NR_socketcall:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) 		return 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) 	case __NR_execve:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) 		return 5;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) static int __init audit_classes_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) #ifdef CONFIG_PPC64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) 	extern __u32 ppc32_dir_class[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) 	extern __u32 ppc32_write_class[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) 	extern __u32 ppc32_read_class[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) 	extern __u32 ppc32_chattr_class[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) 	extern __u32 ppc32_signal_class[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) 	audit_register_class(AUDIT_CLASS_WRITE_32, ppc32_write_class);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) 	audit_register_class(AUDIT_CLASS_READ_32, ppc32_read_class);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) 	audit_register_class(AUDIT_CLASS_DIR_WRITE_32, ppc32_dir_class);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) 	audit_register_class(AUDIT_CLASS_CHATTR_32, ppc32_chattr_class);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) 	audit_register_class(AUDIT_CLASS_SIGNAL_32, ppc32_signal_class);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) 	audit_register_class(AUDIT_CLASS_WRITE, write_class);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) 	audit_register_class(AUDIT_CLASS_READ, read_class);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) 	audit_register_class(AUDIT_CLASS_DIR_WRITE, dir_class);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) 	audit_register_class(AUDIT_CLASS_CHATTR, chattr_class);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) 	audit_register_class(AUDIT_CLASS_SIGNAL, signal_class);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) __initcall(audit_classes_init);