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