]>
Commit | Line | Data |
---|---|---|
1a59d1b8 | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
85c8721f | 2 | /* audit.h -- Auditing support |
1da177e4 LT |
3 | * |
4 | * Copyright 2003-2004 Red Hat Inc., Durham, North Carolina. | |
5 | * All Rights Reserved. | |
6 | * | |
1da177e4 | 7 | * Written by Rickard E. (Rik) Faith <faith@redhat.com> |
1da177e4 | 8 | */ |
1da177e4 LT |
9 | #ifndef _LINUX_AUDIT_H_ |
10 | #define _LINUX_AUDIT_H_ | |
11 | ||
f001e47f | 12 | #include <linux/sched.h> |
c0a3a20b | 13 | #include <linux/ptrace.h> |
607ca46e | 14 | #include <uapi/linux/audit.h> |
8e6cf365 | 15 | #include <uapi/linux/netfilter/nf_tables.h> |
1da177e4 | 16 | |
84cb777e RGB |
17 | #define AUDIT_INO_UNSET ((unsigned long)-1) |
18 | #define AUDIT_DEV_UNSET ((dev_t)-1) | |
19 | ||
c2f0c7c3 SG |
20 | struct audit_sig_info { |
21 | uid_t uid; | |
22 | pid_t pid; | |
0090c1ed | 23 | char ctx[]; |
c2f0c7c3 SG |
24 | }; |
25 | ||
1da177e4 LT |
26 | struct audit_buffer; |
27 | struct audit_context; | |
28 | struct inode; | |
5bb289b5 | 29 | struct netlink_skb_parms; |
37721e1b | 30 | struct path; |
473ae30b | 31 | struct linux_binprm; |
20ca73bc GW |
32 | struct mq_attr; |
33 | struct mqstat; | |
9d57a7f9 AD |
34 | struct audit_watch; |
35 | struct audit_tree; | |
099dd235 | 36 | struct sk_buff; |
9d57a7f9 AD |
37 | |
38 | struct audit_krule { | |
041d7b98 | 39 | u32 pflags; |
9d57a7f9 AD |
40 | u32 flags; |
41 | u32 listnr; | |
42 | u32 action; | |
43 | u32 mask[AUDIT_BITMASK_SIZE]; | |
44 | u32 buflen; /* for data alloc on list rules */ | |
45 | u32 field_count; | |
46 | char *filterkey; /* ties events to rules */ | |
47 | struct audit_field *fields; | |
48 | struct audit_field *arch_f; /* quick access to arch field */ | |
49 | struct audit_field *inode_f; /* quick access to an inode field */ | |
50 | struct audit_watch *watch; /* associated watch */ | |
51 | struct audit_tree *tree; /* associated watched tree */ | |
34d99af5 | 52 | struct audit_fsnotify_mark *exe; |
9d57a7f9 | 53 | struct list_head rlist; /* entry in audit_{watch,tree}.rules list */ |
e45aa212 | 54 | struct list_head list; /* for AUDIT_LIST* purposes only */ |
0590b933 | 55 | u64 prio; |
9d57a7f9 AD |
56 | }; |
57 | ||
041d7b98 RGB |
58 | /* Flag to indicate legacy AUDIT_LOGINUID unset usage */ |
59 | #define AUDIT_LOGINUID_LEGACY 0x1 | |
60 | ||
9d57a7f9 AD |
61 | struct audit_field { |
62 | u32 type; | |
219ca394 RGB |
63 | union { |
64 | u32 val; | |
65 | kuid_t uid; | |
66 | kgid_t gid; | |
67 | struct { | |
68 | char *lsm_str; | |
69 | void *lsm_rule; | |
70 | }; | |
71 | }; | |
9d57a7f9 | 72 | u32 op; |
9d57a7f9 | 73 | }; |
1da177e4 | 74 | |
7e8eda73 OM |
75 | enum audit_ntp_type { |
76 | AUDIT_NTP_OFFSET, | |
77 | AUDIT_NTP_FREQ, | |
78 | AUDIT_NTP_STATUS, | |
79 | AUDIT_NTP_TAI, | |
80 | AUDIT_NTP_TICK, | |
81 | AUDIT_NTP_ADJUST, | |
82 | ||
83 | AUDIT_NTP_NVALS /* count */ | |
84 | }; | |
85 | ||
86 | #ifdef CONFIG_AUDITSYSCALL | |
87 | struct audit_ntp_val { | |
88 | long long oldval, newval; | |
89 | }; | |
90 | ||
91 | struct audit_ntp_data { | |
92 | struct audit_ntp_val vals[AUDIT_NTP_NVALS]; | |
93 | }; | |
94 | #else | |
95 | struct audit_ntp_data {}; | |
96 | #endif | |
97 | ||
c4dad0aa RGB |
98 | enum audit_nfcfgop { |
99 | AUDIT_XT_OP_REGISTER, | |
100 | AUDIT_XT_OP_REPLACE, | |
a45d8853 | 101 | AUDIT_XT_OP_UNREGISTER, |
8e6cf365 RGB |
102 | AUDIT_NFT_OP_TABLE_REGISTER, |
103 | AUDIT_NFT_OP_TABLE_UNREGISTER, | |
104 | AUDIT_NFT_OP_CHAIN_REGISTER, | |
105 | AUDIT_NFT_OP_CHAIN_UNREGISTER, | |
106 | AUDIT_NFT_OP_RULE_REGISTER, | |
107 | AUDIT_NFT_OP_RULE_UNREGISTER, | |
108 | AUDIT_NFT_OP_SET_REGISTER, | |
109 | AUDIT_NFT_OP_SET_UNREGISTER, | |
110 | AUDIT_NFT_OP_SETELEM_REGISTER, | |
111 | AUDIT_NFT_OP_SETELEM_UNREGISTER, | |
112 | AUDIT_NFT_OP_GEN_REGISTER, | |
113 | AUDIT_NFT_OP_OBJ_REGISTER, | |
114 | AUDIT_NFT_OP_OBJ_UNREGISTER, | |
115 | AUDIT_NFT_OP_OBJ_RESET, | |
116 | AUDIT_NFT_OP_FLOWTABLE_REGISTER, | |
117 | AUDIT_NFT_OP_FLOWTABLE_UNREGISTER, | |
118 | AUDIT_NFT_OP_INVALID, | |
c4dad0aa RGB |
119 | }; |
120 | ||
b0fed402 EP |
121 | extern int is_audit_feature_set(int which); |
122 | ||
b915543b | 123 | extern int __init audit_register_class(int class, unsigned *list); |
55669bfa | 124 | extern int audit_classify_syscall(int abi, unsigned syscall); |
e54dc243 | 125 | extern int audit_classify_arch(int arch); |
4b588411 AT |
126 | /* only for compat system calls */ |
127 | extern unsigned compat_write_class[]; | |
128 | extern unsigned compat_read_class[]; | |
129 | extern unsigned compat_dir_class[]; | |
130 | extern unsigned compat_chattr_class[]; | |
131 | extern unsigned compat_signal_class[]; | |
132 | ||
9e8beeb7 | 133 | extern int audit_classify_compat_syscall(int abi, unsigned syscall); |
78e2e802 JL |
134 | |
135 | /* audit_names->type values */ | |
136 | #define AUDIT_TYPE_UNKNOWN 0 /* we don't know yet */ | |
137 | #define AUDIT_TYPE_NORMAL 1 /* a "normal" audit record */ | |
bfcec708 | 138 | #define AUDIT_TYPE_PARENT 2 /* a parent audit record */ |
4fa6b5ec JL |
139 | #define AUDIT_TYPE_CHILD_DELETE 3 /* a child being deleted */ |
140 | #define AUDIT_TYPE_CHILD_CREATE 4 /* a child being created */ | |
78e2e802 | 141 | |
2950fa9d CG |
142 | /* maximized args number that audit_socketcall can process */ |
143 | #define AUDITSC_ARGS 6 | |
144 | ||
2e28d38a PH |
145 | /* bit values for ->signal->audit_tty */ |
146 | #define AUDIT_TTY_ENABLE BIT(0) | |
147 | #define AUDIT_TTY_LOG_PASSWD BIT(1) | |
148 | ||
91a27b2a JL |
149 | struct filename; |
150 | ||
f7859590 RGB |
151 | #define AUDIT_OFF 0 |
152 | #define AUDIT_ON 1 | |
153 | #define AUDIT_LOCKED 2 | |
96368701 PM |
154 | #ifdef CONFIG_AUDIT |
155 | /* These are defined in audit.c */ | |
156 | /* Public API */ | |
157 | extern __printf(4, 5) | |
158 | void audit_log(struct audit_context *ctx, gfp_t gfp_mask, int type, | |
159 | const char *fmt, ...); | |
160 | ||
161 | extern struct audit_buffer *audit_log_start(struct audit_context *ctx, gfp_t gfp_mask, int type); | |
162 | extern __printf(2, 3) | |
163 | void audit_log_format(struct audit_buffer *ab, const char *fmt, ...); | |
164 | extern void audit_log_end(struct audit_buffer *ab); | |
165 | extern bool audit_string_contains_control(const char *string, | |
166 | size_t len); | |
167 | extern void audit_log_n_hex(struct audit_buffer *ab, | |
168 | const unsigned char *buf, | |
169 | size_t len); | |
170 | extern void audit_log_n_string(struct audit_buffer *ab, | |
171 | const char *buf, | |
172 | size_t n); | |
173 | extern void audit_log_n_untrustedstring(struct audit_buffer *ab, | |
174 | const char *string, | |
175 | size_t n); | |
176 | extern void audit_log_untrustedstring(struct audit_buffer *ab, | |
177 | const char *string); | |
178 | extern void audit_log_d_path(struct audit_buffer *ab, | |
179 | const char *prefix, | |
180 | const struct path *path); | |
181 | extern void audit_log_key(struct audit_buffer *ab, | |
182 | char *key); | |
245d7369 KC |
183 | extern void audit_log_path_denied(int type, |
184 | const char *operation); | |
96368701 | 185 | extern void audit_log_lost(const char *message); |
96368701 PM |
186 | |
187 | extern int audit_log_task_context(struct audit_buffer *ab); | |
2a1fe215 | 188 | extern void audit_log_task_info(struct audit_buffer *ab); |
96368701 PM |
189 | |
190 | extern int audit_update_lsm_rules(void); | |
191 | ||
192 | /* Private API (for audit.c only) */ | |
45a0642b | 193 | extern int audit_rule_change(int type, int seq, void *data, size_t datasz); |
96368701 PM |
194 | extern int audit_list_rules_send(struct sk_buff *request_skb, int seq); |
195 | ||
4b7d248b RGB |
196 | extern int audit_set_loginuid(kuid_t loginuid); |
197 | ||
198 | static inline kuid_t audit_get_loginuid(struct task_struct *tsk) | |
199 | { | |
200 | return tsk->loginuid; | |
201 | } | |
202 | ||
203 | static inline unsigned int audit_get_sessionid(struct task_struct *tsk) | |
204 | { | |
205 | return tsk->sessionid; | |
206 | } | |
207 | ||
96368701 | 208 | extern u32 audit_enabled; |
b48345aa RGB |
209 | |
210 | extern int audit_signal_info(int sig, struct task_struct *t); | |
211 | ||
96368701 PM |
212 | #else /* CONFIG_AUDIT */ |
213 | static inline __printf(4, 5) | |
214 | void audit_log(struct audit_context *ctx, gfp_t gfp_mask, int type, | |
215 | const char *fmt, ...) | |
216 | { } | |
217 | static inline struct audit_buffer *audit_log_start(struct audit_context *ctx, | |
218 | gfp_t gfp_mask, int type) | |
219 | { | |
220 | return NULL; | |
221 | } | |
222 | static inline __printf(2, 3) | |
223 | void audit_log_format(struct audit_buffer *ab, const char *fmt, ...) | |
224 | { } | |
225 | static inline void audit_log_end(struct audit_buffer *ab) | |
226 | { } | |
227 | static inline void audit_log_n_hex(struct audit_buffer *ab, | |
228 | const unsigned char *buf, size_t len) | |
229 | { } | |
230 | static inline void audit_log_n_string(struct audit_buffer *ab, | |
231 | const char *buf, size_t n) | |
232 | { } | |
233 | static inline void audit_log_n_untrustedstring(struct audit_buffer *ab, | |
234 | const char *string, size_t n) | |
235 | { } | |
236 | static inline void audit_log_untrustedstring(struct audit_buffer *ab, | |
237 | const char *string) | |
238 | { } | |
239 | static inline void audit_log_d_path(struct audit_buffer *ab, | |
240 | const char *prefix, | |
241 | const struct path *path) | |
242 | { } | |
243 | static inline void audit_log_key(struct audit_buffer *ab, char *key) | |
244 | { } | |
245d7369 | 245 | static inline void audit_log_path_denied(int type, const char *operation) |
96368701 | 246 | { } |
96368701 PM |
247 | static inline int audit_log_task_context(struct audit_buffer *ab) |
248 | { | |
249 | return 0; | |
250 | } | |
2a1fe215 | 251 | static inline void audit_log_task_info(struct audit_buffer *ab) |
96368701 | 252 | { } |
4b7d248b RGB |
253 | |
254 | static inline kuid_t audit_get_loginuid(struct task_struct *tsk) | |
255 | { | |
256 | return INVALID_UID; | |
257 | } | |
258 | ||
259 | static inline unsigned int audit_get_sessionid(struct task_struct *tsk) | |
260 | { | |
261 | return AUDIT_SID_UNSET; | |
262 | } | |
263 | ||
f7859590 | 264 | #define audit_enabled AUDIT_OFF |
b48345aa RGB |
265 | |
266 | static inline int audit_signal_info(int sig, struct task_struct *t) | |
267 | { | |
268 | return 0; | |
269 | } | |
270 | ||
96368701 PM |
271 | #endif /* CONFIG_AUDIT */ |
272 | ||
312103d6 | 273 | #ifdef CONFIG_AUDIT_COMPAT_GENERIC |
356750e3 EP |
274 | #define audit_is_compat(arch) (!((arch) & __AUDIT_ARCH_64BIT)) |
275 | #else | |
276 | #define audit_is_compat(arch) false | |
277 | #endif | |
278 | ||
c9b07eab AV |
279 | #define AUDIT_INODE_PARENT 1 /* dentry represents the parent */ |
280 | #define AUDIT_INODE_HIDDEN 2 /* audit record should be hidden */ | |
281 | #define AUDIT_INODE_NOEVAL 4 /* audit record incomplete */ | |
282 | ||
1da177e4 | 283 | #ifdef CONFIG_AUDITSYSCALL |
a9ebe0b9 EP |
284 | #include <asm/syscall.h> /* for syscall_get_arch() */ |
285 | ||
1da177e4 LT |
286 | /* These are defined in auditsc.c */ |
287 | /* Public API */ | |
288 | extern int audit_alloc(struct task_struct *task); | |
a4ff8dba | 289 | extern void __audit_free(struct task_struct *task); |
b4f0d375 | 290 | extern void __audit_syscall_entry(int major, unsigned long a0, unsigned long a1, |
b05d8447 | 291 | unsigned long a2, unsigned long a3); |
d7e7528b | 292 | extern void __audit_syscall_exit(int ret_success, long ret_value); |
7ac86265 | 293 | extern struct filename *__audit_reusename(const __user char *uptr); |
91a27b2a | 294 | extern void __audit_getname(struct filename *name); |
adb5c247 | 295 | extern void __audit_inode(struct filename *name, const struct dentry *dentry, |
79f6530c | 296 | unsigned int flags); |
9f45f5bf | 297 | extern void __audit_file(const struct file *); |
d6335d77 | 298 | extern void __audit_inode_child(struct inode *parent, |
4fa6b5ec JL |
299 | const struct dentry *dentry, |
300 | const unsigned char type); | |
326bee02 | 301 | extern void audit_seccomp(unsigned long syscall, long signr, int code); |
ea6eca77 TH |
302 | extern void audit_seccomp_actions_logged(const char *names, |
303 | const char *old_names, int res); | |
a5cb013d AV |
304 | extern void __audit_ptrace(struct task_struct *t); |
305 | ||
c0b0ae8a RGB |
306 | static inline void audit_set_context(struct task_struct *task, struct audit_context *ctx) |
307 | { | |
308 | task->audit_context = ctx; | |
309 | } | |
310 | ||
cdfb6b34 RGB |
311 | static inline struct audit_context *audit_context(void) |
312 | { | |
313 | return current->audit_context; | |
314 | } | |
315 | ||
36734810 | 316 | static inline bool audit_dummy_context(void) |
d51374ad | 317 | { |
cdfb6b34 | 318 | void *p = audit_context(); |
d51374ad AV |
319 | return !p || *(int *)p; |
320 | } | |
a4ff8dba EP |
321 | static inline void audit_free(struct task_struct *task) |
322 | { | |
323 | if (unlikely(task->audit_context)) | |
324 | __audit_free(task); | |
325 | } | |
91397401 | 326 | static inline void audit_syscall_entry(int major, unsigned long a0, |
b05d8447 EP |
327 | unsigned long a1, unsigned long a2, |
328 | unsigned long a3) | |
329 | { | |
cdfb6b34 | 330 | if (unlikely(audit_context())) |
b4f0d375 | 331 | __audit_syscall_entry(major, a0, a1, a2, a3); |
b05d8447 | 332 | } |
d7e7528b EP |
333 | static inline void audit_syscall_exit(void *pt_regs) |
334 | { | |
cdfb6b34 | 335 | if (unlikely(audit_context())) { |
d7e7528b | 336 | int success = is_syscall_success(pt_regs); |
06bdadd7 | 337 | long return_code = regs_return_value(pt_regs); |
d7e7528b EP |
338 | |
339 | __audit_syscall_exit(success, return_code); | |
340 | } | |
341 | } | |
7ac86265 JL |
342 | static inline struct filename *audit_reusename(const __user char *name) |
343 | { | |
344 | if (unlikely(!audit_dummy_context())) | |
345 | return __audit_reusename(name); | |
346 | return NULL; | |
347 | } | |
91a27b2a | 348 | static inline void audit_getname(struct filename *name) |
d8945bb5 | 349 | { |
5ac3a9c2 | 350 | if (unlikely(!audit_dummy_context())) |
d8945bb5 AV |
351 | __audit_getname(name); |
352 | } | |
79f6530c JL |
353 | static inline void audit_inode(struct filename *name, |
354 | const struct dentry *dentry, | |
c9b07eab AV |
355 | unsigned int aflags) { |
356 | if (unlikely(!audit_dummy_context())) | |
57d46577 | 357 | __audit_inode(name, dentry, aflags); |
79f6530c | 358 | } |
9f45f5bf AV |
359 | static inline void audit_file(struct file *file) |
360 | { | |
361 | if (unlikely(!audit_dummy_context())) | |
362 | __audit_file(file); | |
363 | } | |
79f6530c JL |
364 | static inline void audit_inode_parent_hidden(struct filename *name, |
365 | const struct dentry *dentry) | |
366 | { | |
5ac3a9c2 | 367 | if (unlikely(!audit_dummy_context())) |
79f6530c JL |
368 | __audit_inode(name, dentry, |
369 | AUDIT_INODE_PARENT | AUDIT_INODE_HIDDEN); | |
73241ccc | 370 | } |
d6335d77 | 371 | static inline void audit_inode_child(struct inode *parent, |
4fa6b5ec JL |
372 | const struct dentry *dentry, |
373 | const unsigned char type) { | |
5ac3a9c2 | 374 | if (unlikely(!audit_dummy_context())) |
4fa6b5ec | 375 | __audit_inode_child(parent, dentry, type); |
73241ccc | 376 | } |
0a4ff8c2 | 377 | void audit_core_dumps(long signr); |
1da177e4 | 378 | |
a5cb013d AV |
379 | static inline void audit_ptrace(struct task_struct *t) |
380 | { | |
381 | if (unlikely(!audit_dummy_context())) | |
382 | __audit_ptrace(t); | |
383 | } | |
384 | ||
1da177e4 | 385 | /* Private API (for audit.c only) */ |
a33e6751 | 386 | extern void __audit_ipc_obj(struct kern_ipc_perm *ipcp); |
2570ebbd | 387 | extern void __audit_ipc_set_perm(unsigned long qbytes, uid_t uid, gid_t gid, umode_t mode); |
d9cfea91 | 388 | extern void __audit_bprm(struct linux_binprm *bprm); |
2950fa9d | 389 | extern int __audit_socketcall(int nargs, unsigned long *args); |
07c49417 | 390 | extern int __audit_sockaddr(int len, void *addr); |
157cf649 | 391 | extern void __audit_fd_pair(int fd1, int fd2); |
df0a4283 | 392 | extern void __audit_mq_open(int oflag, umode_t mode, struct mq_attr *attr); |
b9047726 | 393 | extern void __audit_mq_sendrecv(mqd_t mqdes, size_t msg_len, unsigned int msg_prio, const struct timespec64 *abs_timeout); |
20114f71 | 394 | extern void __audit_mq_notify(mqd_t mqdes, const struct sigevent *notification); |
7392906e | 395 | extern void __audit_mq_getsetattr(mqd_t mqdes, struct mq_attr *mqstat); |
d84f4f99 DH |
396 | extern int __audit_log_bprm_fcaps(struct linux_binprm *bprm, |
397 | const struct cred *new, | |
398 | const struct cred *old); | |
ca24a23e | 399 | extern void __audit_log_capset(const struct cred *new, const struct cred *old); |
120a795d | 400 | extern void __audit_mmap_fd(int fd, int flags); |
ca86cad7 | 401 | extern void __audit_log_kern_module(char *name); |
de8cd83e | 402 | extern void __audit_fanotify(unsigned int response); |
2d87a067 | 403 | extern void __audit_tk_injoffset(struct timespec64 offset); |
7e8eda73 | 404 | extern void __audit_ntp_log(const struct audit_ntp_data *ad); |
c4dad0aa | 405 | extern void __audit_log_nfcfg(const char *name, u8 af, unsigned int nentries, |
14224039 | 406 | enum audit_nfcfgop op, gfp_t gfp); |
d8945bb5 | 407 | |
a33e6751 | 408 | static inline void audit_ipc_obj(struct kern_ipc_perm *ipcp) |
d8945bb5 | 409 | { |
5ac3a9c2 | 410 | if (unlikely(!audit_dummy_context())) |
a33e6751 | 411 | __audit_ipc_obj(ipcp); |
db349509 | 412 | } |
157cf649 | 413 | static inline void audit_fd_pair(int fd1, int fd2) |
d8945bb5 | 414 | { |
5ac3a9c2 | 415 | if (unlikely(!audit_dummy_context())) |
157cf649 | 416 | __audit_fd_pair(fd1, fd2); |
d8945bb5 | 417 | } |
2570ebbd | 418 | static inline void audit_ipc_set_perm(unsigned long qbytes, uid_t uid, gid_t gid, umode_t mode) |
20ca73bc | 419 | { |
5ac3a9c2 | 420 | if (unlikely(!audit_dummy_context())) |
e816f370 | 421 | __audit_ipc_set_perm(qbytes, uid, gid, mode); |
20ca73bc | 422 | } |
9410d228 | 423 | static inline void audit_bprm(struct linux_binprm *bprm) |
07c49417 EP |
424 | { |
425 | if (unlikely(!audit_dummy_context())) | |
d9cfea91 | 426 | __audit_bprm(bprm); |
07c49417 | 427 | } |
2950fa9d | 428 | static inline int audit_socketcall(int nargs, unsigned long *args) |
07c49417 EP |
429 | { |
430 | if (unlikely(!audit_dummy_context())) | |
2950fa9d CG |
431 | return __audit_socketcall(nargs, args); |
432 | return 0; | |
07c49417 | 433 | } |
62bc306e RGB |
434 | |
435 | static inline int audit_socketcall_compat(int nargs, u32 *args) | |
436 | { | |
437 | unsigned long a[AUDITSC_ARGS]; | |
438 | int i; | |
439 | ||
440 | if (audit_dummy_context()) | |
441 | return 0; | |
442 | ||
443 | for (i = 0; i < nargs; i++) | |
444 | a[i] = (unsigned long)args[i]; | |
445 | return __audit_socketcall(nargs, a); | |
446 | } | |
447 | ||
07c49417 EP |
448 | static inline int audit_sockaddr(int len, void *addr) |
449 | { | |
450 | if (unlikely(!audit_dummy_context())) | |
451 | return __audit_sockaddr(len, addr); | |
452 | return 0; | |
453 | } | |
df0a4283 | 454 | static inline void audit_mq_open(int oflag, umode_t mode, struct mq_attr *attr) |
20ca73bc | 455 | { |
5ac3a9c2 | 456 | if (unlikely(!audit_dummy_context())) |
564f6993 | 457 | __audit_mq_open(oflag, mode, attr); |
20ca73bc | 458 | } |
b9047726 | 459 | static inline void audit_mq_sendrecv(mqd_t mqdes, size_t msg_len, unsigned int msg_prio, const struct timespec64 *abs_timeout) |
20ca73bc | 460 | { |
5ac3a9c2 | 461 | if (unlikely(!audit_dummy_context())) |
c32c8af4 | 462 | __audit_mq_sendrecv(mqdes, msg_len, msg_prio, abs_timeout); |
20ca73bc | 463 | } |
20114f71 | 464 | static inline void audit_mq_notify(mqd_t mqdes, const struct sigevent *notification) |
20ca73bc | 465 | { |
5ac3a9c2 | 466 | if (unlikely(!audit_dummy_context())) |
20114f71 | 467 | __audit_mq_notify(mqdes, notification); |
20ca73bc | 468 | } |
7392906e | 469 | static inline void audit_mq_getsetattr(mqd_t mqdes, struct mq_attr *mqstat) |
20ca73bc | 470 | { |
5ac3a9c2 | 471 | if (unlikely(!audit_dummy_context())) |
7392906e | 472 | __audit_mq_getsetattr(mqdes, mqstat); |
20ca73bc | 473 | } |
3fc689e9 | 474 | |
d84f4f99 DH |
475 | static inline int audit_log_bprm_fcaps(struct linux_binprm *bprm, |
476 | const struct cred *new, | |
477 | const struct cred *old) | |
3fc689e9 EP |
478 | { |
479 | if (unlikely(!audit_dummy_context())) | |
d84f4f99 DH |
480 | return __audit_log_bprm_fcaps(bprm, new, old); |
481 | return 0; | |
3fc689e9 EP |
482 | } |
483 | ||
ca24a23e | 484 | static inline void audit_log_capset(const struct cred *new, |
d84f4f99 | 485 | const struct cred *old) |
e68b75a0 EP |
486 | { |
487 | if (unlikely(!audit_dummy_context())) | |
ca24a23e | 488 | __audit_log_capset(new, old); |
e68b75a0 EP |
489 | } |
490 | ||
120a795d AV |
491 | static inline void audit_mmap_fd(int fd, int flags) |
492 | { | |
493 | if (unlikely(!audit_dummy_context())) | |
494 | __audit_mmap_fd(fd, flags); | |
495 | } | |
496 | ||
ca86cad7 RGB |
497 | static inline void audit_log_kern_module(char *name) |
498 | { | |
499 | if (!audit_dummy_context()) | |
500 | __audit_log_kern_module(name); | |
501 | } | |
502 | ||
de8cd83e SG |
503 | static inline void audit_fanotify(unsigned int response) |
504 | { | |
505 | if (!audit_dummy_context()) | |
506 | __audit_fanotify(response); | |
507 | } | |
508 | ||
2d87a067 OM |
509 | static inline void audit_tk_injoffset(struct timespec64 offset) |
510 | { | |
511 | /* ignore no-op events */ | |
512 | if (offset.tv_sec == 0 && offset.tv_nsec == 0) | |
513 | return; | |
514 | ||
515 | if (!audit_dummy_context()) | |
516 | __audit_tk_injoffset(offset); | |
517 | } | |
518 | ||
7e8eda73 OM |
519 | static inline void audit_ntp_init(struct audit_ntp_data *ad) |
520 | { | |
521 | memset(ad, 0, sizeof(*ad)); | |
522 | } | |
523 | ||
524 | static inline void audit_ntp_set_old(struct audit_ntp_data *ad, | |
525 | enum audit_ntp_type type, long long val) | |
526 | { | |
527 | ad->vals[type].oldval = val; | |
528 | } | |
529 | ||
530 | static inline void audit_ntp_set_new(struct audit_ntp_data *ad, | |
531 | enum audit_ntp_type type, long long val) | |
532 | { | |
533 | ad->vals[type].newval = val; | |
534 | } | |
535 | ||
536 | static inline void audit_ntp_log(const struct audit_ntp_data *ad) | |
537 | { | |
538 | if (!audit_dummy_context()) | |
539 | __audit_ntp_log(ad); | |
540 | } | |
541 | ||
c4dad0aa RGB |
542 | static inline void audit_log_nfcfg(const char *name, u8 af, |
543 | unsigned int nentries, | |
14224039 | 544 | enum audit_nfcfgop op, gfp_t gfp) |
c4dad0aa RGB |
545 | { |
546 | if (audit_enabled) | |
14224039 | 547 | __audit_log_nfcfg(name, af, nentries, op, gfp); |
c4dad0aa RGB |
548 | } |
549 | ||
471a5c7c | 550 | extern int audit_n_rules; |
e54dc243 | 551 | extern int audit_signals; |
d7e7528b | 552 | #else /* CONFIG_AUDITSYSCALL */ |
9321d526 KC |
553 | static inline int audit_alloc(struct task_struct *task) |
554 | { | |
555 | return 0; | |
556 | } | |
557 | static inline void audit_free(struct task_struct *task) | |
558 | { } | |
91397401 | 559 | static inline void audit_syscall_entry(int major, unsigned long a0, |
9321d526 KC |
560 | unsigned long a1, unsigned long a2, |
561 | unsigned long a3) | |
562 | { } | |
563 | static inline void audit_syscall_exit(void *pt_regs) | |
564 | { } | |
36734810 | 565 | static inline bool audit_dummy_context(void) |
9321d526 | 566 | { |
36734810 | 567 | return true; |
9321d526 | 568 | } |
c0b0ae8a RGB |
569 | static inline void audit_set_context(struct task_struct *task, struct audit_context *ctx) |
570 | { } | |
cdfb6b34 RGB |
571 | static inline struct audit_context *audit_context(void) |
572 | { | |
573 | return NULL; | |
574 | } | |
7ac86265 JL |
575 | static inline struct filename *audit_reusename(const __user char *name) |
576 | { | |
577 | return NULL; | |
578 | } | |
91a27b2a | 579 | static inline void audit_getname(struct filename *name) |
9321d526 | 580 | { } |
adb5c247 JL |
581 | static inline void audit_inode(struct filename *name, |
582 | const struct dentry *dentry, | |
c9b07eab | 583 | unsigned int aflags) |
9321d526 | 584 | { } |
9f45f5bf AV |
585 | static inline void audit_file(struct file *file) |
586 | { | |
587 | } | |
79f6530c JL |
588 | static inline void audit_inode_parent_hidden(struct filename *name, |
589 | const struct dentry *dentry) | |
590 | { } | |
d6335d77 | 591 | static inline void audit_inode_child(struct inode *parent, |
4fa6b5ec JL |
592 | const struct dentry *dentry, |
593 | const unsigned char type) | |
9321d526 KC |
594 | { } |
595 | static inline void audit_core_dumps(long signr) | |
596 | { } | |
9321d526 KC |
597 | static inline void audit_seccomp(unsigned long syscall, long signr, int code) |
598 | { } | |
ea6eca77 TH |
599 | static inline void audit_seccomp_actions_logged(const char *names, |
600 | const char *old_names, int res) | |
601 | { } | |
9321d526 KC |
602 | static inline void audit_ipc_obj(struct kern_ipc_perm *ipcp) |
603 | { } | |
604 | static inline void audit_ipc_set_perm(unsigned long qbytes, uid_t uid, | |
605 | gid_t gid, umode_t mode) | |
606 | { } | |
9410d228 RGB |
607 | static inline void audit_bprm(struct linux_binprm *bprm) |
608 | { } | |
2950fa9d CG |
609 | static inline int audit_socketcall(int nargs, unsigned long *args) |
610 | { | |
611 | return 0; | |
612 | } | |
62bc306e RGB |
613 | |
614 | static inline int audit_socketcall_compat(int nargs, u32 *args) | |
615 | { | |
616 | return 0; | |
617 | } | |
618 | ||
9321d526 KC |
619 | static inline void audit_fd_pair(int fd1, int fd2) |
620 | { } | |
621 | static inline int audit_sockaddr(int len, void *addr) | |
622 | { | |
623 | return 0; | |
624 | } | |
625 | static inline void audit_mq_open(int oflag, umode_t mode, struct mq_attr *attr) | |
626 | { } | |
627 | static inline void audit_mq_sendrecv(mqd_t mqdes, size_t msg_len, | |
628 | unsigned int msg_prio, | |
b9047726 | 629 | const struct timespec64 *abs_timeout) |
9321d526 KC |
630 | { } |
631 | static inline void audit_mq_notify(mqd_t mqdes, | |
632 | const struct sigevent *notification) | |
633 | { } | |
634 | static inline void audit_mq_getsetattr(mqd_t mqdes, struct mq_attr *mqstat) | |
635 | { } | |
636 | static inline int audit_log_bprm_fcaps(struct linux_binprm *bprm, | |
637 | const struct cred *new, | |
638 | const struct cred *old) | |
639 | { | |
640 | return 0; | |
641 | } | |
ca24a23e EB |
642 | static inline void audit_log_capset(const struct cred *new, |
643 | const struct cred *old) | |
9321d526 KC |
644 | { } |
645 | static inline void audit_mmap_fd(int fd, int flags) | |
646 | { } | |
ca86cad7 RGB |
647 | |
648 | static inline void audit_log_kern_module(char *name) | |
649 | { | |
650 | } | |
651 | ||
de8cd83e SG |
652 | static inline void audit_fanotify(unsigned int response) |
653 | { } | |
654 | ||
2d87a067 OM |
655 | static inline void audit_tk_injoffset(struct timespec64 offset) |
656 | { } | |
657 | ||
7e8eda73 OM |
658 | static inline void audit_ntp_init(struct audit_ntp_data *ad) |
659 | { } | |
660 | ||
661 | static inline void audit_ntp_set_old(struct audit_ntp_data *ad, | |
662 | enum audit_ntp_type type, long long val) | |
663 | { } | |
664 | ||
665 | static inline void audit_ntp_set_new(struct audit_ntp_data *ad, | |
666 | enum audit_ntp_type type, long long val) | |
667 | { } | |
668 | ||
669 | static inline void audit_ntp_log(const struct audit_ntp_data *ad) | |
670 | { } | |
671 | ||
9321d526 KC |
672 | static inline void audit_ptrace(struct task_struct *t) |
673 | { } | |
c4dad0aa RGB |
674 | |
675 | static inline void audit_log_nfcfg(const char *name, u8 af, | |
676 | unsigned int nentries, | |
14224039 | 677 | enum audit_nfcfgop op, gfp_t gfp) |
c4dad0aa RGB |
678 | { } |
679 | ||
471a5c7c | 680 | #define audit_n_rules 0 |
e54dc243 | 681 | #define audit_signals 0 |
d7e7528b | 682 | #endif /* CONFIG_AUDITSYSCALL */ |
1da177e4 | 683 | |
780a7654 EB |
684 | static inline bool audit_loginuid_set(struct task_struct *tsk) |
685 | { | |
686 | return uid_valid(audit_get_loginuid(tsk)); | |
687 | } | |
688 | ||
1da177e4 | 689 | #endif |