1b2441318SGreg Kroah-Hartman // SPDX-License-Identifier: GPL-2.0
2e65e1fc2SAl Viro #include <linux/init.h>
3e65e1fc2SAl Viro #include <linux/types.h>
4e65e1fc2SAl Viro #include <linux/audit.h>
5e65e1fc2SAl Viro #include <asm/unistd.h>
6e65e1fc2SAl Viro
7e65e1fc2SAl Viro static unsigned dir_class[] = {
8e65e1fc2SAl Viro #include <asm-generic/audit_dir_write.h>
9e65e1fc2SAl Viro ~0U
10e65e1fc2SAl Viro };
11e65e1fc2SAl Viro
12e65e1fc2SAl Viro static unsigned read_class[] = {
13e65e1fc2SAl Viro #include <asm-generic/audit_read.h>
14e65e1fc2SAl Viro ~0U
15e65e1fc2SAl Viro };
16e65e1fc2SAl Viro
17e65e1fc2SAl Viro static unsigned write_class[] = {
18e65e1fc2SAl Viro #include <asm-generic/audit_write.h>
19e65e1fc2SAl Viro ~0U
20e65e1fc2SAl Viro };
21e65e1fc2SAl Viro
22e65e1fc2SAl Viro static unsigned chattr_class[] = {
23e65e1fc2SAl Viro #include <asm-generic/audit_change_attr.h>
24e65e1fc2SAl Viro ~0U
25e65e1fc2SAl Viro };
26e65e1fc2SAl Viro
277f13da40SAmy Griffis static unsigned signal_class[] = {
287f13da40SAmy Griffis #include <asm-generic/audit_signal.h>
297f13da40SAmy Griffis ~0U
307f13da40SAmy Griffis };
317f13da40SAmy Griffis
audit_classify_arch(int arch)32e54dc243SAmy Griffis int audit_classify_arch(int arch)
33e54dc243SAmy Griffis {
344b588411SAKASHI Takahiro if (audit_is_compat(arch))
354b588411SAKASHI Takahiro return 1;
364b588411SAKASHI Takahiro else
37e54dc243SAmy Griffis return 0;
38e54dc243SAmy Griffis }
39e54dc243SAmy Griffis
audit_classify_syscall(int abi,unsigned syscall)40e65e1fc2SAl Viro int audit_classify_syscall(int abi, unsigned syscall)
41e65e1fc2SAl Viro {
424b588411SAKASHI Takahiro if (audit_is_compat(abi))
434b588411SAKASHI Takahiro return audit_classify_compat_syscall(abi, syscall);
444b588411SAKASHI Takahiro
45e65e1fc2SAl Viro switch(syscall) {
46aaeb012fSChris Metcalf #ifdef __NR_open
47e65e1fc2SAl Viro case __NR_open:
4842f355efSRichard Guy Briggs return AUDITSC_OPEN;
49aaeb012fSChris Metcalf #endif
50a83fbf63SAl Viro #ifdef __NR_openat
51e65e1fc2SAl Viro case __NR_openat:
5242f355efSRichard Guy Briggs return AUDITSC_OPENAT;
53a83fbf63SAl Viro #endif
54e65e1fc2SAl Viro #ifdef __NR_socketcall
55e65e1fc2SAl Viro case __NR_socketcall:
5642f355efSRichard Guy Briggs return AUDITSC_SOCKETCALL;
57e65e1fc2SAl Viro #endif
5851f39a1fSDavid Drysdale #ifdef __NR_execveat
5951f39a1fSDavid Drysdale case __NR_execveat:
6051f39a1fSDavid Drysdale #endif
61e65e1fc2SAl Viro case __NR_execve:
6242f355efSRichard Guy Briggs return AUDITSC_EXECVE;
63*1c30e3afSRichard Guy Briggs #ifdef __NR_openat2
64*1c30e3afSRichard Guy Briggs case __NR_openat2:
65*1c30e3afSRichard Guy Briggs return AUDITSC_OPENAT2;
66*1c30e3afSRichard Guy Briggs #endif
67e65e1fc2SAl Viro default:
6842f355efSRichard Guy Briggs return AUDITSC_NATIVE;
69e65e1fc2SAl Viro }
70e65e1fc2SAl Viro }
71e65e1fc2SAl Viro
audit_classes_init(void)72e65e1fc2SAl Viro static int __init audit_classes_init(void)
73e65e1fc2SAl Viro {
744b588411SAKASHI Takahiro #ifdef CONFIG_AUDIT_COMPAT_GENERIC
754b588411SAKASHI Takahiro audit_register_class(AUDIT_CLASS_WRITE_32, compat_write_class);
764b588411SAKASHI Takahiro audit_register_class(AUDIT_CLASS_READ_32, compat_read_class);
774b588411SAKASHI Takahiro audit_register_class(AUDIT_CLASS_DIR_WRITE_32, compat_dir_class);
784b588411SAKASHI Takahiro audit_register_class(AUDIT_CLASS_CHATTR_32, compat_chattr_class);
794b588411SAKASHI Takahiro audit_register_class(AUDIT_CLASS_SIGNAL_32, compat_signal_class);
804b588411SAKASHI Takahiro #endif
81e65e1fc2SAl Viro audit_register_class(AUDIT_CLASS_WRITE, write_class);
82e65e1fc2SAl Viro audit_register_class(AUDIT_CLASS_READ, read_class);
83e65e1fc2SAl Viro audit_register_class(AUDIT_CLASS_DIR_WRITE, dir_class);
84e65e1fc2SAl Viro audit_register_class(AUDIT_CLASS_CHATTR, chattr_class);
857f13da40SAmy Griffis audit_register_class(AUDIT_CLASS_SIGNAL, signal_class);
86e65e1fc2SAl Viro return 0;
87e65e1fc2SAl Viro }
88e65e1fc2SAl Viro
89e65e1fc2SAl Viro __initcall(audit_classes_init);
90