Blame view

include/linux/audit.h 19.2 KB
1a59d1b8e   Thomas Gleixner   treewide: Replace...
1
  /* SPDX-License-Identifier: GPL-2.0-or-later */
85c8721ff   David Woodhouse   audit: update poi...
2
  /* audit.h -- Auditing support
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
3
4
5
6
   *
   * Copyright 2003-2004 Red Hat Inc., Durham, North Carolina.
   * All Rights Reserved.
   *
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
7
   * Written by Rickard E. (Rik) Faith <faith@redhat.com>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
8
   */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
9
10
  #ifndef _LINUX_AUDIT_H_
  #define _LINUX_AUDIT_H_
f001e47f8   David Woodhouse   Sanitise linux/au...
11
  #include <linux/sched.h>
c0a3a20b6   Mike Frysinger   linux/audit.h: mo...
12
  #include <linux/ptrace.h>
607ca46e9   David Howells   UAPI: (Scripted) ...
13
  #include <uapi/linux/audit.h>
8e6cf365e   Richard Guy Briggs   audit: log nftabl...
14
  #include <uapi/linux/netfilter/nf_tables.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
15

84cb777e6   Richard Guy Briggs   audit: use macros...
16
17
  #define AUDIT_INO_UNSET ((unsigned long)-1)
  #define AUDIT_DEV_UNSET ((dev_t)-1)
c2f0c7c35   Steve Grubb   The attached patc...
18
19
20
  struct audit_sig_info {
  	uid_t		uid;
  	pid_t		pid;
0090c1ede   Gustavo A. R. Silva   audit: Replace ze...
21
  	char		ctx[];
c2f0c7c35   Steve Grubb   The attached patc...
22
  };
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
23
24
25
  struct audit_buffer;
  struct audit_context;
  struct inode;
5bb289b5a   David Woodhouse   AUDIT: Clean up u...
26
  struct netlink_skb_parms;
37721e1b0   Alexey Dobriyan   headers: path.h r...
27
  struct path;
473ae30bc   Al Viro   [PATCH] execve ar...
28
  struct linux_binprm;
20ca73bc7   George C. Wilson   [PATCH] Audit of ...
29
30
  struct mq_attr;
  struct mqstat;
9d57a7f9e   Ahmed S. Darwish   SELinux: use new ...
31
32
  struct audit_watch;
  struct audit_tree;
099dd2351   Eric W. Biederman   audit: Send repli...
33
  struct sk_buff;
9d57a7f9e   Ahmed S. Darwish   SELinux: use new ...
34
35
  
  struct audit_krule {
041d7b98f   Richard Guy Briggs   audit: restore AU...
36
  	u32			pflags;
9d57a7f9e   Ahmed S. Darwish   SELinux: use new ...
37
38
39
40
41
42
43
44
45
46
47
48
  	u32			flags;
  	u32			listnr;
  	u32			action;
  	u32			mask[AUDIT_BITMASK_SIZE];
  	u32			buflen; /* for data alloc on list rules */
  	u32			field_count;
  	char			*filterkey; /* ties events to rules */
  	struct audit_field	*fields;
  	struct audit_field	*arch_f; /* quick access to arch field */
  	struct audit_field	*inode_f; /* quick access to an inode field */
  	struct audit_watch	*watch;	/* associated watch */
  	struct audit_tree	*tree;	/* associated watched tree */
34d99af52   Richard Guy Briggs   audit: implement ...
49
  	struct audit_fsnotify_mark	*exe;
9d57a7f9e   Ahmed S. Darwish   SELinux: use new ...
50
  	struct list_head	rlist;	/* entry in audit_{watch,tree}.rules list */
e45aa212e   Al Viro   audit rules order...
51
  	struct list_head	list;	/* for AUDIT_LIST* purposes only */
0590b9335   Al Viro   fixing audit rule...
52
  	u64			prio;
9d57a7f9e   Ahmed S. Darwish   SELinux: use new ...
53
  };
041d7b98f   Richard Guy Briggs   audit: restore AU...
54
55
  /* Flag to indicate legacy AUDIT_LOGINUID unset usage */
  #define AUDIT_LOGINUID_LEGACY		0x1
9d57a7f9e   Ahmed S. Darwish   SELinux: use new ...
56
57
  struct audit_field {
  	u32				type;
219ca3942   Richard Guy Briggs   audit: use union ...
58
59
60
61
62
63
64
65
66
  	union {
  		u32			val;
  		kuid_t			uid;
  		kgid_t			gid;
  		struct {
  			char		*lsm_str;
  			void		*lsm_rule;
  		};
  	};
9d57a7f9e   Ahmed S. Darwish   SELinux: use new ...
67
  	u32				op;
9d57a7f9e   Ahmed S. Darwish   SELinux: use new ...
68
  };
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
69

7e8eda734   Ondrej Mosnacek   ntp: Audit NTP pa...
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
  enum audit_ntp_type {
  	AUDIT_NTP_OFFSET,
  	AUDIT_NTP_FREQ,
  	AUDIT_NTP_STATUS,
  	AUDIT_NTP_TAI,
  	AUDIT_NTP_TICK,
  	AUDIT_NTP_ADJUST,
  
  	AUDIT_NTP_NVALS /* count */
  };
  
  #ifdef CONFIG_AUDITSYSCALL
  struct audit_ntp_val {
  	long long oldval, newval;
  };
  
  struct audit_ntp_data {
  	struct audit_ntp_val vals[AUDIT_NTP_NVALS];
  };
  #else
  struct audit_ntp_data {};
  #endif
c4dad0aab   Richard Guy Briggs   audit: tidy and e...
92
93
94
  enum audit_nfcfgop {
  	AUDIT_XT_OP_REGISTER,
  	AUDIT_XT_OP_REPLACE,
a45d88530   Richard Guy Briggs   netfilter: add au...
95
  	AUDIT_XT_OP_UNREGISTER,
8e6cf365e   Richard Guy Briggs   audit: log nftabl...
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
  	AUDIT_NFT_OP_TABLE_REGISTER,
  	AUDIT_NFT_OP_TABLE_UNREGISTER,
  	AUDIT_NFT_OP_CHAIN_REGISTER,
  	AUDIT_NFT_OP_CHAIN_UNREGISTER,
  	AUDIT_NFT_OP_RULE_REGISTER,
  	AUDIT_NFT_OP_RULE_UNREGISTER,
  	AUDIT_NFT_OP_SET_REGISTER,
  	AUDIT_NFT_OP_SET_UNREGISTER,
  	AUDIT_NFT_OP_SETELEM_REGISTER,
  	AUDIT_NFT_OP_SETELEM_UNREGISTER,
  	AUDIT_NFT_OP_GEN_REGISTER,
  	AUDIT_NFT_OP_OBJ_REGISTER,
  	AUDIT_NFT_OP_OBJ_UNREGISTER,
  	AUDIT_NFT_OP_OBJ_RESET,
  	AUDIT_NFT_OP_FLOWTABLE_REGISTER,
  	AUDIT_NFT_OP_FLOWTABLE_UNREGISTER,
  	AUDIT_NFT_OP_INVALID,
c4dad0aab   Richard Guy Briggs   audit: tidy and e...
113
  };
b0fed4021   Eric Paris   audit: implement ...
114
  extern int is_audit_feature_set(int which);
b915543b4   Al Viro   [PATCH] audit sys...
115
  extern int __init audit_register_class(int class, unsigned *list);
55669bfa1   Al Viro   [PATCH] audit: AU...
116
  extern int audit_classify_syscall(int abi, unsigned syscall);
e54dc2431   Amy Griffis   [PATCH] audit sig...
117
  extern int audit_classify_arch(int arch);
4b5884114   AKASHI Takahiro   audit: Add generi...
118
119
120
121
122
123
  /* only for compat system calls */
  extern unsigned compat_write_class[];
  extern unsigned compat_read_class[];
  extern unsigned compat_dir_class[];
  extern unsigned compat_chattr_class[];
  extern unsigned compat_signal_class[];
9e8beeb79   Bjorn Helgaas   audit: Remove "we...
124
  extern int audit_classify_compat_syscall(int abi, unsigned syscall);
78e2e802a   Jeff Layton   audit: add a new ...
125
126
127
128
  
  /* audit_names->type values */
  #define	AUDIT_TYPE_UNKNOWN	0	/* we don't know yet */
  #define	AUDIT_TYPE_NORMAL	1	/* a "normal" audit record */
bfcec7087   Jeff Layton   audit: set the na...
129
  #define	AUDIT_TYPE_PARENT	2	/* a parent audit record */
4fa6b5ecb   Jeff Layton   audit: overhaul _...
130
131
  #define	AUDIT_TYPE_CHILD_DELETE 3	/* a child being deleted */
  #define	AUDIT_TYPE_CHILD_CREATE 4	/* a child being created */
78e2e802a   Jeff Layton   audit: add a new ...
132

2950fa9d3   Chen Gang   kernel: audit: be...
133
134
  /* maximized args number that audit_socketcall can process */
  #define AUDITSC_ARGS		6
2e28d38ae   Peter Hurley   tty: audit: Handl...
135
136
137
  /* bit values for ->signal->audit_tty */
  #define AUDIT_TTY_ENABLE	BIT(0)
  #define AUDIT_TTY_LOG_PASSWD	BIT(1)
91a27b2a7   Jeff Layton   vfs: define struc...
138
  struct filename;
f7859590d   Richard Guy Briggs   audit: eliminate ...
139
140
141
  #define AUDIT_OFF	0
  #define AUDIT_ON	1
  #define AUDIT_LOCKED	2
96368701e   Paul Moore   audit: force secc...
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
  #ifdef CONFIG_AUDIT
  /* These are defined in audit.c */
  				/* Public API */
  extern __printf(4, 5)
  void audit_log(struct audit_context *ctx, gfp_t gfp_mask, int type,
  	       const char *fmt, ...);
  
  extern struct audit_buffer *audit_log_start(struct audit_context *ctx, gfp_t gfp_mask, int type);
  extern __printf(2, 3)
  void audit_log_format(struct audit_buffer *ab, const char *fmt, ...);
  extern void		    audit_log_end(struct audit_buffer *ab);
  extern bool		    audit_string_contains_control(const char *string,
  							  size_t len);
  extern void		    audit_log_n_hex(struct audit_buffer *ab,
  					  const unsigned char *buf,
  					  size_t len);
  extern void		    audit_log_n_string(struct audit_buffer *ab,
  					       const char *buf,
  					       size_t n);
  extern void		    audit_log_n_untrustedstring(struct audit_buffer *ab,
  							const char *string,
  							size_t n);
  extern void		    audit_log_untrustedstring(struct audit_buffer *ab,
  						      const char *string);
  extern void		    audit_log_d_path(struct audit_buffer *ab,
  					     const char *prefix,
  					     const struct path *path);
  extern void		    audit_log_key(struct audit_buffer *ab,
  					  char *key);
245d73698   Kees Cook   audit: Report sus...
171
172
  extern void		    audit_log_path_denied(int type,
  						  const char *operation);
96368701e   Paul Moore   audit: force secc...
173
  extern void		    audit_log_lost(const char *message);
96368701e   Paul Moore   audit: force secc...
174
175
  
  extern int audit_log_task_context(struct audit_buffer *ab);
2a1fe215e   Paul Moore   audit: use curren...
176
  extern void audit_log_task_info(struct audit_buffer *ab);
96368701e   Paul Moore   audit: force secc...
177
178
179
180
  
  extern int		    audit_update_lsm_rules(void);
  
  				/* Private API (for audit.c only) */
45a0642b4   Paul Moore   audit: kernel gen...
181
  extern int audit_rule_change(int type, int seq, void *data, size_t datasz);
96368701e   Paul Moore   audit: force secc...
182
  extern int audit_list_rules_send(struct sk_buff *request_skb, int seq);
4b7d248b3   Richard Guy Briggs   audit: move login...
183
184
185
186
187
188
189
190
191
192
193
  extern int audit_set_loginuid(kuid_t loginuid);
  
  static inline kuid_t audit_get_loginuid(struct task_struct *tsk)
  {
  	return tsk->loginuid;
  }
  
  static inline unsigned int audit_get_sessionid(struct task_struct *tsk)
  {
  	return tsk->sessionid;
  }
96368701e   Paul Moore   audit: force secc...
194
  extern u32 audit_enabled;
b48345aaf   Richard Guy Briggs   audit: deliver si...
195
196
  
  extern int audit_signal_info(int sig, struct task_struct *t);
96368701e   Paul Moore   audit: force secc...
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
  #else /* CONFIG_AUDIT */
  static inline __printf(4, 5)
  void audit_log(struct audit_context *ctx, gfp_t gfp_mask, int type,
  	       const char *fmt, ...)
  { }
  static inline struct audit_buffer *audit_log_start(struct audit_context *ctx,
  						   gfp_t gfp_mask, int type)
  {
  	return NULL;
  }
  static inline __printf(2, 3)
  void audit_log_format(struct audit_buffer *ab, const char *fmt, ...)
  { }
  static inline void audit_log_end(struct audit_buffer *ab)
  { }
  static inline void audit_log_n_hex(struct audit_buffer *ab,
  				   const unsigned char *buf, size_t len)
  { }
  static inline void audit_log_n_string(struct audit_buffer *ab,
  				      const char *buf, size_t n)
  { }
  static inline void  audit_log_n_untrustedstring(struct audit_buffer *ab,
  						const char *string, size_t n)
  { }
  static inline void audit_log_untrustedstring(struct audit_buffer *ab,
  					     const char *string)
  { }
  static inline void audit_log_d_path(struct audit_buffer *ab,
  				    const char *prefix,
  				    const struct path *path)
  { }
  static inline void audit_log_key(struct audit_buffer *ab, char *key)
  { }
245d73698   Kees Cook   audit: Report sus...
230
  static inline void audit_log_path_denied(int type, const char *operation)
96368701e   Paul Moore   audit: force secc...
231
  { }
96368701e   Paul Moore   audit: force secc...
232
233
234
235
  static inline int audit_log_task_context(struct audit_buffer *ab)
  {
  	return 0;
  }
2a1fe215e   Paul Moore   audit: use curren...
236
  static inline void audit_log_task_info(struct audit_buffer *ab)
96368701e   Paul Moore   audit: force secc...
237
  { }
4b7d248b3   Richard Guy Briggs   audit: move login...
238
239
240
241
242
243
244
245
246
247
  
  static inline kuid_t audit_get_loginuid(struct task_struct *tsk)
  {
  	return INVALID_UID;
  }
  
  static inline unsigned int audit_get_sessionid(struct task_struct *tsk)
  {
  	return AUDIT_SID_UNSET;
  }
f7859590d   Richard Guy Briggs   audit: eliminate ...
248
  #define audit_enabled AUDIT_OFF
b48345aaf   Richard Guy Briggs   audit: deliver si...
249
250
251
252
253
  
  static inline int audit_signal_info(int sig, struct task_struct *t)
  {
  	return 0;
  }
96368701e   Paul Moore   audit: force secc...
254
  #endif /* CONFIG_AUDIT */
312103d64   Chris Metcalf   AUDIT: make audit...
255
  #ifdef CONFIG_AUDIT_COMPAT_GENERIC
356750e35   Eric Paris   audit: define aud...
256
257
258
259
  #define audit_is_compat(arch)  (!((arch) & __AUDIT_ARCH_64BIT))
  #else
  #define audit_is_compat(arch)  false
  #endif
c9b07eab0   Al Viro   audit_inode(): sw...
260
261
262
  #define AUDIT_INODE_PARENT	1	/* dentry represents the parent */
  #define AUDIT_INODE_HIDDEN	2	/* audit record should be hidden */
  #define AUDIT_INODE_NOEVAL	4	/* audit record incomplete */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
263
  #ifdef CONFIG_AUDITSYSCALL
a9ebe0b98   Eric Paris   audit: fix build ...
264
  #include <asm/syscall.h> /* for syscall_get_arch() */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
265
266
267
  /* These are defined in auditsc.c */
  				/* Public API */
  extern int  audit_alloc(struct task_struct *task);
a4ff8dba7   Eric Paris   audit: inline aud...
268
  extern void __audit_free(struct task_struct *task);
b4f0d3755   Richard Guy Briggs   audit: x86: drop ...
269
  extern void __audit_syscall_entry(int major, unsigned long a0, unsigned long a1,
b05d8447e   Eric Paris   audit: inline aud...
270
  				  unsigned long a2, unsigned long a3);
d7e7528bc   Eric Paris   Audit: push audit...
271
  extern void __audit_syscall_exit(int ret_success, long ret_value);
7ac86265d   Jeff Layton   audit: allow audi...
272
  extern struct filename *__audit_reusename(const __user char *uptr);
91a27b2a7   Jeff Layton   vfs: define struc...
273
  extern void __audit_getname(struct filename *name);
d7481b24b   Richard Guy Briggs   audit: issue CWD ...
274
  extern void __audit_getcwd(void);
adb5c2473   Jeff Layton   audit: make audit...
275
  extern void __audit_inode(struct filename *name, const struct dentry *dentry,
79f6530cb   Jeff Layton   audit: fix mq_ope...
276
  				unsigned int flags);
9f45f5bf3   Al Viro   new helper: audit...
277
  extern void __audit_file(const struct file *);
d6335d77a   Andreas Gruenbacher   security: Make in...
278
  extern void __audit_inode_child(struct inode *parent,
4fa6b5ecb   Jeff Layton   audit: overhaul _...
279
280
  				const struct dentry *dentry,
  				const unsigned char type);
326bee028   Tyler Hicks   seccomp: Don't sp...
281
  extern void audit_seccomp(unsigned long syscall, long signr, int code);
ea6eca778   Tyler Hicks   seccomp: Audit at...
282
283
  extern void audit_seccomp_actions_logged(const char *names,
  					 const char *old_names, int res);
a5cb013da   Al Viro   [PATCH] auditing ...
284
  extern void __audit_ptrace(struct task_struct *t);
c0b0ae8a8   Richard Guy Briggs   audit: use inline...
285
286
287
288
  static inline void audit_set_context(struct task_struct *task, struct audit_context *ctx)
  {
  	task->audit_context = ctx;
  }
cdfb6b341   Richard Guy Briggs   audit: use inline...
289
290
291
292
  static inline struct audit_context *audit_context(void)
  {
  	return current->audit_context;
  }
367348104   Yaowei Bai   audit: audit_dumm...
293
  static inline bool audit_dummy_context(void)
d51374adf   Al Viro   [PATCH] mark cont...
294
  {
cdfb6b341   Richard Guy Briggs   audit: use inline...
295
  	void *p = audit_context();
d51374adf   Al Viro   [PATCH] mark cont...
296
297
  	return !p || *(int *)p;
  }
a4ff8dba7   Eric Paris   audit: inline aud...
298
299
300
301
302
  static inline void audit_free(struct task_struct *task)
  {
  	if (unlikely(task->audit_context))
  		__audit_free(task);
  }
91397401b   Eric Paris   ARCH: AUDIT: audi...
303
  static inline void audit_syscall_entry(int major, unsigned long a0,
b05d8447e   Eric Paris   audit: inline aud...
304
305
306
  				       unsigned long a1, unsigned long a2,
  				       unsigned long a3)
  {
cdfb6b341   Richard Guy Briggs   audit: use inline...
307
  	if (unlikely(audit_context()))
b4f0d3755   Richard Guy Briggs   audit: x86: drop ...
308
  		__audit_syscall_entry(major, a0, a1, a2, a3);
b05d8447e   Eric Paris   audit: inline aud...
309
  }
d7e7528bc   Eric Paris   Audit: push audit...
310
311
  static inline void audit_syscall_exit(void *pt_regs)
  {
cdfb6b341   Richard Guy Briggs   audit: use inline...
312
  	if (unlikely(audit_context())) {
d7e7528bc   Eric Paris   Audit: push audit...
313
  		int success = is_syscall_success(pt_regs);
06bdadd76   AKASHI Takahiro   audit: correct a ...
314
  		long return_code = regs_return_value(pt_regs);
d7e7528bc   Eric Paris   Audit: push audit...
315
316
317
318
  
  		__audit_syscall_exit(success, return_code);
  	}
  }
7ac86265d   Jeff Layton   audit: allow audi...
319
320
321
322
323
324
  static inline struct filename *audit_reusename(const __user char *name)
  {
  	if (unlikely(!audit_dummy_context()))
  		return __audit_reusename(name);
  	return NULL;
  }
91a27b2a7   Jeff Layton   vfs: define struc...
325
  static inline void audit_getname(struct filename *name)
d8945bb51   Al Viro   [PATCH] inline mo...
326
  {
5ac3a9c26   Al Viro   [PATCH] don't bot...
327
  	if (unlikely(!audit_dummy_context()))
d8945bb51   Al Viro   [PATCH] inline mo...
328
329
  		__audit_getname(name);
  }
d7481b24b   Richard Guy Briggs   audit: issue CWD ...
330
331
332
333
334
  static inline void audit_getcwd(void)
  {
  	if (unlikely(audit_context()))
  		__audit_getcwd();
  }
79f6530cb   Jeff Layton   audit: fix mq_ope...
335
336
  static inline void audit_inode(struct filename *name,
  				const struct dentry *dentry,
c9b07eab0   Al Viro   audit_inode(): sw...
337
338
  				unsigned int aflags) {
  	if (unlikely(!audit_dummy_context()))
57d465771   Richard Guy Briggs   audit: ignore fca...
339
  		__audit_inode(name, dentry, aflags);
79f6530cb   Jeff Layton   audit: fix mq_ope...
340
  }
9f45f5bf3   Al Viro   new helper: audit...
341
342
343
344
345
  static inline void audit_file(struct file *file)
  {
  	if (unlikely(!audit_dummy_context()))
  		__audit_file(file);
  }
79f6530cb   Jeff Layton   audit: fix mq_ope...
346
347
348
  static inline void audit_inode_parent_hidden(struct filename *name,
  						const struct dentry *dentry)
  {
5ac3a9c26   Al Viro   [PATCH] don't bot...
349
  	if (unlikely(!audit_dummy_context()))
79f6530cb   Jeff Layton   audit: fix mq_ope...
350
351
  		__audit_inode(name, dentry,
  				AUDIT_INODE_PARENT | AUDIT_INODE_HIDDEN);
73241ccca   Amy Griffis   [PATCH] Collect m...
352
  }
d6335d77a   Andreas Gruenbacher   security: Make in...
353
  static inline void audit_inode_child(struct inode *parent,
4fa6b5ecb   Jeff Layton   audit: overhaul _...
354
355
  				     const struct dentry *dentry,
  				     const unsigned char type) {
5ac3a9c26   Al Viro   [PATCH] don't bot...
356
  	if (unlikely(!audit_dummy_context()))
4fa6b5ecb   Jeff Layton   audit: overhaul _...
357
  		__audit_inode_child(parent, dentry, type);
73241ccca   Amy Griffis   [PATCH] Collect m...
358
  }
0a4ff8c25   Steve Grubb   [PATCH] Abnormal ...
359
  void audit_core_dumps(long signr);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
360

a5cb013da   Al Viro   [PATCH] auditing ...
361
362
363
364
365
  static inline void audit_ptrace(struct task_struct *t)
  {
  	if (unlikely(!audit_dummy_context()))
  		__audit_ptrace(t);
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
366
  				/* Private API (for audit.c only) */
a33e67510   Al Viro   sanitize audit_ip...
367
  extern void __audit_ipc_obj(struct kern_ipc_perm *ipcp);
2570ebbd1   Al Viro   switch kern_ipc_p...
368
  extern void __audit_ipc_set_perm(unsigned long qbytes, uid_t uid, gid_t gid, umode_t mode);
d9cfea91e   Richard Guy Briggs   audit: move audit...
369
  extern void __audit_bprm(struct linux_binprm *bprm);
2950fa9d3   Chen Gang   kernel: audit: be...
370
  extern int __audit_socketcall(int nargs, unsigned long *args);
07c494178   Eric Paris   audit: inline che...
371
  extern int __audit_sockaddr(int len, void *addr);
157cf649a   Al Viro   sanitize audit_fd...
372
  extern void __audit_fd_pair(int fd1, int fd2);
df0a42837   Al Viro   switch mq_open() ...
373
  extern void __audit_mq_open(int oflag, umode_t mode, struct mq_attr *attr);
b90477263   Deepa Dinamani   ipc: mqueue: Repl...
374
  extern void __audit_mq_sendrecv(mqd_t mqdes, size_t msg_len, unsigned int msg_prio, const struct timespec64 *abs_timeout);
20114f71b   Al Viro   sanitize audit_mq...
375
  extern void __audit_mq_notify(mqd_t mqdes, const struct sigevent *notification);
7392906ea   Al Viro   sanitize audit_mq...
376
  extern void __audit_mq_getsetattr(mqd_t mqdes, struct mq_attr *mqstat);
d84f4f992   David Howells   CRED: Inaugurate ...
377
378
379
  extern int __audit_log_bprm_fcaps(struct linux_binprm *bprm,
  				  const struct cred *new,
  				  const struct cred *old);
ca24a23eb   Eric W. Biederman   audit: Simplify a...
380
  extern void __audit_log_capset(const struct cred *new, const struct cred *old);
120a795da   Al Viro   audit mmap
381
  extern void __audit_mmap_fd(int fd, int flags);
ca86cad73   Richard Guy Briggs   audit: log module...
382
  extern void __audit_log_kern_module(char *name);
de8cd83e9   Steve Grubb   audit: Record fan...
383
  extern void __audit_fanotify(unsigned int response);
2d87a0674   Ondrej Mosnacek   timekeeping: Audi...
384
  extern void __audit_tk_injoffset(struct timespec64 offset);
7e8eda734   Ondrej Mosnacek   ntp: Audit NTP pa...
385
  extern void __audit_ntp_log(const struct audit_ntp_data *ad);
c4dad0aab   Richard Guy Briggs   audit: tidy and e...
386
  extern void __audit_log_nfcfg(const char *name, u8 af, unsigned int nentries,
142240398   Richard Guy Briggs   audit: add gfp pa...
387
  			      enum audit_nfcfgop op, gfp_t gfp);
d8945bb51   Al Viro   [PATCH] inline mo...
388

a33e67510   Al Viro   sanitize audit_ip...
389
  static inline void audit_ipc_obj(struct kern_ipc_perm *ipcp)
d8945bb51   Al Viro   [PATCH] inline mo...
390
  {
5ac3a9c26   Al Viro   [PATCH] don't bot...
391
  	if (unlikely(!audit_dummy_context()))
a33e67510   Al Viro   sanitize audit_ip...
392
  		__audit_ipc_obj(ipcp);
db3495099   Al Viro   [PATCH] AUDIT_FD_...
393
  }
157cf649a   Al Viro   sanitize audit_fd...
394
  static inline void audit_fd_pair(int fd1, int fd2)
d8945bb51   Al Viro   [PATCH] inline mo...
395
  {
5ac3a9c26   Al Viro   [PATCH] don't bot...
396
  	if (unlikely(!audit_dummy_context()))
157cf649a   Al Viro   sanitize audit_fd...
397
  		__audit_fd_pair(fd1, fd2);
d8945bb51   Al Viro   [PATCH] inline mo...
398
  }
2570ebbd1   Al Viro   switch kern_ipc_p...
399
  static inline void audit_ipc_set_perm(unsigned long qbytes, uid_t uid, gid_t gid, umode_t mode)
20ca73bc7   George C. Wilson   [PATCH] Audit of ...
400
  {
5ac3a9c26   Al Viro   [PATCH] don't bot...
401
  	if (unlikely(!audit_dummy_context()))
e816f370c   Al Viro   sanitize audit_ip...
402
  		__audit_ipc_set_perm(qbytes, uid, gid, mode);
20ca73bc7   George C. Wilson   [PATCH] Audit of ...
403
  }
9410d228a   Richard Guy Briggs   audit: call audit...
404
  static inline void audit_bprm(struct linux_binprm *bprm)
07c494178   Eric Paris   audit: inline che...
405
406
  {
  	if (unlikely(!audit_dummy_context()))
d9cfea91e   Richard Guy Briggs   audit: move audit...
407
  		__audit_bprm(bprm);
07c494178   Eric Paris   audit: inline che...
408
  }
2950fa9d3   Chen Gang   kernel: audit: be...
409
  static inline int audit_socketcall(int nargs, unsigned long *args)
07c494178   Eric Paris   audit: inline che...
410
411
  {
  	if (unlikely(!audit_dummy_context()))
2950fa9d3   Chen Gang   kernel: audit: be...
412
413
  		return __audit_socketcall(nargs, args);
  	return 0;
07c494178   Eric Paris   audit: inline che...
414
  }
62bc306e2   Richard Guy Briggs   audit: log 32-bit...
415
416
417
418
419
420
421
422
423
424
425
426
427
  
  static inline int audit_socketcall_compat(int nargs, u32 *args)
  {
  	unsigned long a[AUDITSC_ARGS];
  	int i;
  
  	if (audit_dummy_context())
  		return 0;
  
  	for (i = 0; i < nargs; i++)
  		a[i] = (unsigned long)args[i];
  	return __audit_socketcall(nargs, a);
  }
07c494178   Eric Paris   audit: inline che...
428
429
430
431
432
433
  static inline int audit_sockaddr(int len, void *addr)
  {
  	if (unlikely(!audit_dummy_context()))
  		return __audit_sockaddr(len, addr);
  	return 0;
  }
df0a42837   Al Viro   switch mq_open() ...
434
  static inline void audit_mq_open(int oflag, umode_t mode, struct mq_attr *attr)
20ca73bc7   George C. Wilson   [PATCH] Audit of ...
435
  {
5ac3a9c26   Al Viro   [PATCH] don't bot...
436
  	if (unlikely(!audit_dummy_context()))
564f6993f   Al Viro   sanitize audit_mq...
437
  		__audit_mq_open(oflag, mode, attr);
20ca73bc7   George C. Wilson   [PATCH] Audit of ...
438
  }
b90477263   Deepa Dinamani   ipc: mqueue: Repl...
439
  static inline void audit_mq_sendrecv(mqd_t mqdes, size_t msg_len, unsigned int msg_prio, const struct timespec64 *abs_timeout)
20ca73bc7   George C. Wilson   [PATCH] Audit of ...
440
  {
5ac3a9c26   Al Viro   [PATCH] don't bot...
441
  	if (unlikely(!audit_dummy_context()))
c32c8af43   Al Viro   sanitize AUDIT_MQ...
442
  		__audit_mq_sendrecv(mqdes, msg_len, msg_prio, abs_timeout);
20ca73bc7   George C. Wilson   [PATCH] Audit of ...
443
  }
20114f71b   Al Viro   sanitize audit_mq...
444
  static inline void audit_mq_notify(mqd_t mqdes, const struct sigevent *notification)
20ca73bc7   George C. Wilson   [PATCH] Audit of ...
445
  {
5ac3a9c26   Al Viro   [PATCH] don't bot...
446
  	if (unlikely(!audit_dummy_context()))
20114f71b   Al Viro   sanitize audit_mq...
447
  		__audit_mq_notify(mqdes, notification);
20ca73bc7   George C. Wilson   [PATCH] Audit of ...
448
  }
7392906ea   Al Viro   sanitize audit_mq...
449
  static inline void audit_mq_getsetattr(mqd_t mqdes, struct mq_attr *mqstat)
20ca73bc7   George C. Wilson   [PATCH] Audit of ...
450
  {
5ac3a9c26   Al Viro   [PATCH] don't bot...
451
  	if (unlikely(!audit_dummy_context()))
7392906ea   Al Viro   sanitize audit_mq...
452
  		__audit_mq_getsetattr(mqdes, mqstat);
20ca73bc7   George C. Wilson   [PATCH] Audit of ...
453
  }
3fc689e96   Eric Paris   Any time fcaps or...
454

d84f4f992   David Howells   CRED: Inaugurate ...
455
456
457
  static inline int audit_log_bprm_fcaps(struct linux_binprm *bprm,
  				       const struct cred *new,
  				       const struct cred *old)
3fc689e96   Eric Paris   Any time fcaps or...
458
459
  {
  	if (unlikely(!audit_dummy_context()))
d84f4f992   David Howells   CRED: Inaugurate ...
460
461
  		return __audit_log_bprm_fcaps(bprm, new, old);
  	return 0;
3fc689e96   Eric Paris   Any time fcaps or...
462
  }
ca24a23eb   Eric W. Biederman   audit: Simplify a...
463
  static inline void audit_log_capset(const struct cred *new,
d84f4f992   David Howells   CRED: Inaugurate ...
464
  				   const struct cred *old)
e68b75a02   Eric Paris   When the capset s...
465
466
  {
  	if (unlikely(!audit_dummy_context()))
ca24a23eb   Eric W. Biederman   audit: Simplify a...
467
  		__audit_log_capset(new, old);
e68b75a02   Eric Paris   When the capset s...
468
  }
120a795da   Al Viro   audit mmap
469
470
471
472
473
  static inline void audit_mmap_fd(int fd, int flags)
  {
  	if (unlikely(!audit_dummy_context()))
  		__audit_mmap_fd(fd, flags);
  }
ca86cad73   Richard Guy Briggs   audit: log module...
474
475
476
477
478
  static inline void audit_log_kern_module(char *name)
  {
  	if (!audit_dummy_context())
  		__audit_log_kern_module(name);
  }
de8cd83e9   Steve Grubb   audit: Record fan...
479
480
481
482
483
  static inline void audit_fanotify(unsigned int response)
  {
  	if (!audit_dummy_context())
  		__audit_fanotify(response);
  }
2d87a0674   Ondrej Mosnacek   timekeeping: Audi...
484
485
486
487
488
489
490
491
492
  static inline void audit_tk_injoffset(struct timespec64 offset)
  {
  	/* ignore no-op events */
  	if (offset.tv_sec == 0 && offset.tv_nsec == 0)
  		return;
  
  	if (!audit_dummy_context())
  		__audit_tk_injoffset(offset);
  }
7e8eda734   Ondrej Mosnacek   ntp: Audit NTP pa...
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
  static inline void audit_ntp_init(struct audit_ntp_data *ad)
  {
  	memset(ad, 0, sizeof(*ad));
  }
  
  static inline void audit_ntp_set_old(struct audit_ntp_data *ad,
  				     enum audit_ntp_type type, long long val)
  {
  	ad->vals[type].oldval = val;
  }
  
  static inline void audit_ntp_set_new(struct audit_ntp_data *ad,
  				     enum audit_ntp_type type, long long val)
  {
  	ad->vals[type].newval = val;
  }
  
  static inline void audit_ntp_log(const struct audit_ntp_data *ad)
  {
  	if (!audit_dummy_context())
  		__audit_ntp_log(ad);
  }
c4dad0aab   Richard Guy Briggs   audit: tidy and e...
515
516
  static inline void audit_log_nfcfg(const char *name, u8 af,
  				   unsigned int nentries,
142240398   Richard Guy Briggs   audit: add gfp pa...
517
  				   enum audit_nfcfgop op, gfp_t gfp)
c4dad0aab   Richard Guy Briggs   audit: tidy and e...
518
519
  {
  	if (audit_enabled)
142240398   Richard Guy Briggs   audit: add gfp pa...
520
  		__audit_log_nfcfg(name, af, nentries, op, gfp);
c4dad0aab   Richard Guy Briggs   audit: tidy and e...
521
  }
471a5c7c8   Al Viro   [PATCH] introduce...
522
  extern int audit_n_rules;
e54dc2431   Amy Griffis   [PATCH] audit sig...
523
  extern int audit_signals;
d7e7528bc   Eric Paris   Audit: push audit...
524
  #else /* CONFIG_AUDITSYSCALL */
9321d526d   Kees Cook   audit.h: replace ...
525
526
527
528
529
530
  static inline int audit_alloc(struct task_struct *task)
  {
  	return 0;
  }
  static inline void audit_free(struct task_struct *task)
  { }
91397401b   Eric Paris   ARCH: AUDIT: audi...
531
  static inline void audit_syscall_entry(int major, unsigned long a0,
9321d526d   Kees Cook   audit.h: replace ...
532
533
534
535
536
  				       unsigned long a1, unsigned long a2,
  				       unsigned long a3)
  { }
  static inline void audit_syscall_exit(void *pt_regs)
  { }
367348104   Yaowei Bai   audit: audit_dumm...
537
  static inline bool audit_dummy_context(void)
9321d526d   Kees Cook   audit.h: replace ...
538
  {
367348104   Yaowei Bai   audit: audit_dumm...
539
  	return true;
9321d526d   Kees Cook   audit.h: replace ...
540
  }
c0b0ae8a8   Richard Guy Briggs   audit: use inline...
541
542
  static inline void audit_set_context(struct task_struct *task, struct audit_context *ctx)
  { }
cdfb6b341   Richard Guy Briggs   audit: use inline...
543
544
545
546
  static inline struct audit_context *audit_context(void)
  {
  	return NULL;
  }
7ac86265d   Jeff Layton   audit: allow audi...
547
548
549
550
  static inline struct filename *audit_reusename(const __user char *name)
  {
  	return NULL;
  }
91a27b2a7   Jeff Layton   vfs: define struc...
551
  static inline void audit_getname(struct filename *name)
9321d526d   Kees Cook   audit.h: replace ...
552
  { }
d7481b24b   Richard Guy Briggs   audit: issue CWD ...
553
554
  static inline void audit_getcwd(void)
  { }
adb5c2473   Jeff Layton   audit: make audit...
555
556
  static inline void audit_inode(struct filename *name,
  				const struct dentry *dentry,
c9b07eab0   Al Viro   audit_inode(): sw...
557
  				unsigned int aflags)
9321d526d   Kees Cook   audit.h: replace ...
558
  { }
9f45f5bf3   Al Viro   new helper: audit...
559
560
561
  static inline void audit_file(struct file *file)
  {
  }
79f6530cb   Jeff Layton   audit: fix mq_ope...
562
563
564
  static inline void audit_inode_parent_hidden(struct filename *name,
  				const struct dentry *dentry)
  { }
d6335d77a   Andreas Gruenbacher   security: Make in...
565
  static inline void audit_inode_child(struct inode *parent,
4fa6b5ecb   Jeff Layton   audit: overhaul _...
566
567
  				     const struct dentry *dentry,
  				     const unsigned char type)
9321d526d   Kees Cook   audit.h: replace ...
568
569
570
  { }
  static inline void audit_core_dumps(long signr)
  { }
9321d526d   Kees Cook   audit.h: replace ...
571
572
  static inline void audit_seccomp(unsigned long syscall, long signr, int code)
  { }
ea6eca778   Tyler Hicks   seccomp: Audit at...
573
574
575
  static inline void audit_seccomp_actions_logged(const char *names,
  						const char *old_names, int res)
  { }
9321d526d   Kees Cook   audit.h: replace ...
576
577
578
579
580
  static inline void audit_ipc_obj(struct kern_ipc_perm *ipcp)
  { }
  static inline void audit_ipc_set_perm(unsigned long qbytes, uid_t uid,
  					gid_t gid, umode_t mode)
  { }
9410d228a   Richard Guy Briggs   audit: call audit...
581
582
  static inline void audit_bprm(struct linux_binprm *bprm)
  { }
2950fa9d3   Chen Gang   kernel: audit: be...
583
584
585
586
  static inline int audit_socketcall(int nargs, unsigned long *args)
  {
  	return 0;
  }
62bc306e2   Richard Guy Briggs   audit: log 32-bit...
587
588
589
590
591
  
  static inline int audit_socketcall_compat(int nargs, u32 *args)
  {
  	return 0;
  }
9321d526d   Kees Cook   audit.h: replace ...
592
593
594
595
596
597
598
599
600
601
  static inline void audit_fd_pair(int fd1, int fd2)
  { }
  static inline int audit_sockaddr(int len, void *addr)
  {
  	return 0;
  }
  static inline void audit_mq_open(int oflag, umode_t mode, struct mq_attr *attr)
  { }
  static inline void audit_mq_sendrecv(mqd_t mqdes, size_t msg_len,
  				     unsigned int msg_prio,
b90477263   Deepa Dinamani   ipc: mqueue: Repl...
602
  				     const struct timespec64 *abs_timeout)
9321d526d   Kees Cook   audit.h: replace ...
603
604
605
606
607
608
609
610
611
612
613
614
  { }
  static inline void audit_mq_notify(mqd_t mqdes,
  				   const struct sigevent *notification)
  { }
  static inline void audit_mq_getsetattr(mqd_t mqdes, struct mq_attr *mqstat)
  { }
  static inline int audit_log_bprm_fcaps(struct linux_binprm *bprm,
  				       const struct cred *new,
  				       const struct cred *old)
  {
  	return 0;
  }
ca24a23eb   Eric W. Biederman   audit: Simplify a...
615
616
  static inline void audit_log_capset(const struct cred *new,
  				    const struct cred *old)
9321d526d   Kees Cook   audit.h: replace ...
617
618
619
  { }
  static inline void audit_mmap_fd(int fd, int flags)
  { }
ca86cad73   Richard Guy Briggs   audit: log module...
620
621
622
623
  
  static inline void audit_log_kern_module(char *name)
  {
  }
de8cd83e9   Steve Grubb   audit: Record fan...
624
625
  static inline void audit_fanotify(unsigned int response)
  { }
2d87a0674   Ondrej Mosnacek   timekeeping: Audi...
626
627
  static inline void audit_tk_injoffset(struct timespec64 offset)
  { }
7e8eda734   Ondrej Mosnacek   ntp: Audit NTP pa...
628
629
630
631
632
633
634
635
636
637
638
639
640
  static inline void audit_ntp_init(struct audit_ntp_data *ad)
  { }
  
  static inline void audit_ntp_set_old(struct audit_ntp_data *ad,
  				     enum audit_ntp_type type, long long val)
  { }
  
  static inline void audit_ntp_set_new(struct audit_ntp_data *ad,
  				     enum audit_ntp_type type, long long val)
  { }
  
  static inline void audit_ntp_log(const struct audit_ntp_data *ad)
  { }
9321d526d   Kees Cook   audit.h: replace ...
641
642
  static inline void audit_ptrace(struct task_struct *t)
  { }
c4dad0aab   Richard Guy Briggs   audit: tidy and e...
643
644
645
  
  static inline void audit_log_nfcfg(const char *name, u8 af,
  				   unsigned int nentries,
142240398   Richard Guy Briggs   audit: add gfp pa...
646
  				   enum audit_nfcfgop op, gfp_t gfp)
c4dad0aab   Richard Guy Briggs   audit: tidy and e...
647
  { }
471a5c7c8   Al Viro   [PATCH] introduce...
648
  #define audit_n_rules 0
e54dc2431   Amy Griffis   [PATCH] audit sig...
649
  #define audit_signals 0
d7e7528bc   Eric Paris   Audit: push audit...
650
  #endif /* CONFIG_AUDITSYSCALL */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
651

780a7654c   Eric W. Biederman   audit: Make testi...
652
653
654
655
  static inline bool audit_loginuid_set(struct task_struct *tsk)
  {
  	return uid_valid(audit_get_loginuid(tsk));
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
656
  #endif