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