aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/audit.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/audit.h')
-rw-r--r--include/linux/audit.h54
1 files changed, 40 insertions, 14 deletions
diff --git a/include/linux/audit.h b/include/linux/audit.h
index b27d7debc5a1..40a6c26294ae 100644
--- a/include/linux/audit.h
+++ b/include/linux/audit.h
@@ -132,6 +132,10 @@
132#define AUDIT_CLASS_DIR_WRITE_32 1 132#define AUDIT_CLASS_DIR_WRITE_32 1
133#define AUDIT_CLASS_CHATTR 2 133#define AUDIT_CLASS_CHATTR 2
134#define AUDIT_CLASS_CHATTR_32 3 134#define AUDIT_CLASS_CHATTR_32 3
135#define AUDIT_CLASS_READ 4
136#define AUDIT_CLASS_READ_32 5
137#define AUDIT_CLASS_WRITE 6
138#define AUDIT_CLASS_WRITE_32 7
135 139
136/* This bitmask is used to validate user input. It represents all bits that 140/* This bitmask is used to validate user input. It represents all bits that
137 * are currently used in an audit field constant understood by the kernel. 141 * are currently used in an audit field constant understood by the kernel.
@@ -177,6 +181,7 @@
177#define AUDIT_EXIT 103 181#define AUDIT_EXIT 103
178#define AUDIT_SUCCESS 104 /* exit >= 0; value ignored */ 182#define AUDIT_SUCCESS 104 /* exit >= 0; value ignored */
179#define AUDIT_WATCH 105 183#define AUDIT_WATCH 105
184#define AUDIT_PERM 106
180 185
181#define AUDIT_ARG0 200 186#define AUDIT_ARG0 200
182#define AUDIT_ARG1 (AUDIT_ARG0+1) 187#define AUDIT_ARG1 (AUDIT_ARG0+1)
@@ -252,6 +257,11 @@
252#define AUDIT_ARCH_V850 (EM_V850|__AUDIT_ARCH_LE) 257#define AUDIT_ARCH_V850 (EM_V850|__AUDIT_ARCH_LE)
253#define AUDIT_ARCH_X86_64 (EM_X86_64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE) 258#define AUDIT_ARCH_X86_64 (EM_X86_64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
254 259
260#define AUDIT_PERM_EXEC 1
261#define AUDIT_PERM_WRITE 2
262#define AUDIT_PERM_READ 4
263#define AUDIT_PERM_ATTR 8
264
255struct audit_status { 265struct audit_status {
256 __u32 mask; /* Bit mask for valid entries */ 266 __u32 mask; /* Bit mask for valid entries */
257 __u32 enabled; /* 1 = enabled, 0 = disabled */ 267 __u32 enabled; /* 1 = enabled, 0 = disabled */
@@ -314,6 +324,7 @@ struct mqstat;
314#define AUDITSC_FAILURE 2 324#define AUDITSC_FAILURE 2
315#define AUDITSC_RESULT(x) ( ((long)(x))<0?AUDITSC_FAILURE:AUDITSC_SUCCESS ) 325#define AUDITSC_RESULT(x) ( ((long)(x))<0?AUDITSC_FAILURE:AUDITSC_SUCCESS )
316extern int __init audit_register_class(int class, unsigned *list); 326extern int __init audit_register_class(int class, unsigned *list);
327extern int audit_classify_syscall(int abi, unsigned syscall);
317#ifdef CONFIG_AUDITSYSCALL 328#ifdef CONFIG_AUDITSYSCALL
318/* These are defined in auditsc.c */ 329/* These are defined in auditsc.c */
319 /* Public API */ 330 /* Public API */
@@ -327,21 +338,31 @@ extern void __audit_getname(const char *name);
327extern void audit_putname(const char *name); 338extern void audit_putname(const char *name);
328extern void __audit_inode(const char *name, const struct inode *inode); 339extern void __audit_inode(const char *name, const struct inode *inode);
329extern void __audit_inode_child(const char *dname, const struct inode *inode, 340extern void __audit_inode_child(const char *dname, const struct inode *inode,
330 unsigned long pino); 341 const struct inode *parent);
342extern void __audit_inode_update(const struct inode *inode);
343static inline int audit_dummy_context(void)
344{
345 void *p = current->audit_context;
346 return !p || *(int *)p;
347}
331static inline void audit_getname(const char *name) 348static inline void audit_getname(const char *name)
332{ 349{
333 if (unlikely(current->audit_context)) 350 if (unlikely(!audit_dummy_context()))
334 __audit_getname(name); 351 __audit_getname(name);
335} 352}
336static inline void audit_inode(const char *name, const struct inode *inode) { 353static inline void audit_inode(const char *name, const struct inode *inode) {
337 if (unlikely(current->audit_context)) 354 if (unlikely(!audit_dummy_context()))
338 __audit_inode(name, inode); 355 __audit_inode(name, inode);
339} 356}
340static inline void audit_inode_child(const char *dname, 357static inline void audit_inode_child(const char *dname,
341 const struct inode *inode, 358 const struct inode *inode,
342 unsigned long pino) { 359 const struct inode *parent) {
343 if (unlikely(current->audit_context)) 360 if (unlikely(!audit_dummy_context()))
344 __audit_inode_child(dname, inode, pino); 361 __audit_inode_child(dname, inode, parent);
362}
363static inline void audit_inode_update(const struct inode *inode) {
364 if (unlikely(!audit_dummy_context()))
365 __audit_inode_update(inode);
345} 366}
346 367
347 /* Private API (for audit.c only) */ 368 /* Private API (for audit.c only) */
@@ -365,57 +386,61 @@ extern int __audit_mq_getsetattr(mqd_t mqdes, struct mq_attr *mqstat);
365 386
366static inline int audit_ipc_obj(struct kern_ipc_perm *ipcp) 387static inline int audit_ipc_obj(struct kern_ipc_perm *ipcp)
367{ 388{
368 if (unlikely(current->audit_context)) 389 if (unlikely(!audit_dummy_context()))
369 return __audit_ipc_obj(ipcp); 390 return __audit_ipc_obj(ipcp);
370 return 0; 391 return 0;
371} 392}
372static inline int audit_ipc_set_perm(unsigned long qbytes, uid_t uid, gid_t gid, mode_t mode) 393static inline int audit_ipc_set_perm(unsigned long qbytes, uid_t uid, gid_t gid, mode_t mode)
373{ 394{
374 if (unlikely(current->audit_context)) 395 if (unlikely(!audit_dummy_context()))
375 return __audit_ipc_set_perm(qbytes, uid, gid, mode); 396 return __audit_ipc_set_perm(qbytes, uid, gid, mode);
376 return 0; 397 return 0;
377} 398}
378static inline int audit_mq_open(int oflag, mode_t mode, struct mq_attr __user *u_attr) 399static inline int audit_mq_open(int oflag, mode_t mode, struct mq_attr __user *u_attr)
379{ 400{
380 if (unlikely(current->audit_context)) 401 if (unlikely(!audit_dummy_context()))
381 return __audit_mq_open(oflag, mode, u_attr); 402 return __audit_mq_open(oflag, mode, u_attr);
382 return 0; 403 return 0;
383} 404}
384static inline int audit_mq_timedsend(mqd_t mqdes, size_t msg_len, unsigned int msg_prio, const struct timespec __user *u_abs_timeout) 405static inline int audit_mq_timedsend(mqd_t mqdes, size_t msg_len, unsigned int msg_prio, const struct timespec __user *u_abs_timeout)
385{ 406{
386 if (unlikely(current->audit_context)) 407 if (unlikely(!audit_dummy_context()))
387 return __audit_mq_timedsend(mqdes, msg_len, msg_prio, u_abs_timeout); 408 return __audit_mq_timedsend(mqdes, msg_len, msg_prio, u_abs_timeout);
388 return 0; 409 return 0;
389} 410}
390static inline int audit_mq_timedreceive(mqd_t mqdes, size_t msg_len, unsigned int __user *u_msg_prio, const struct timespec __user *u_abs_timeout) 411static inline int audit_mq_timedreceive(mqd_t mqdes, size_t msg_len, unsigned int __user *u_msg_prio, const struct timespec __user *u_abs_timeout)
391{ 412{
392 if (unlikely(current->audit_context)) 413 if (unlikely(!audit_dummy_context()))
393 return __audit_mq_timedreceive(mqdes, msg_len, u_msg_prio, u_abs_timeout); 414 return __audit_mq_timedreceive(mqdes, msg_len, u_msg_prio, u_abs_timeout);
394 return 0; 415 return 0;
395} 416}
396static inline int audit_mq_notify(mqd_t mqdes, const struct sigevent __user *u_notification) 417static inline int audit_mq_notify(mqd_t mqdes, const struct sigevent __user *u_notification)
397{ 418{
398 if (unlikely(current->audit_context)) 419 if (unlikely(!audit_dummy_context()))
399 return __audit_mq_notify(mqdes, u_notification); 420 return __audit_mq_notify(mqdes, u_notification);
400 return 0; 421 return 0;
401} 422}
402static inline int audit_mq_getsetattr(mqd_t mqdes, struct mq_attr *mqstat) 423static inline int audit_mq_getsetattr(mqd_t mqdes, struct mq_attr *mqstat)
403{ 424{
404 if (unlikely(current->audit_context)) 425 if (unlikely(!audit_dummy_context()))
405 return __audit_mq_getsetattr(mqdes, mqstat); 426 return __audit_mq_getsetattr(mqdes, mqstat);
406 return 0; 427 return 0;
407} 428}
429extern int audit_n_rules;
408#else 430#else
409#define audit_alloc(t) ({ 0; }) 431#define audit_alloc(t) ({ 0; })
410#define audit_free(t) do { ; } while (0) 432#define audit_free(t) do { ; } while (0)
411#define audit_syscall_entry(ta,a,b,c,d,e) do { ; } while (0) 433#define audit_syscall_entry(ta,a,b,c,d,e) do { ; } while (0)
412#define audit_syscall_exit(f,r) do { ; } while (0) 434#define audit_syscall_exit(f,r) do { ; } while (0)
435#define audit_dummy_context() 1
413#define audit_getname(n) do { ; } while (0) 436#define audit_getname(n) do { ; } while (0)
414#define audit_putname(n) do { ; } while (0) 437#define audit_putname(n) do { ; } while (0)
415#define __audit_inode(n,i) do { ; } while (0) 438#define __audit_inode(n,i) do { ; } while (0)
416#define __audit_inode_child(d,i,p) do { ; } while (0) 439#define __audit_inode_child(d,i,p) do { ; } while (0)
440#define __audit_inode_update(i) do { ; } while (0)
417#define audit_inode(n,i) do { ; } while (0) 441#define audit_inode(n,i) do { ; } while (0)
418#define audit_inode_child(d,i,p) do { ; } while (0) 442#define audit_inode_child(d,i,p) do { ; } while (0)
443#define audit_inode_update(i) do { ; } while (0)
419#define auditsc_get_stamp(c,t,s) do { BUG(); } while (0) 444#define auditsc_get_stamp(c,t,s) do { BUG(); } while (0)
420#define audit_get_loginuid(c) ({ -1; }) 445#define audit_get_loginuid(c) ({ -1; })
421#define audit_ipc_obj(i) ({ 0; }) 446#define audit_ipc_obj(i) ({ 0; })
@@ -430,6 +455,7 @@ static inline int audit_mq_getsetattr(mqd_t mqdes, struct mq_attr *mqstat)
430#define audit_mq_timedreceive(d,l,p,t) ({ 0; }) 455#define audit_mq_timedreceive(d,l,p,t) ({ 0; })
431#define audit_mq_notify(d,n) ({ 0; }) 456#define audit_mq_notify(d,n) ({ 0; })
432#define audit_mq_getsetattr(d,s) ({ 0; }) 457#define audit_mq_getsetattr(d,s) ({ 0; })
458#define audit_n_rules 0
433#endif 459#endif
434 460
435#ifdef CONFIG_AUDIT 461#ifdef CONFIG_AUDIT