Blame view

include/linux/audit.h 16.8 KB
85c8721ff   David Woodhouse   audit: update poi...
1
  /* audit.h -- Auditing support
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
   *
   * Copyright 2003-2004 Red Hat Inc., Durham, North Carolina.
   * All Rights Reserved.
   *
   * This program is free software; you can redistribute it and/or modify
   * it under the terms of the GNU General Public License as published by
   * the Free Software Foundation; either version 2 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   * GNU General Public License for more details.
   *
   * You should have received a copy of the GNU General Public License
   * along with this program; if not, write to the Free Software
   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   *
   * Written by Rickard E. (Rik) Faith <faith@redhat.com>
   *
   */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
23
24
  #ifndef _LINUX_AUDIT_H_
  #define _LINUX_AUDIT_H_
f001e47f8   David Woodhouse   Sanitise linux/au...
25
  #include <linux/sched.h>
c0a3a20b6   Mike Frysinger   linux/audit.h: mo...
26
  #include <linux/ptrace.h>
607ca46e9   David Howells   UAPI: (Scripted) ...
27
  #include <uapi/linux/audit.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
28

84cb777e6   Richard Guy Briggs   audit: use macros...
29
30
  #define AUDIT_INO_UNSET ((unsigned long)-1)
  #define AUDIT_DEV_UNSET ((dev_t)-1)
c2f0c7c35   Steve Grubb   The attached patc...
31
32
33
  struct audit_sig_info {
  	uid_t		uid;
  	pid_t		pid;
e1396065e   Al Viro   [PATCH] collect s...
34
  	char		ctx[0];
c2f0c7c35   Steve Grubb   The attached patc...
35
  };
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
36
37
38
  struct audit_buffer;
  struct audit_context;
  struct inode;
5bb289b5a   David Woodhouse   AUDIT: Clean up u...
39
  struct netlink_skb_parms;
37721e1b0   Alexey Dobriyan   headers: path.h r...
40
  struct path;
473ae30bc   Al Viro   [PATCH] execve ar...
41
  struct linux_binprm;
20ca73bc7   George C. Wilson   [PATCH] Audit of ...
42
43
  struct mq_attr;
  struct mqstat;
9d57a7f9e   Ahmed S. Darwish   SELinux: use new ...
44
45
  struct audit_watch;
  struct audit_tree;
099dd2351   Eric W. Biederman   audit: Send repli...
46
  struct sk_buff;
9d57a7f9e   Ahmed S. Darwish   SELinux: use new ...
47
48
  
  struct audit_krule {
041d7b98f   Richard Guy Briggs   audit: restore AU...
49
  	u32			pflags;
9d57a7f9e   Ahmed S. Darwish   SELinux: use new ...
50
51
52
53
54
55
56
57
58
59
60
61
  	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 ...
62
  	struct audit_fsnotify_mark	*exe;
9d57a7f9e   Ahmed S. Darwish   SELinux: use new ...
63
  	struct list_head	rlist;	/* entry in audit_{watch,tree}.rules list */
e45aa212e   Al Viro   audit rules order...
64
  	struct list_head	list;	/* for AUDIT_LIST* purposes only */
0590b9335   Al Viro   fixing audit rule...
65
  	u64			prio;
9d57a7f9e   Ahmed S. Darwish   SELinux: use new ...
66
  };
041d7b98f   Richard Guy Briggs   audit: restore AU...
67
68
  /* Flag to indicate legacy AUDIT_LOGINUID unset usage */
  #define AUDIT_LOGINUID_LEGACY		0x1
9d57a7f9e   Ahmed S. Darwish   SELinux: use new ...
69
70
  struct audit_field {
  	u32				type;
219ca3942   Richard Guy Briggs   audit: use union ...
71
72
73
74
75
76
77
78
79
  	union {
  		u32			val;
  		kuid_t			uid;
  		kgid_t			gid;
  		struct {
  			char		*lsm_str;
  			void		*lsm_rule;
  		};
  	};
9d57a7f9e   Ahmed S. Darwish   SELinux: use new ...
80
  	u32				op;
9d57a7f9e   Ahmed S. Darwish   SELinux: use new ...
81
  };
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
82

b0fed4021   Eric Paris   audit: implement ...
83
  extern int is_audit_feature_set(int which);
b915543b4   Al Viro   [PATCH] audit sys...
84
  extern int __init audit_register_class(int class, unsigned *list);
55669bfa1   Al Viro   [PATCH] audit: AU...
85
  extern int audit_classify_syscall(int abi, unsigned syscall);
e54dc2431   Amy Griffis   [PATCH] audit sig...
86
  extern int audit_classify_arch(int arch);
4b5884114   AKASHI Takahiro   audit: Add generi...
87
88
89
90
91
92
  /* 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...
93
  extern int audit_classify_compat_syscall(int abi, unsigned syscall);
78e2e802a   Jeff Layton   audit: add a new ...
94
95
96
97
  
  /* 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...
98
  #define	AUDIT_TYPE_PARENT	2	/* a parent audit record */
4fa6b5ecb   Jeff Layton   audit: overhaul _...
99
100
  #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 ...
101

2950fa9d3   Chen Gang   kernel: audit: be...
102
103
  /* maximized args number that audit_socketcall can process */
  #define AUDITSC_ARGS		6
2e28d38ae   Peter Hurley   tty: audit: Handl...
104
105
106
  /* 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...
107
  struct filename;
4d3fb709b   Eric Paris   helper for some s...
108
  extern void audit_log_session_info(struct audit_buffer *ab);
96368701e   Paul Moore   audit: force secc...
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
  #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);
  extern void		    audit_log_link_denied(const char *operation,
  						  struct path *link);
  extern void		    audit_log_lost(const char *message);
  #ifdef CONFIG_SECURITY
  extern void 		    audit_log_secctx(struct audit_buffer *ab, u32 secid);
  #else
  static inline void	    audit_log_secctx(struct audit_buffer *ab, u32 secid)
  { }
  #endif
  
  extern int audit_log_task_context(struct audit_buffer *ab);
  extern void audit_log_task_info(struct audit_buffer *ab,
  				struct task_struct *tsk);
  
  extern int		    audit_update_lsm_rules(void);
  
  				/* Private API (for audit.c only) */
96368701e   Paul Moore   audit: force secc...
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
  extern int audit_rule_change(int type, __u32 portid, int seq,
  				void *data, size_t datasz);
  extern int audit_list_rules_send(struct sk_buff *request_skb, int seq);
  
  extern u32 audit_enabled;
  #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)
  { }
  static inline void audit_log_link_denied(const char *string,
  					 const struct path *link)
  { }
  static inline void audit_log_secctx(struct audit_buffer *ab, u32 secid)
  { }
  static inline int audit_log_task_context(struct audit_buffer *ab)
  {
  	return 0;
  }
  static inline void audit_log_task_info(struct audit_buffer *ab,
  				       struct task_struct *tsk)
  { }
  #define audit_enabled 0
  #endif /* CONFIG_AUDIT */
312103d64   Chris Metcalf   AUDIT: make audit...
207
  #ifdef CONFIG_AUDIT_COMPAT_GENERIC
356750e35   Eric Paris   audit: define aud...
208
209
210
211
  #define audit_is_compat(arch)  (!((arch) & __AUDIT_ARCH_64BIT))
  #else
  #define audit_is_compat(arch)  false
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
212
  #ifdef CONFIG_AUDITSYSCALL
a9ebe0b98   Eric Paris   audit: fix build ...
213
  #include <asm/syscall.h> /* for syscall_get_arch() */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
214
215
216
  /* These are defined in auditsc.c */
  				/* Public API */
  extern int  audit_alloc(struct task_struct *task);
a4ff8dba7   Eric Paris   audit: inline aud...
217
  extern void __audit_free(struct task_struct *task);
b4f0d3755   Richard Guy Briggs   audit: x86: drop ...
218
  extern void __audit_syscall_entry(int major, unsigned long a0, unsigned long a1,
b05d8447e   Eric Paris   audit: inline aud...
219
  				  unsigned long a2, unsigned long a3);
d7e7528bc   Eric Paris   Audit: push audit...
220
  extern void __audit_syscall_exit(int ret_success, long ret_value);
7ac86265d   Jeff Layton   audit: allow audi...
221
  extern struct filename *__audit_reusename(const __user char *uptr);
91a27b2a7   Jeff Layton   vfs: define struc...
222
  extern void __audit_getname(struct filename *name);
79f6530cb   Jeff Layton   audit: fix mq_ope...
223
224
225
  
  #define AUDIT_INODE_PARENT	1	/* dentry represents the parent */
  #define AUDIT_INODE_HIDDEN	2	/* audit record should be hidden */
adb5c2473   Jeff Layton   audit: make audit...
226
  extern void __audit_inode(struct filename *name, const struct dentry *dentry,
79f6530cb   Jeff Layton   audit: fix mq_ope...
227
  				unsigned int flags);
9f45f5bf3   Al Viro   new helper: audit...
228
  extern void __audit_file(const struct file *);
d6335d77a   Andreas Gruenbacher   security: Make in...
229
  extern void __audit_inode_child(struct inode *parent,
4fa6b5ecb   Jeff Layton   audit: overhaul _...
230
231
  				const struct dentry *dentry,
  				const unsigned char type);
3dc1c1b2d   Kees Cook   seccomp: remove d...
232
  extern void __audit_seccomp(unsigned long syscall, long signr, int code);
a5cb013da   Al Viro   [PATCH] auditing ...
233
  extern void __audit_ptrace(struct task_struct *t);
367348104   Yaowei Bai   audit: audit_dumm...
234
  static inline bool audit_dummy_context(void)
d51374adf   Al Viro   [PATCH] mark cont...
235
236
237
238
  {
  	void *p = current->audit_context;
  	return !p || *(int *)p;
  }
a4ff8dba7   Eric Paris   audit: inline aud...
239
240
241
242
243
  static inline void audit_free(struct task_struct *task)
  {
  	if (unlikely(task->audit_context))
  		__audit_free(task);
  }
91397401b   Eric Paris   ARCH: AUDIT: audi...
244
  static inline void audit_syscall_entry(int major, unsigned long a0,
b05d8447e   Eric Paris   audit: inline aud...
245
246
247
  				       unsigned long a1, unsigned long a2,
  				       unsigned long a3)
  {
cdee3904b   Anton Blanchard   audit: Syscall ru...
248
  	if (unlikely(current->audit_context))
b4f0d3755   Richard Guy Briggs   audit: x86: drop ...
249
  		__audit_syscall_entry(major, a0, a1, a2, a3);
b05d8447e   Eric Paris   audit: inline aud...
250
  }
d7e7528bc   Eric Paris   Audit: push audit...
251
252
253
254
  static inline void audit_syscall_exit(void *pt_regs)
  {
  	if (unlikely(current->audit_context)) {
  		int success = is_syscall_success(pt_regs);
06bdadd76   AKASHI Takahiro   audit: correct a ...
255
  		long return_code = regs_return_value(pt_regs);
d7e7528bc   Eric Paris   Audit: push audit...
256
257
258
259
  
  		__audit_syscall_exit(success, return_code);
  	}
  }
7ac86265d   Jeff Layton   audit: allow audi...
260
261
262
263
264
265
  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...
266
  static inline void audit_getname(struct filename *name)
d8945bb51   Al Viro   [PATCH] inline mo...
267
  {
5ac3a9c26   Al Viro   [PATCH] don't bot...
268
  	if (unlikely(!audit_dummy_context()))
d8945bb51   Al Viro   [PATCH] inline mo...
269
270
  		__audit_getname(name);
  }
79f6530cb   Jeff Layton   audit: fix mq_ope...
271
272
  static inline void audit_inode(struct filename *name,
  				const struct dentry *dentry,
bfcec7087   Jeff Layton   audit: set the na...
273
  				unsigned int parent) {
79f6530cb   Jeff Layton   audit: fix mq_ope...
274
275
276
277
278
279
280
  	if (unlikely(!audit_dummy_context())) {
  		unsigned int flags = 0;
  		if (parent)
  			flags |= AUDIT_INODE_PARENT;
  		__audit_inode(name, dentry, flags);
  	}
  }
9f45f5bf3   Al Viro   new helper: audit...
281
282
283
284
285
  static inline void audit_file(struct file *file)
  {
  	if (unlikely(!audit_dummy_context()))
  		__audit_file(file);
  }
79f6530cb   Jeff Layton   audit: fix mq_ope...
286
287
288
  static inline void audit_inode_parent_hidden(struct filename *name,
  						const struct dentry *dentry)
  {
5ac3a9c26   Al Viro   [PATCH] don't bot...
289
  	if (unlikely(!audit_dummy_context()))
79f6530cb   Jeff Layton   audit: fix mq_ope...
290
291
  		__audit_inode(name, dentry,
  				AUDIT_INODE_PARENT | AUDIT_INODE_HIDDEN);
73241ccca   Amy Griffis   [PATCH] Collect m...
292
  }
d6335d77a   Andreas Gruenbacher   security: Make in...
293
  static inline void audit_inode_child(struct inode *parent,
4fa6b5ecb   Jeff Layton   audit: overhaul _...
294
295
  				     const struct dentry *dentry,
  				     const unsigned char type) {
5ac3a9c26   Al Viro   [PATCH] don't bot...
296
  	if (unlikely(!audit_dummy_context()))
4fa6b5ecb   Jeff Layton   audit: overhaul _...
297
  		__audit_inode_child(parent, dentry, type);
73241ccca   Amy Griffis   [PATCH] Collect m...
298
  }
0a4ff8c25   Steve Grubb   [PATCH] Abnormal ...
299
  void audit_core_dumps(long signr);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
300

3dc1c1b2d   Kees Cook   seccomp: remove d...
301
  static inline void audit_seccomp(unsigned long syscall, long signr, int code)
85e7bac33   Eric Paris   seccomp: audit ab...
302
  {
96368701e   Paul Moore   audit: force secc...
303
304
  	if (!audit_enabled)
  		return;
7b9205bd7   Kees Cook   audit: create exp...
305
306
  	/* Force a record to be reported if a signal was delivered. */
  	if (signr || unlikely(!audit_dummy_context()))
3dc1c1b2d   Kees Cook   seccomp: remove d...
307
  		__audit_seccomp(syscall, signr, code);
85e7bac33   Eric Paris   seccomp: audit ab...
308
  }
a5cb013da   Al Viro   [PATCH] auditing ...
309
310
311
312
313
  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
314
  				/* Private API (for audit.c only) */
bfb4496e7   David Woodhouse   AUDIT: Assign ser...
315
  extern unsigned int audit_serial(void);
48887e63d   Al Viro   [PATCH] fix broke...
316
  extern int auditsc_get_stamp(struct audit_context *ctx,
bfb4496e7   David Woodhouse   AUDIT: Assign ser...
317
  			      struct timespec *t, unsigned int *serial);
9321d526d   Kees Cook   audit.h: replace ...
318
319
320
321
322
323
  extern int audit_set_loginuid(kuid_t loginuid);
  
  static inline kuid_t audit_get_loginuid(struct task_struct *tsk)
  {
  	return tsk->loginuid;
  }
b6cfee4cc   Richard Guy Briggs   audit: fix incorr...
324
  static inline unsigned int audit_get_sessionid(struct task_struct *tsk)
9321d526d   Kees Cook   audit.h: replace ...
325
326
327
  {
  	return tsk->sessionid;
  }
a33e67510   Al Viro   sanitize audit_ip...
328
  extern void __audit_ipc_obj(struct kern_ipc_perm *ipcp);
2570ebbd1   Al Viro   switch kern_ipc_p...
329
  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...
330
  extern void __audit_bprm(struct linux_binprm *bprm);
2950fa9d3   Chen Gang   kernel: audit: be...
331
  extern int __audit_socketcall(int nargs, unsigned long *args);
07c494178   Eric Paris   audit: inline che...
332
  extern int __audit_sockaddr(int len, void *addr);
157cf649a   Al Viro   sanitize audit_fd...
333
  extern void __audit_fd_pair(int fd1, int fd2);
df0a42837   Al Viro   switch mq_open() ...
334
  extern void __audit_mq_open(int oflag, umode_t mode, struct mq_attr *attr);
c32c8af43   Al Viro   sanitize AUDIT_MQ...
335
  extern void __audit_mq_sendrecv(mqd_t mqdes, size_t msg_len, unsigned int msg_prio, const struct timespec *abs_timeout);
20114f71b   Al Viro   sanitize audit_mq...
336
  extern void __audit_mq_notify(mqd_t mqdes, const struct sigevent *notification);
7392906ea   Al Viro   sanitize audit_mq...
337
  extern void __audit_mq_getsetattr(mqd_t mqdes, struct mq_attr *mqstat);
d84f4f992   David Howells   CRED: Inaugurate ...
338
339
340
  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...
341
  extern void __audit_log_capset(const struct cred *new, const struct cred *old);
120a795da   Al Viro   audit mmap
342
  extern void __audit_mmap_fd(int fd, int flags);
d8945bb51   Al Viro   [PATCH] inline mo...
343

a33e67510   Al Viro   sanitize audit_ip...
344
  static inline void audit_ipc_obj(struct kern_ipc_perm *ipcp)
d8945bb51   Al Viro   [PATCH] inline mo...
345
  {
5ac3a9c26   Al Viro   [PATCH] don't bot...
346
  	if (unlikely(!audit_dummy_context()))
a33e67510   Al Viro   sanitize audit_ip...
347
  		__audit_ipc_obj(ipcp);
db3495099   Al Viro   [PATCH] AUDIT_FD_...
348
  }
157cf649a   Al Viro   sanitize audit_fd...
349
  static inline void audit_fd_pair(int fd1, int fd2)
d8945bb51   Al Viro   [PATCH] inline mo...
350
  {
5ac3a9c26   Al Viro   [PATCH] don't bot...
351
  	if (unlikely(!audit_dummy_context()))
157cf649a   Al Viro   sanitize audit_fd...
352
  		__audit_fd_pair(fd1, fd2);
d8945bb51   Al Viro   [PATCH] inline mo...
353
  }
2570ebbd1   Al Viro   switch kern_ipc_p...
354
  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 ...
355
  {
5ac3a9c26   Al Viro   [PATCH] don't bot...
356
  	if (unlikely(!audit_dummy_context()))
e816f370c   Al Viro   sanitize audit_ip...
357
  		__audit_ipc_set_perm(qbytes, uid, gid, mode);
20ca73bc7   George C. Wilson   [PATCH] Audit of ...
358
  }
9410d228a   Richard Guy Briggs   audit: call audit...
359
  static inline void audit_bprm(struct linux_binprm *bprm)
07c494178   Eric Paris   audit: inline che...
360
361
  {
  	if (unlikely(!audit_dummy_context()))
d9cfea91e   Richard Guy Briggs   audit: move audit...
362
  		__audit_bprm(bprm);
07c494178   Eric Paris   audit: inline che...
363
  }
2950fa9d3   Chen Gang   kernel: audit: be...
364
  static inline int audit_socketcall(int nargs, unsigned long *args)
07c494178   Eric Paris   audit: inline che...
365
366
  {
  	if (unlikely(!audit_dummy_context()))
2950fa9d3   Chen Gang   kernel: audit: be...
367
368
  		return __audit_socketcall(nargs, args);
  	return 0;
07c494178   Eric Paris   audit: inline che...
369
370
371
372
373
374
375
  }
  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() ...
376
  static inline void audit_mq_open(int oflag, umode_t mode, struct mq_attr *attr)
20ca73bc7   George C. Wilson   [PATCH] Audit of ...
377
  {
5ac3a9c26   Al Viro   [PATCH] don't bot...
378
  	if (unlikely(!audit_dummy_context()))
564f6993f   Al Viro   sanitize audit_mq...
379
  		__audit_mq_open(oflag, mode, attr);
20ca73bc7   George C. Wilson   [PATCH] Audit of ...
380
  }
c32c8af43   Al Viro   sanitize AUDIT_MQ...
381
  static inline void audit_mq_sendrecv(mqd_t mqdes, size_t msg_len, unsigned int msg_prio, const struct timespec *abs_timeout)
20ca73bc7   George C. Wilson   [PATCH] Audit of ...
382
  {
5ac3a9c26   Al Viro   [PATCH] don't bot...
383
  	if (unlikely(!audit_dummy_context()))
c32c8af43   Al Viro   sanitize AUDIT_MQ...
384
  		__audit_mq_sendrecv(mqdes, msg_len, msg_prio, abs_timeout);
20ca73bc7   George C. Wilson   [PATCH] Audit of ...
385
  }
20114f71b   Al Viro   sanitize audit_mq...
386
  static inline void audit_mq_notify(mqd_t mqdes, const struct sigevent *notification)
20ca73bc7   George C. Wilson   [PATCH] Audit of ...
387
  {
5ac3a9c26   Al Viro   [PATCH] don't bot...
388
  	if (unlikely(!audit_dummy_context()))
20114f71b   Al Viro   sanitize audit_mq...
389
  		__audit_mq_notify(mqdes, notification);
20ca73bc7   George C. Wilson   [PATCH] Audit of ...
390
  }
7392906ea   Al Viro   sanitize audit_mq...
391
  static inline void audit_mq_getsetattr(mqd_t mqdes, struct mq_attr *mqstat)
20ca73bc7   George C. Wilson   [PATCH] Audit of ...
392
  {
5ac3a9c26   Al Viro   [PATCH] don't bot...
393
  	if (unlikely(!audit_dummy_context()))
7392906ea   Al Viro   sanitize audit_mq...
394
  		__audit_mq_getsetattr(mqdes, mqstat);
20ca73bc7   George C. Wilson   [PATCH] Audit of ...
395
  }
3fc689e96   Eric Paris   Any time fcaps or...
396

d84f4f992   David Howells   CRED: Inaugurate ...
397
398
399
  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...
400
401
  {
  	if (unlikely(!audit_dummy_context()))
d84f4f992   David Howells   CRED: Inaugurate ...
402
403
  		return __audit_log_bprm_fcaps(bprm, new, old);
  	return 0;
3fc689e96   Eric Paris   Any time fcaps or...
404
  }
ca24a23eb   Eric W. Biederman   audit: Simplify a...
405
  static inline void audit_log_capset(const struct cred *new,
d84f4f992   David Howells   CRED: Inaugurate ...
406
  				   const struct cred *old)
e68b75a02   Eric Paris   When the capset s...
407
408
  {
  	if (unlikely(!audit_dummy_context()))
ca24a23eb   Eric W. Biederman   audit: Simplify a...
409
  		__audit_log_capset(new, old);
e68b75a02   Eric Paris   When the capset s...
410
  }
120a795da   Al Viro   audit mmap
411
412
413
414
415
  static inline void audit_mmap_fd(int fd, int flags)
  {
  	if (unlikely(!audit_dummy_context()))
  		__audit_mmap_fd(fd, flags);
  }
471a5c7c8   Al Viro   [PATCH] introduce...
416
  extern int audit_n_rules;
e54dc2431   Amy Griffis   [PATCH] audit sig...
417
  extern int audit_signals;
d7e7528bc   Eric Paris   Audit: push audit...
418
  #else /* CONFIG_AUDITSYSCALL */
9321d526d   Kees Cook   audit.h: replace ...
419
420
421
422
423
424
  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...
425
  static inline void audit_syscall_entry(int major, unsigned long a0,
9321d526d   Kees Cook   audit.h: replace ...
426
427
428
429
430
  				       unsigned long a1, unsigned long a2,
  				       unsigned long a3)
  { }
  static inline void audit_syscall_exit(void *pt_regs)
  { }
367348104   Yaowei Bai   audit: audit_dumm...
431
  static inline bool audit_dummy_context(void)
9321d526d   Kees Cook   audit.h: replace ...
432
  {
367348104   Yaowei Bai   audit: audit_dumm...
433
  	return true;
9321d526d   Kees Cook   audit.h: replace ...
434
  }
7ac86265d   Jeff Layton   audit: allow audi...
435
436
437
438
  static inline struct filename *audit_reusename(const __user char *name)
  {
  	return NULL;
  }
91a27b2a7   Jeff Layton   vfs: define struc...
439
  static inline void audit_getname(struct filename *name)
9321d526d   Kees Cook   audit.h: replace ...
440
  { }
adb5c2473   Jeff Layton   audit: make audit...
441
442
  static inline void __audit_inode(struct filename *name,
  					const struct dentry *dentry,
79f6530cb   Jeff Layton   audit: fix mq_ope...
443
  					unsigned int flags)
9321d526d   Kees Cook   audit.h: replace ...
444
  { }
d6335d77a   Andreas Gruenbacher   security: Make in...
445
  static inline void __audit_inode_child(struct inode *parent,
4fa6b5ecb   Jeff Layton   audit: overhaul _...
446
447
  					const struct dentry *dentry,
  					const unsigned char type)
9321d526d   Kees Cook   audit.h: replace ...
448
  { }
adb5c2473   Jeff Layton   audit: make audit...
449
450
  static inline void audit_inode(struct filename *name,
  				const struct dentry *dentry,
bfcec7087   Jeff Layton   audit: set the na...
451
  				unsigned int parent)
9321d526d   Kees Cook   audit.h: replace ...
452
  { }
9f45f5bf3   Al Viro   new helper: audit...
453
454
455
  static inline void audit_file(struct file *file)
  {
  }
79f6530cb   Jeff Layton   audit: fix mq_ope...
456
457
458
  static inline void audit_inode_parent_hidden(struct filename *name,
  				const struct dentry *dentry)
  { }
d6335d77a   Andreas Gruenbacher   security: Make in...
459
  static inline void audit_inode_child(struct inode *parent,
4fa6b5ecb   Jeff Layton   audit: overhaul _...
460
461
  				     const struct dentry *dentry,
  				     const unsigned char type)
9321d526d   Kees Cook   audit.h: replace ...
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
  { }
  static inline void audit_core_dumps(long signr)
  { }
  static inline void __audit_seccomp(unsigned long syscall, long signr, int code)
  { }
  static inline void audit_seccomp(unsigned long syscall, long signr, int code)
  { }
  static inline int auditsc_get_stamp(struct audit_context *ctx,
  			      struct timespec *t, unsigned int *serial)
  {
  	return 0;
  }
  static inline kuid_t audit_get_loginuid(struct task_struct *tsk)
  {
  	return INVALID_UID;
  }
b6cfee4cc   Richard Guy Briggs   audit: fix incorr...
478
  static inline unsigned int audit_get_sessionid(struct task_struct *tsk)
9321d526d   Kees Cook   audit.h: replace ...
479
480
481
  {
  	return -1;
  }
9321d526d   Kees Cook   audit.h: replace ...
482
483
484
485
486
  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...
487
488
  static inline void audit_bprm(struct linux_binprm *bprm)
  { }
2950fa9d3   Chen Gang   kernel: audit: be...
489
490
491
492
  static inline int audit_socketcall(int nargs, unsigned long *args)
  {
  	return 0;
  }
9321d526d   Kees Cook   audit.h: replace ...
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
  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,
  				     const struct timespec *abs_timeout)
  { }
  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...
516
517
  static inline void audit_log_capset(const struct cred *new,
  				    const struct cred *old)
9321d526d   Kees Cook   audit.h: replace ...
518
519
520
521
522
  { }
  static inline void audit_mmap_fd(int fd, int flags)
  { }
  static inline void audit_ptrace(struct task_struct *t)
  { }
471a5c7c8   Al Viro   [PATCH] introduce...
523
  #define audit_n_rules 0
e54dc2431   Amy Griffis   [PATCH] audit sig...
524
  #define audit_signals 0
d7e7528bc   Eric Paris   Audit: push audit...
525
  #endif /* CONFIG_AUDITSYSCALL */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
526

780a7654c   Eric W. Biederman   audit: Make testi...
527
528
529
530
  static inline bool audit_loginuid_set(struct task_struct *tsk)
  {
  	return uid_valid(audit_get_loginuid(tsk));
  }
9321d526d   Kees Cook   audit.h: replace ...
531
532
533
534
  static inline void audit_log_string(struct audit_buffer *ab, const char *buf)
  {
  	audit_log_n_string(ab, buf, strlen(buf));
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
535
  #endif