blob: 44c3601cfdc45d65d75e4a440f1a0a01a83df0c2 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001// SPDX-License-Identifier: GPL-2.0
Al Virob9155432006-07-01 03:56:16 -04002#include <linux/init.h>
3#include <linux/types.h>
4#include <linux/audit.h>
5#include <asm/unistd.h>
Benjamin Thiel0e5e3d42020-05-16 14:38:16 +02006#include <asm/audit.h>
Al Virob9155432006-07-01 03:56:16 -04007
8static unsigned dir_class[] = {
9#include <asm-generic/audit_dir_write.h>
10~0U
11};
12
Al Virodc104fb2006-08-31 19:05:56 -040013static unsigned read_class[] = {
14#include <asm-generic/audit_read.h>
15~0U
16};
17
18static unsigned write_class[] = {
19#include <asm-generic/audit_write.h>
20~0U
21};
22
Al Virob9155432006-07-01 03:56:16 -040023static unsigned chattr_class[] = {
24#include <asm-generic/audit_change_attr.h>
25~0U
26};
27
Amy Griffis7f13da42007-03-29 18:00:37 -040028static unsigned signal_class[] = {
29#include <asm-generic/audit_signal.h>
30~0U
31};
32
Amy Griffise54dc242007-03-29 18:01:04 -040033int audit_classify_arch(int arch)
34{
35#ifdef CONFIG_IA32_EMULATION
36 if (arch == AUDIT_ARCH_I386)
37 return 1;
38#endif
39 return 0;
40}
41
Al Viro55669bf2006-08-31 19:26:40 -040042int audit_classify_syscall(int abi, unsigned syscall)
43{
44#ifdef CONFIG_IA32_EMULATION
Al Viro55669bf2006-08-31 19:26:40 -040045 if (abi == AUDIT_ARCH_I386)
46 return ia32_classify_syscall(syscall);
47#endif
48 switch(syscall) {
49 case __NR_open:
Richard Guy Briggs42f355e2021-05-19 16:00:20 -040050 return AUDITSC_OPEN;
Al Viro55669bf2006-08-31 19:26:40 -040051 case __NR_openat:
Richard Guy Briggs42f355e2021-05-19 16:00:20 -040052 return AUDITSC_OPENAT;
Al Viro55669bf2006-08-31 19:26:40 -040053 case __NR_execve:
David Drysdale27d6ec72014-12-12 16:57:33 -080054 case __NR_execveat:
Richard Guy Briggs42f355e2021-05-19 16:00:20 -040055 return AUDITSC_EXECVE;
Richard Guy Briggs1c30e3a2021-05-19 16:00:21 -040056 case __NR_openat2:
57 return AUDITSC_OPENAT2;
Al Viro55669bf2006-08-31 19:26:40 -040058 default:
Richard Guy Briggs42f355e2021-05-19 16:00:20 -040059 return AUDITSC_NATIVE;
Al Viro55669bf2006-08-31 19:26:40 -040060 }
61}
62
Al Virob9155432006-07-01 03:56:16 -040063static int __init audit_classes_init(void)
64{
65#ifdef CONFIG_IA32_EMULATION
66 extern __u32 ia32_dir_class[];
Al Virodc104fb2006-08-31 19:05:56 -040067 extern __u32 ia32_write_class[];
68 extern __u32 ia32_read_class[];
Al Virob9155432006-07-01 03:56:16 -040069 extern __u32 ia32_chattr_class[];
Amy Griffis7f13da42007-03-29 18:00:37 -040070 extern __u32 ia32_signal_class[];
Al Virodc104fb2006-08-31 19:05:56 -040071 audit_register_class(AUDIT_CLASS_WRITE_32, ia32_write_class);
72 audit_register_class(AUDIT_CLASS_READ_32, ia32_read_class);
Al Virob9155432006-07-01 03:56:16 -040073 audit_register_class(AUDIT_CLASS_DIR_WRITE_32, ia32_dir_class);
74 audit_register_class(AUDIT_CLASS_CHATTR_32, ia32_chattr_class);
Amy Griffis7f13da42007-03-29 18:00:37 -040075 audit_register_class(AUDIT_CLASS_SIGNAL_32, ia32_signal_class);
Al Virob9155432006-07-01 03:56:16 -040076#endif
Al Virodc104fb2006-08-31 19:05:56 -040077 audit_register_class(AUDIT_CLASS_WRITE, write_class);
78 audit_register_class(AUDIT_CLASS_READ, read_class);
Al Virob9155432006-07-01 03:56:16 -040079 audit_register_class(AUDIT_CLASS_DIR_WRITE, dir_class);
80 audit_register_class(AUDIT_CLASS_CHATTR, chattr_class);
Amy Griffis7f13da42007-03-29 18:00:37 -040081 audit_register_class(AUDIT_CLASS_SIGNAL, signal_class);
Al Virob9155432006-07-01 03:56:16 -040082 return 0;
83}
84
85__initcall(audit_classes_init);