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