xref: /openbmc/linux/arch/ia64/kernel/audit.c (revision e54dc2431d740a79a6bd013babade99d71b1714f)
1b915543bSAl Viro #include <linux/init.h>
2b915543bSAl Viro #include <linux/types.h>
3b915543bSAl Viro #include <linux/audit.h>
4b915543bSAl Viro #include <asm/unistd.h>
5b915543bSAl Viro 
6b915543bSAl Viro static unsigned dir_class[] = {
7b915543bSAl Viro #include <asm-generic/audit_dir_write.h>
8b915543bSAl Viro ~0U
9b915543bSAl Viro };
10b915543bSAl Viro 
11dc104fb3SAl Viro static unsigned read_class[] = {
12dc104fb3SAl Viro #include <asm-generic/audit_read.h>
13dc104fb3SAl Viro ~0U
14dc104fb3SAl Viro };
15dc104fb3SAl Viro 
16dc104fb3SAl Viro static unsigned write_class[] = {
17dc104fb3SAl Viro #include <asm-generic/audit_write.h>
18dc104fb3SAl Viro ~0U
19dc104fb3SAl Viro };
20dc104fb3SAl Viro 
21b915543bSAl Viro static unsigned chattr_class[] = {
22b915543bSAl Viro #include <asm-generic/audit_change_attr.h>
23b915543bSAl Viro ~0U
24b915543bSAl Viro };
25b915543bSAl Viro 
267f13da40SAmy Griffis static unsigned signal_class[] = {
277f13da40SAmy Griffis #include <asm-generic/audit_signal.h>
287f13da40SAmy Griffis ~0U
297f13da40SAmy Griffis };
307f13da40SAmy Griffis 
31*e54dc243SAmy Griffis int audit_classify_arch(int arch)
32*e54dc243SAmy Griffis {
33*e54dc243SAmy Griffis #ifdef CONFIG_IA32_SUPPORT
34*e54dc243SAmy Griffis 	if (arch == AUDIT_ARCH_I386)
35*e54dc243SAmy Griffis 		return 1;
36*e54dc243SAmy Griffis #endif
37*e54dc243SAmy Griffis 	return 0;
38*e54dc243SAmy Griffis }
39*e54dc243SAmy Griffis 
4055669bfaSAl Viro int audit_classify_syscall(int abi, unsigned syscall)
4155669bfaSAl Viro {
4255669bfaSAl Viro #ifdef CONFIG_IA32_SUPPORT
4355669bfaSAl Viro 	extern int ia32_classify_syscall(unsigned);
4455669bfaSAl Viro 	if (abi == AUDIT_ARCH_I386)
4555669bfaSAl Viro 		return ia32_classify_syscall(syscall);
4655669bfaSAl Viro #endif
4755669bfaSAl Viro 	switch(syscall) {
4855669bfaSAl Viro 	case __NR_open:
4955669bfaSAl Viro 		return 2;
5055669bfaSAl Viro 	case __NR_openat:
5155669bfaSAl Viro 		return 3;
5255669bfaSAl Viro 	case __NR_execve:
5355669bfaSAl Viro 		return 5;
5455669bfaSAl Viro 	default:
5555669bfaSAl Viro 		return 0;
5655669bfaSAl Viro 	}
5755669bfaSAl Viro }
5855669bfaSAl Viro 
59b915543bSAl Viro static int __init audit_classes_init(void)
60b915543bSAl Viro {
61b915543bSAl Viro #ifdef CONFIG_IA32_SUPPORT
62b915543bSAl Viro 	extern __u32 ia32_dir_class[];
63dc104fb3SAl Viro 	extern __u32 ia32_write_class[];
64dc104fb3SAl Viro 	extern __u32 ia32_read_class[];
65b915543bSAl Viro 	extern __u32 ia32_chattr_class[];
667f13da40SAmy Griffis 	extern __u32 ia32_signal_class[];
67dc104fb3SAl Viro 	audit_register_class(AUDIT_CLASS_WRITE_32, ia32_write_class);
68dc104fb3SAl Viro 	audit_register_class(AUDIT_CLASS_READ_32, ia32_read_class);
69b915543bSAl Viro 	audit_register_class(AUDIT_CLASS_DIR_WRITE_32, ia32_dir_class);
70b915543bSAl Viro 	audit_register_class(AUDIT_CLASS_CHATTR_32, ia32_chattr_class);
717f13da40SAmy Griffis 	audit_register_class(AUDIT_CLASS_SIGNAL_32, ia32_signal_class);
72b915543bSAl Viro #endif
73dc104fb3SAl Viro 	audit_register_class(AUDIT_CLASS_WRITE, write_class);
74dc104fb3SAl Viro 	audit_register_class(AUDIT_CLASS_READ, read_class);
75b915543bSAl Viro 	audit_register_class(AUDIT_CLASS_DIR_WRITE, dir_class);
76b915543bSAl Viro 	audit_register_class(AUDIT_CLASS_CHATTR, chattr_class);
777f13da40SAmy Griffis 	audit_register_class(AUDIT_CLASS_SIGNAL, signal_class);
78b915543bSAl Viro 	return 0;
79b915543bSAl Viro }
80b915543bSAl Viro 
81b915543bSAl Viro __initcall(audit_classes_init);
82