xref: /linux/lib/audit.c (revision 51f39a1f0cea1cacf8c787f652f26dfee9611874)
1e65e1fc2SAl Viro #include <linux/init.h>
2e65e1fc2SAl Viro #include <linux/types.h>
3e65e1fc2SAl Viro #include <linux/audit.h>
4e65e1fc2SAl Viro #include <asm/unistd.h>
5e65e1fc2SAl Viro 
6e65e1fc2SAl Viro static unsigned dir_class[] = {
7e65e1fc2SAl Viro #include <asm-generic/audit_dir_write.h>
8e65e1fc2SAl Viro ~0U
9e65e1fc2SAl Viro };
10e65e1fc2SAl Viro 
11e65e1fc2SAl Viro static unsigned read_class[] = {
12e65e1fc2SAl Viro #include <asm-generic/audit_read.h>
13e65e1fc2SAl Viro ~0U
14e65e1fc2SAl Viro };
15e65e1fc2SAl Viro 
16e65e1fc2SAl Viro static unsigned write_class[] = {
17e65e1fc2SAl Viro #include <asm-generic/audit_write.h>
18e65e1fc2SAl Viro ~0U
19e65e1fc2SAl Viro };
20e65e1fc2SAl Viro 
21e65e1fc2SAl Viro static unsigned chattr_class[] = {
22e65e1fc2SAl Viro #include <asm-generic/audit_change_attr.h>
23e65e1fc2SAl Viro ~0U
24e65e1fc2SAl Viro };
25e65e1fc2SAl Viro 
267f13da40SAmy Griffis static unsigned signal_class[] = {
277f13da40SAmy Griffis #include <asm-generic/audit_signal.h>
287f13da40SAmy Griffis ~0U
297f13da40SAmy Griffis };
307f13da40SAmy Griffis 
31e54dc243SAmy Griffis int audit_classify_arch(int arch)
32e54dc243SAmy Griffis {
334b588411SAKASHI Takahiro 	if (audit_is_compat(arch))
344b588411SAKASHI Takahiro 		return 1;
354b588411SAKASHI Takahiro 	else
36e54dc243SAmy Griffis 		return 0;
37e54dc243SAmy Griffis }
38e54dc243SAmy Griffis 
39e65e1fc2SAl Viro int audit_classify_syscall(int abi, unsigned syscall)
40e65e1fc2SAl Viro {
414b588411SAKASHI Takahiro 	if (audit_is_compat(abi))
424b588411SAKASHI Takahiro 		return audit_classify_compat_syscall(abi, syscall);
434b588411SAKASHI Takahiro 
44e65e1fc2SAl Viro 	switch(syscall) {
45aaeb012fSChris Metcalf #ifdef __NR_open
46e65e1fc2SAl Viro 	case __NR_open:
47e65e1fc2SAl Viro 		return 2;
48aaeb012fSChris Metcalf #endif
49a83fbf63SAl Viro #ifdef __NR_openat
50e65e1fc2SAl Viro 	case __NR_openat:
51e65e1fc2SAl Viro 		return 3;
52a83fbf63SAl Viro #endif
53e65e1fc2SAl Viro #ifdef __NR_socketcall
54e65e1fc2SAl Viro 	case __NR_socketcall:
55e65e1fc2SAl Viro 		return 4;
56e65e1fc2SAl Viro #endif
57*51f39a1fSDavid Drysdale #ifdef __NR_execveat
58*51f39a1fSDavid Drysdale 	case __NR_execveat:
59*51f39a1fSDavid Drysdale #endif
60e65e1fc2SAl Viro 	case __NR_execve:
61e65e1fc2SAl Viro 		return 5;
62e65e1fc2SAl Viro 	default:
63e65e1fc2SAl Viro 		return 0;
64e65e1fc2SAl Viro 	}
65e65e1fc2SAl Viro }
66e65e1fc2SAl Viro 
67e65e1fc2SAl Viro static int __init audit_classes_init(void)
68e65e1fc2SAl Viro {
694b588411SAKASHI Takahiro #ifdef CONFIG_AUDIT_COMPAT_GENERIC
704b588411SAKASHI Takahiro 	audit_register_class(AUDIT_CLASS_WRITE_32, compat_write_class);
714b588411SAKASHI Takahiro 	audit_register_class(AUDIT_CLASS_READ_32, compat_read_class);
724b588411SAKASHI Takahiro 	audit_register_class(AUDIT_CLASS_DIR_WRITE_32, compat_dir_class);
734b588411SAKASHI Takahiro 	audit_register_class(AUDIT_CLASS_CHATTR_32, compat_chattr_class);
744b588411SAKASHI Takahiro 	audit_register_class(AUDIT_CLASS_SIGNAL_32, compat_signal_class);
754b588411SAKASHI Takahiro #endif
76e65e1fc2SAl Viro 	audit_register_class(AUDIT_CLASS_WRITE, write_class);
77e65e1fc2SAl Viro 	audit_register_class(AUDIT_CLASS_READ, read_class);
78e65e1fc2SAl Viro 	audit_register_class(AUDIT_CLASS_DIR_WRITE, dir_class);
79e65e1fc2SAl Viro 	audit_register_class(AUDIT_CLASS_CHATTR, chattr_class);
807f13da40SAmy Griffis 	audit_register_class(AUDIT_CLASS_SIGNAL, signal_class);
81e65e1fc2SAl Viro 	return 0;
82e65e1fc2SAl Viro }
83e65e1fc2SAl Viro 
84e65e1fc2SAl Viro __initcall(audit_classes_init);
85