1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24#ifndef _LINUX_AUDIT_H_
25#define _LINUX_AUDIT_H_
26
27
28#define AUDIT_GET 1000
29#define AUDIT_SET 1001
30#define AUDIT_LIST 1002
31#define AUDIT_ADD 1003
32#define AUDIT_DEL 1004
33#define AUDIT_USER 1005
34#define AUDIT_LOGIN 1006
35#define AUDIT_KERNEL 2000
36
37
38#define AUDIT_PER_TASK 0x01
39#define AUDIT_AT_ENTRY 0x02
40#define AUDIT_AT_EXIT 0x04
41#define AUDIT_PREPEND 0x10
42
43
44#define AUDIT_NEVER 0
45#define AUDIT_POSSIBLE 1
46#define AUDIT_ALWAYS 2
47
48
49
50#define AUDIT_MAX_FIELDS 64
51#define AUDIT_BITMASK_SIZE 64
52#define AUDIT_WORD(nr) ((__u32)((nr)/32))
53#define AUDIT_BIT(nr) (1 << ((nr) - AUDIT_WORD(nr)*32))
54
55
56
57
58
59#define AUDIT_PID 0
60#define AUDIT_UID 1
61#define AUDIT_EUID 2
62#define AUDIT_SUID 3
63#define AUDIT_FSUID 4
64#define AUDIT_GID 5
65#define AUDIT_EGID 6
66#define AUDIT_SGID 7
67#define AUDIT_FSGID 8
68#define AUDIT_LOGINUID 9
69#define AUDIT_PERS 10
70
71
72
73#define AUDIT_DEVMAJOR 100
74#define AUDIT_DEVMINOR 101
75#define AUDIT_INODE 102
76#define AUDIT_EXIT 103
77#define AUDIT_SUCCESS 104
78
79#define AUDIT_ARG0 200
80#define AUDIT_ARG1 (AUDIT_ARG0+1)
81#define AUDIT_ARG2 (AUDIT_ARG0+2)
82#define AUDIT_ARG3 (AUDIT_ARG0+3)
83
84#define AUDIT_NEGATE 0x80000000
85
86
87
88
89#define AUDIT_STATUS_ENABLED 0x0001
90#define AUDIT_STATUS_FAILURE 0x0002
91#define AUDIT_STATUS_PID 0x0004
92#define AUDIT_STATUS_RATE_LIMIT 0x0008
93#define AUDIT_STATUS_BACKLOG_LIMIT 0x0010
94
95#define AUDIT_FAIL_SILENT 0
96#define AUDIT_FAIL_PRINTK 1
97#define AUDIT_FAIL_PANIC 2
98
99#ifndef __KERNEL__
100struct audit_message {
101 struct nlmsghdr nlh;
102 char data[1200];
103};
104#endif
105
106struct audit_status {
107 __u32 mask;
108 __u32 enabled;
109 __u32 failure;
110 __u32 pid;
111 __u32 rate_limit;
112 __u32 backlog_limit;
113 __u32 lost;
114 __u32 backlog;
115};
116
117struct audit_login {
118 __u32 loginuid;
119 int msglen;
120 char msg[1024];
121};
122
123struct audit_rule {
124 __u32 flags;
125 __u32 action;
126 __u32 field_count;
127 __u32 mask[AUDIT_BITMASK_SIZE];
128 __u32 fields[AUDIT_MAX_FIELDS];
129 __u32 values[AUDIT_MAX_FIELDS];
130};
131
132#ifdef __KERNEL__
133
134#ifdef CONFIG_AUDIT
135struct audit_buffer;
136struct audit_context;
137#endif
138
139#ifdef CONFIG_AUDITSYSCALL
140
141
142extern int audit_alloc(struct task_struct *task);
143extern void audit_free(struct task_struct *task);
144extern void audit_syscall_entry(struct task_struct *task,
145 int major, unsigned long a0, unsigned long a1,
146 unsigned long a2, unsigned long a3);
147extern void audit_syscall_exit(struct task_struct *task, int return_code);
148extern void audit_getname(const char *name);
149extern void audit_putname(const char *name);
150extern void audit_inode(const char *name, unsigned long ino, dev_t rdev);
151
152
153extern int audit_receive_filter(int type, int pid, int uid, int seq,
154 void *data);
155extern void audit_get_stamp(struct audit_context *ctx,
156 struct timespec *t, int *serial);
157extern int audit_set_loginuid(struct audit_context *ctx, uid_t loginuid);
158#else
159#define audit_alloc(t) ({ 0; })
160#define audit_free(t) do { ; } while (0)
161#define audit_syscall_entry(t,a,b,c,d,e) do { ; } while (0)
162#define audit_syscall_exit(t,r) do { ; } while (0)
163#define audit_getname(n) do { ; } while (0)
164#define audit_putname(n) do { ; } while (0)
165#define audit_inode(n,i,d) do { ; } while (0)
166#endif
167
168#ifdef CONFIG_AUDIT
169
170
171extern void audit_log(struct audit_context *ctx,
172 const char *fmt, ...)
173 __attribute__((format(printf,2,3)));
174
175extern struct audit_buffer *audit_log_start(struct audit_context *ctx);
176extern void audit_log_format(struct audit_buffer *ab,
177 const char *fmt, ...)
178 __attribute__((format(printf,2,3)));
179extern void audit_log_end(struct audit_buffer *ab);
180extern void audit_log_end_fast(struct audit_buffer *ab);
181extern void audit_log_end_irq(struct audit_buffer *ab);
182extern void audit_log_d_path(struct audit_buffer *ab,
183 const char *prefix,
184 struct dentry *dentry,
185 struct vfsmount *vfsmnt);
186extern int audit_set_rate_limit(int limit);
187extern int audit_set_backlog_limit(int limit);
188extern int audit_set_enabled(int state);
189extern int audit_set_failure(int state);
190
191
192extern void audit_send_reply(int pid, int seq, int type,
193 int done, int multi,
194 void *payload, int size);
195extern void audit_log_lost(const char *message);
196#else
197#define audit_log(t,f,...) do { ; } while (0)
198#define audit_log_start(t) ({ NULL; })
199#define audit_log_vformat(b,f,a) do { ; } while (0)
200#define audit_log_format(b,f,...) do { ; } while (0)
201#define audit_log_end(b) do { ; } while (0)
202#define audit_log_end_fast(b) do { ; } while (0)
203#define audit_log_end_irq(b) do { ; } while (0)
204#define audit_log_d_path(b,p,d,v) do { ; } while (0)
205#define audit_set_rate_limit(l) do { ; } while (0)
206#define audit_set_backlog_limit(l) do { ; } while (0)
207#define audit_set_enabled(s) do { ; } while (0)
208#define audit_set_failure(s) do { ; } while (0)
209#endif
210#endif
211#endif
212