diff options
Diffstat (limited to 'include/linux/audit.h')
-rw-r--r-- | include/linux/audit.h | 43 |
1 files changed, 29 insertions, 14 deletions
diff --git a/include/linux/audit.h b/include/linux/audit.h index b27d7debc5a1..64f9f9e56ac5 100644 --- a/include/linux/audit.h +++ b/include/linux/audit.h | |||
@@ -327,21 +327,31 @@ extern void __audit_getname(const char *name); | |||
327 | extern void audit_putname(const char *name); | 327 | extern void audit_putname(const char *name); |
328 | extern void __audit_inode(const char *name, const struct inode *inode); | 328 | extern void __audit_inode(const char *name, const struct inode *inode); |
329 | extern void __audit_inode_child(const char *dname, const struct inode *inode, | 329 | extern void __audit_inode_child(const char *dname, const struct inode *inode, |
330 | unsigned long pino); | 330 | const struct inode *parent); |
331 | extern void __audit_inode_update(const struct inode *inode); | ||
332 | static inline int audit_dummy_context(void) | ||
333 | { | ||
334 | void *p = current->audit_context; | ||
335 | return !p || *(int *)p; | ||
336 | } | ||
331 | static inline void audit_getname(const char *name) | 337 | static inline void audit_getname(const char *name) |
332 | { | 338 | { |
333 | if (unlikely(current->audit_context)) | 339 | if (unlikely(!audit_dummy_context())) |
334 | __audit_getname(name); | 340 | __audit_getname(name); |
335 | } | 341 | } |
336 | static inline void audit_inode(const char *name, const struct inode *inode) { | 342 | static inline void audit_inode(const char *name, const struct inode *inode) { |
337 | if (unlikely(current->audit_context)) | 343 | if (unlikely(!audit_dummy_context())) |
338 | __audit_inode(name, inode); | 344 | __audit_inode(name, inode); |
339 | } | 345 | } |
340 | static inline void audit_inode_child(const char *dname, | 346 | static inline void audit_inode_child(const char *dname, |
341 | const struct inode *inode, | 347 | const struct inode *inode, |
342 | unsigned long pino) { | 348 | const struct inode *parent) { |
343 | if (unlikely(current->audit_context)) | 349 | if (unlikely(!audit_dummy_context())) |
344 | __audit_inode_child(dname, inode, pino); | 350 | __audit_inode_child(dname, inode, parent); |
351 | } | ||
352 | static inline void audit_inode_update(const struct inode *inode) { | ||
353 | if (unlikely(!audit_dummy_context())) | ||
354 | __audit_inode_update(inode); | ||
345 | } | 355 | } |
346 | 356 | ||
347 | /* Private API (for audit.c only) */ | 357 | /* Private API (for audit.c only) */ |
@@ -365,57 +375,61 @@ extern int __audit_mq_getsetattr(mqd_t mqdes, struct mq_attr *mqstat); | |||
365 | 375 | ||
366 | static inline int audit_ipc_obj(struct kern_ipc_perm *ipcp) | 376 | static inline int audit_ipc_obj(struct kern_ipc_perm *ipcp) |
367 | { | 377 | { |
368 | if (unlikely(current->audit_context)) | 378 | if (unlikely(!audit_dummy_context())) |
369 | return __audit_ipc_obj(ipcp); | 379 | return __audit_ipc_obj(ipcp); |
370 | return 0; | 380 | return 0; |
371 | } | 381 | } |
372 | static inline int audit_ipc_set_perm(unsigned long qbytes, uid_t uid, gid_t gid, mode_t mode) | 382 | static inline int audit_ipc_set_perm(unsigned long qbytes, uid_t uid, gid_t gid, mode_t mode) |
373 | { | 383 | { |
374 | if (unlikely(current->audit_context)) | 384 | if (unlikely(!audit_dummy_context())) |
375 | return __audit_ipc_set_perm(qbytes, uid, gid, mode); | 385 | return __audit_ipc_set_perm(qbytes, uid, gid, mode); |
376 | return 0; | 386 | return 0; |
377 | } | 387 | } |
378 | static inline int audit_mq_open(int oflag, mode_t mode, struct mq_attr __user *u_attr) | 388 | static inline int audit_mq_open(int oflag, mode_t mode, struct mq_attr __user *u_attr) |
379 | { | 389 | { |
380 | if (unlikely(current->audit_context)) | 390 | if (unlikely(!audit_dummy_context())) |
381 | return __audit_mq_open(oflag, mode, u_attr); | 391 | return __audit_mq_open(oflag, mode, u_attr); |
382 | return 0; | 392 | return 0; |
383 | } | 393 | } |
384 | static inline int audit_mq_timedsend(mqd_t mqdes, size_t msg_len, unsigned int msg_prio, const struct timespec __user *u_abs_timeout) | 394 | static inline int audit_mq_timedsend(mqd_t mqdes, size_t msg_len, unsigned int msg_prio, const struct timespec __user *u_abs_timeout) |
385 | { | 395 | { |
386 | if (unlikely(current->audit_context)) | 396 | if (unlikely(!audit_dummy_context())) |
387 | return __audit_mq_timedsend(mqdes, msg_len, msg_prio, u_abs_timeout); | 397 | return __audit_mq_timedsend(mqdes, msg_len, msg_prio, u_abs_timeout); |
388 | return 0; | 398 | return 0; |
389 | } | 399 | } |
390 | static 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) | 400 | static 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 | { | 401 | { |
392 | if (unlikely(current->audit_context)) | 402 | if (unlikely(!audit_dummy_context())) |
393 | return __audit_mq_timedreceive(mqdes, msg_len, u_msg_prio, u_abs_timeout); | 403 | return __audit_mq_timedreceive(mqdes, msg_len, u_msg_prio, u_abs_timeout); |
394 | return 0; | 404 | return 0; |
395 | } | 405 | } |
396 | static inline int audit_mq_notify(mqd_t mqdes, const struct sigevent __user *u_notification) | 406 | static inline int audit_mq_notify(mqd_t mqdes, const struct sigevent __user *u_notification) |
397 | { | 407 | { |
398 | if (unlikely(current->audit_context)) | 408 | if (unlikely(!audit_dummy_context())) |
399 | return __audit_mq_notify(mqdes, u_notification); | 409 | return __audit_mq_notify(mqdes, u_notification); |
400 | return 0; | 410 | return 0; |
401 | } | 411 | } |
402 | static inline int audit_mq_getsetattr(mqd_t mqdes, struct mq_attr *mqstat) | 412 | static inline int audit_mq_getsetattr(mqd_t mqdes, struct mq_attr *mqstat) |
403 | { | 413 | { |
404 | if (unlikely(current->audit_context)) | 414 | if (unlikely(!audit_dummy_context())) |
405 | return __audit_mq_getsetattr(mqdes, mqstat); | 415 | return __audit_mq_getsetattr(mqdes, mqstat); |
406 | return 0; | 416 | return 0; |
407 | } | 417 | } |
418 | extern int audit_n_rules; | ||
408 | #else | 419 | #else |
409 | #define audit_alloc(t) ({ 0; }) | 420 | #define audit_alloc(t) ({ 0; }) |
410 | #define audit_free(t) do { ; } while (0) | 421 | #define audit_free(t) do { ; } while (0) |
411 | #define audit_syscall_entry(ta,a,b,c,d,e) do { ; } while (0) | 422 | #define audit_syscall_entry(ta,a,b,c,d,e) do { ; } while (0) |
412 | #define audit_syscall_exit(f,r) do { ; } while (0) | 423 | #define audit_syscall_exit(f,r) do { ; } while (0) |
424 | #define audit_dummy_context() 1 | ||
413 | #define audit_getname(n) do { ; } while (0) | 425 | #define audit_getname(n) do { ; } while (0) |
414 | #define audit_putname(n) do { ; } while (0) | 426 | #define audit_putname(n) do { ; } while (0) |
415 | #define __audit_inode(n,i) do { ; } while (0) | 427 | #define __audit_inode(n,i) do { ; } while (0) |
416 | #define __audit_inode_child(d,i,p) do { ; } while (0) | 428 | #define __audit_inode_child(d,i,p) do { ; } while (0) |
429 | #define __audit_inode_update(i) do { ; } while (0) | ||
417 | #define audit_inode(n,i) do { ; } while (0) | 430 | #define audit_inode(n,i) do { ; } while (0) |
418 | #define audit_inode_child(d,i,p) do { ; } while (0) | 431 | #define audit_inode_child(d,i,p) do { ; } while (0) |
432 | #define audit_inode_update(i) do { ; } while (0) | ||
419 | #define auditsc_get_stamp(c,t,s) do { BUG(); } while (0) | 433 | #define auditsc_get_stamp(c,t,s) do { BUG(); } while (0) |
420 | #define audit_get_loginuid(c) ({ -1; }) | 434 | #define audit_get_loginuid(c) ({ -1; }) |
421 | #define audit_ipc_obj(i) ({ 0; }) | 435 | #define audit_ipc_obj(i) ({ 0; }) |
@@ -430,6 +444,7 @@ static inline int audit_mq_getsetattr(mqd_t mqdes, struct mq_attr *mqstat) | |||
430 | #define audit_mq_timedreceive(d,l,p,t) ({ 0; }) | 444 | #define audit_mq_timedreceive(d,l,p,t) ({ 0; }) |
431 | #define audit_mq_notify(d,n) ({ 0; }) | 445 | #define audit_mq_notify(d,n) ({ 0; }) |
432 | #define audit_mq_getsetattr(d,s) ({ 0; }) | 446 | #define audit_mq_getsetattr(d,s) ({ 0; }) |
447 | #define audit_n_rules 0 | ||
433 | #endif | 448 | #endif |
434 | 449 | ||
435 | #ifdef CONFIG_AUDIT | 450 | #ifdef CONFIG_AUDIT |