]> git.ipfire.org Git - thirdparty/linux.git/blame - lib/audit.c
btrfs: use u64 for buffer sizes in the tree search ioctls
[thirdparty/linux.git] / lib / audit.c
CommitLineData
b2441318 1// SPDX-License-Identifier: GPL-2.0
b915543b
AV
2#include <linux/init.h>
3#include <linux/types.h>
4#include <linux/audit.h>
5#include <asm/unistd.h>
6
7static unsigned dir_class[] = {
8#include <asm-generic/audit_dir_write.h>
9~0U
10};
11
dc104fb3
AV
12static unsigned read_class[] = {
13#include <asm-generic/audit_read.h>
14~0U
15};
16
17static unsigned write_class[] = {
18#include <asm-generic/audit_write.h>
19~0U
20};
21
b915543b
AV
22static unsigned chattr_class[] = {
23#include <asm-generic/audit_change_attr.h>
24~0U
25};
26
7f13da40
AG
27static unsigned signal_class[] = {
28#include <asm-generic/audit_signal.h>
29~0U
30};
31
e54dc243
AG
32int audit_classify_arch(int arch)
33{
4b588411
AT
34 if (audit_is_compat(arch))
35 return 1;
36 else
37 return 0;
e54dc243
AG
38}
39
55669bfa
AV
40int audit_classify_syscall(int abi, unsigned syscall)
41{
4b588411
AT
42 if (audit_is_compat(abi))
43 return audit_classify_compat_syscall(abi, syscall);
44
55669bfa 45 switch(syscall) {
aaeb012f 46#ifdef __NR_open
55669bfa 47 case __NR_open:
42f355ef 48 return AUDITSC_OPEN;
aaeb012f 49#endif
a83fbf63 50#ifdef __NR_openat
55669bfa 51 case __NR_openat:
42f355ef 52 return AUDITSC_OPENAT;
a83fbf63 53#endif
e65e1fc2 54#ifdef __NR_socketcall
55669bfa 55 case __NR_socketcall:
42f355ef 56 return AUDITSC_SOCKETCALL;
51f39a1f
DD
57#endif
58#ifdef __NR_execveat
59 case __NR_execveat:
e65e1fc2 60#endif
55669bfa 61 case __NR_execve:
42f355ef 62 return AUDITSC_EXECVE;
1c30e3af
RGB
63#ifdef __NR_openat2
64 case __NR_openat2:
65 return AUDITSC_OPENAT2;
66#endif
55669bfa 67 default:
42f355ef 68 return AUDITSC_NATIVE;
55669bfa
AV
69 }
70}
71
b915543b
AV
72static int __init audit_classes_init(void)
73{
4b588411
AT
74#ifdef CONFIG_AUDIT_COMPAT_GENERIC
75 audit_register_class(AUDIT_CLASS_WRITE_32, compat_write_class);
76 audit_register_class(AUDIT_CLASS_READ_32, compat_read_class);
77 audit_register_class(AUDIT_CLASS_DIR_WRITE_32, compat_dir_class);
78 audit_register_class(AUDIT_CLASS_CHATTR_32, compat_chattr_class);
79 audit_register_class(AUDIT_CLASS_SIGNAL_32, compat_signal_class);
80#endif
dc104fb3
AV
81 audit_register_class(AUDIT_CLASS_WRITE, write_class);
82 audit_register_class(AUDIT_CLASS_READ, read_class);
b915543b
AV
83 audit_register_class(AUDIT_CLASS_DIR_WRITE, dir_class);
84 audit_register_class(AUDIT_CLASS_CHATTR, chattr_class);
7f13da40 85 audit_register_class(AUDIT_CLASS_SIGNAL, signal_class);
b915543b
AV
86 return 0;
87}
88
89__initcall(audit_classes_init);