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