diff options
author | Kees Cook <keescook@chromium.org> | 2012-10-04 20:11:11 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-10-05 14:04:35 -0400 |
commit | 9321d526dd731588f09508af48de50041785a26a (patch) | |
tree | b8db96367019c85c18e8685d8cc9225b2d0332ec /include/linux/audit.h | |
parent | ecefbd94b834fa32559d854646d777c56749ef1c (diff) |
audit.h: replace defines with C stubs
Replace the #defines used when CONFIG_AUDIT or CONFIG_AUDIT_SYSCALLS are
disabled so we get type checking during those builds.
Suggested-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Kees Cook <keescook@chromium.org>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux/audit.h')
-rw-r--r-- | include/linux/audit.h | 206 |
1 files changed, 153 insertions, 53 deletions
diff --git a/include/linux/audit.h b/include/linux/audit.h index e7c836d961ea..2c83e5f7edb1 100644 --- a/include/linux/audit.h +++ b/include/linux/audit.h | |||
@@ -527,9 +527,18 @@ static inline void audit_ptrace(struct task_struct *t) | |||
527 | extern unsigned int audit_serial(void); | 527 | extern unsigned int audit_serial(void); |
528 | extern int auditsc_get_stamp(struct audit_context *ctx, | 528 | extern int auditsc_get_stamp(struct audit_context *ctx, |
529 | struct timespec *t, unsigned int *serial); | 529 | struct timespec *t, unsigned int *serial); |
530 | extern int audit_set_loginuid(kuid_t loginuid); | 530 | extern int audit_set_loginuid(kuid_t loginuid); |
531 | #define audit_get_loginuid(t) ((t)->loginuid) | 531 | |
532 | #define audit_get_sessionid(t) ((t)->sessionid) | 532 | static inline kuid_t audit_get_loginuid(struct task_struct *tsk) |
533 | { | ||
534 | return tsk->loginuid; | ||
535 | } | ||
536 | |||
537 | static inline int audit_get_sessionid(struct task_struct *tsk) | ||
538 | { | ||
539 | return tsk->sessionid; | ||
540 | } | ||
541 | |||
533 | extern void audit_log_task_context(struct audit_buffer *ab); | 542 | extern void audit_log_task_context(struct audit_buffer *ab); |
534 | extern void audit_log_task_info(struct audit_buffer *ab, struct task_struct *tsk); | 543 | extern void audit_log_task_info(struct audit_buffer *ab, struct task_struct *tsk); |
535 | extern void __audit_ipc_obj(struct kern_ipc_perm *ipcp); | 544 | extern void __audit_ipc_obj(struct kern_ipc_perm *ipcp); |
@@ -626,38 +635,101 @@ static inline void audit_mmap_fd(int fd, int flags) | |||
626 | extern int audit_n_rules; | 635 | extern int audit_n_rules; |
627 | extern int audit_signals; | 636 | extern int audit_signals; |
628 | #else /* CONFIG_AUDITSYSCALL */ | 637 | #else /* CONFIG_AUDITSYSCALL */ |
629 | #define audit_alloc(t) ({ 0; }) | 638 | static inline int audit_alloc(struct task_struct *task) |
630 | #define audit_free(t) do { ; } while (0) | 639 | { |
631 | #define audit_syscall_entry(ta,a,b,c,d,e) do { ; } while (0) | 640 | return 0; |
632 | #define audit_syscall_exit(r) do { ; } while (0) | 641 | } |
633 | #define audit_dummy_context() 1 | 642 | static inline void audit_free(struct task_struct *task) |
634 | #define audit_getname(n) do { ; } while (0) | 643 | { } |
635 | #define audit_putname(n) do { ; } while (0) | 644 | static inline void audit_syscall_entry(int arch, int major, unsigned long a0, |
636 | #define __audit_inode(n,d) do { ; } while (0) | 645 | unsigned long a1, unsigned long a2, |
637 | #define __audit_inode_child(i,p) do { ; } while (0) | 646 | unsigned long a3) |
638 | #define audit_inode(n,d) do { (void)(d); } while (0) | 647 | { } |
639 | #define audit_inode_child(i,p) do { ; } while (0) | 648 | static inline void audit_syscall_exit(void *pt_regs) |
640 | #define audit_core_dumps(i) do { ; } while (0) | 649 | { } |
641 | #define audit_seccomp(i,s,c) do { ; } while (0) | 650 | static inline int audit_dummy_context(void) |
642 | #define auditsc_get_stamp(c,t,s) (0) | 651 | { |
643 | #define audit_get_loginuid(t) (INVALID_UID) | 652 | return 1; |
644 | #define audit_get_sessionid(t) (-1) | 653 | } |
645 | #define audit_log_task_context(b) do { ; } while (0) | 654 | static inline void audit_getname(const char *name) |
646 | #define audit_log_task_info(b, t) do { ; } while (0) | 655 | { } |
647 | #define audit_ipc_obj(i) ((void)0) | 656 | static inline void audit_putname(const char *name) |
648 | #define audit_ipc_set_perm(q,u,g,m) ((void)0) | 657 | { } |
649 | #define audit_bprm(p) ({ 0; }) | 658 | static inline void __audit_inode(const char *name, const struct dentry *dentry) |
650 | #define audit_socketcall(n,a) ((void)0) | 659 | { } |
651 | #define audit_fd_pair(n,a) ((void)0) | 660 | static inline void __audit_inode_child(const struct dentry *dentry, |
652 | #define audit_sockaddr(len, addr) ({ 0; }) | 661 | const struct inode *parent) |
653 | #define audit_mq_open(o,m,a) ((void)0) | 662 | { } |
654 | #define audit_mq_sendrecv(d,l,p,t) ((void)0) | 663 | static inline void audit_inode(const char *name, const struct dentry *dentry) |
655 | #define audit_mq_notify(d,n) ((void)0) | 664 | { } |
656 | #define audit_mq_getsetattr(d,s) ((void)0) | 665 | static inline void audit_inode_child(const struct dentry *dentry, |
657 | #define audit_log_bprm_fcaps(b, ncr, ocr) ({ 0; }) | 666 | const struct inode *parent) |
658 | #define audit_log_capset(pid, ncr, ocr) ((void)0) | 667 | { } |
659 | #define audit_mmap_fd(fd, flags) ((void)0) | 668 | static inline void audit_core_dumps(long signr) |
660 | #define audit_ptrace(t) ((void)0) | 669 | { } |
670 | static inline void __audit_seccomp(unsigned long syscall, long signr, int code) | ||
671 | { } | ||
672 | static inline void audit_seccomp(unsigned long syscall, long signr, int code) | ||
673 | { } | ||
674 | static inline int auditsc_get_stamp(struct audit_context *ctx, | ||
675 | struct timespec *t, unsigned int *serial) | ||
676 | { | ||
677 | return 0; | ||
678 | } | ||
679 | static inline kuid_t audit_get_loginuid(struct task_struct *tsk) | ||
680 | { | ||
681 | return INVALID_UID; | ||
682 | } | ||
683 | static inline int audit_get_sessionid(struct task_struct *tsk) | ||
684 | { | ||
685 | return -1; | ||
686 | } | ||
687 | static inline void audit_log_task_context(struct audit_buffer *ab) | ||
688 | { } | ||
689 | static inline void audit_log_task_info(struct audit_buffer *ab, | ||
690 | struct task_struct *tsk) | ||
691 | { } | ||
692 | static inline void audit_ipc_obj(struct kern_ipc_perm *ipcp) | ||
693 | { } | ||
694 | static inline void audit_ipc_set_perm(unsigned long qbytes, uid_t uid, | ||
695 | gid_t gid, umode_t mode) | ||
696 | { } | ||
697 | static inline int audit_bprm(struct linux_binprm *bprm) | ||
698 | { | ||
699 | return 0; | ||
700 | } | ||
701 | static inline void audit_socketcall(int nargs, unsigned long *args) | ||
702 | { } | ||
703 | static inline void audit_fd_pair(int fd1, int fd2) | ||
704 | { } | ||
705 | static inline int audit_sockaddr(int len, void *addr) | ||
706 | { | ||
707 | return 0; | ||
708 | } | ||
709 | static inline void audit_mq_open(int oflag, umode_t mode, struct mq_attr *attr) | ||
710 | { } | ||
711 | static inline void audit_mq_sendrecv(mqd_t mqdes, size_t msg_len, | ||
712 | unsigned int msg_prio, | ||
713 | const struct timespec *abs_timeout) | ||
714 | { } | ||
715 | static inline void audit_mq_notify(mqd_t mqdes, | ||
716 | const struct sigevent *notification) | ||
717 | { } | ||
718 | static inline void audit_mq_getsetattr(mqd_t mqdes, struct mq_attr *mqstat) | ||
719 | { } | ||
720 | static inline int audit_log_bprm_fcaps(struct linux_binprm *bprm, | ||
721 | const struct cred *new, | ||
722 | const struct cred *old) | ||
723 | { | ||
724 | return 0; | ||
725 | } | ||
726 | static inline void audit_log_capset(pid_t pid, const struct cred *new, | ||
727 | const struct cred *old) | ||
728 | { } | ||
729 | static inline void audit_mmap_fd(int fd, int flags) | ||
730 | { } | ||
731 | static inline void audit_ptrace(struct task_struct *t) | ||
732 | { } | ||
661 | #define audit_n_rules 0 | 733 | #define audit_n_rules 0 |
662 | #define audit_signals 0 | 734 | #define audit_signals 0 |
663 | #endif /* CONFIG_AUDITSYSCALL */ | 735 | #endif /* CONFIG_AUDITSYSCALL */ |
@@ -681,7 +753,6 @@ extern void audit_log_n_hex(struct audit_buffer *ab, | |||
681 | extern void audit_log_n_string(struct audit_buffer *ab, | 753 | extern void audit_log_n_string(struct audit_buffer *ab, |
682 | const char *buf, | 754 | const char *buf, |
683 | size_t n); | 755 | size_t n); |
684 | #define audit_log_string(a,b) audit_log_n_string(a, b, strlen(b)); | ||
685 | extern void audit_log_n_untrustedstring(struct audit_buffer *ab, | 756 | extern void audit_log_n_untrustedstring(struct audit_buffer *ab, |
686 | const char *string, | 757 | const char *string, |
687 | size_t n); | 758 | size_t n); |
@@ -698,7 +769,8 @@ extern void audit_log_lost(const char *message); | |||
698 | #ifdef CONFIG_SECURITY | 769 | #ifdef CONFIG_SECURITY |
699 | extern void audit_log_secctx(struct audit_buffer *ab, u32 secid); | 770 | extern void audit_log_secctx(struct audit_buffer *ab, u32 secid); |
700 | #else | 771 | #else |
701 | #define audit_log_secctx(b,s) do { ; } while (0) | 772 | static inline void audit_log_secctx(struct audit_buffer *ab, u32 secid) |
773 | { } | ||
702 | #endif | 774 | #endif |
703 | 775 | ||
704 | extern int audit_update_lsm_rules(void); | 776 | extern int audit_update_lsm_rules(void); |
@@ -710,22 +782,50 @@ extern int audit_receive_filter(int type, int pid, int seq, | |||
710 | void *data, size_t datasz, kuid_t loginuid, | 782 | void *data, size_t datasz, kuid_t loginuid, |
711 | u32 sessionid, u32 sid); | 783 | u32 sessionid, u32 sid); |
712 | extern int audit_enabled; | 784 | extern int audit_enabled; |
713 | #else | 785 | #else /* CONFIG_AUDIT */ |
714 | #define audit_log(c,g,t,f,...) do { ; } while (0) | 786 | static inline __printf(4, 5) |
715 | #define audit_log_start(c,g,t) ({ NULL; }) | 787 | void audit_log(struct audit_context *ctx, gfp_t gfp_mask, int type, |
716 | #define audit_log_vformat(b,f,a) do { ; } while (0) | 788 | const char *fmt, ...) |
717 | #define audit_log_format(b,f,...) do { ; } while (0) | 789 | { } |
718 | #define audit_log_end(b) do { ; } while (0) | 790 | static inline struct audit_buffer *audit_log_start(struct audit_context *ctx, |
719 | #define audit_log_n_hex(a,b,l) do { ; } while (0) | 791 | gfp_t gfp_mask, int type) |
720 | #define audit_log_n_string(a,c,l) do { ; } while (0) | 792 | { |
721 | #define audit_log_string(a,c) do { ; } while (0) | 793 | return NULL; |
722 | #define audit_log_n_untrustedstring(a,n,s) do { ; } while (0) | 794 | } |
723 | #define audit_log_untrustedstring(a,s) do { ; } while (0) | 795 | static inline __printf(2, 3) |
724 | #define audit_log_d_path(b, p, d) do { ; } while (0) | 796 | void audit_log_format(struct audit_buffer *ab, const char *fmt, ...) |
725 | #define audit_log_key(b, k) do { ; } while (0) | 797 | { } |
726 | #define audit_log_link_denied(o, l) do { ; } while (0) | 798 | static inline void audit_log_end(struct audit_buffer *ab) |
727 | #define audit_log_secctx(b,s) do { ; } while (0) | 799 | { } |
800 | static inline void audit_log_n_hex(struct audit_buffer *ab, | ||
801 | const unsigned char *buf, size_t len) | ||
802 | { } | ||
803 | static inline void audit_log_n_string(struct audit_buffer *ab, | ||
804 | const char *buf, size_t n) | ||
805 | { } | ||
806 | static inline void audit_log_n_untrustedstring(struct audit_buffer *ab, | ||
807 | const char *string, size_t n) | ||
808 | { } | ||
809 | static inline void audit_log_untrustedstring(struct audit_buffer *ab, | ||
810 | const char *string) | ||
811 | { } | ||
812 | static inline void audit_log_d_path(struct audit_buffer *ab, | ||
813 | const char *prefix, | ||
814 | const struct path *path) | ||
815 | { } | ||
816 | static inline void audit_log_key(struct audit_buffer *ab, char *key) | ||
817 | { } | ||
818 | static inline void audit_log_link_denied(const char *string, | ||
819 | const struct path *link) | ||
820 | { } | ||
821 | static inline void audit_log_secctx(struct audit_buffer *ab, u32 secid) | ||
822 | { } | ||
728 | #define audit_enabled 0 | 823 | #define audit_enabled 0 |
729 | #endif | 824 | #endif /* CONFIG_AUDIT */ |
825 | static inline void audit_log_string(struct audit_buffer *ab, const char *buf) | ||
826 | { | ||
827 | audit_log_n_string(ab, buf, strlen(buf)); | ||
828 | } | ||
829 | |||
730 | #endif | 830 | #endif |
731 | #endif | 831 | #endif |