aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/audit.h
diff options
context:
space:
mode:
authorKees Cook <keescook@chromium.org>2012-10-04 20:11:11 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-10-05 14:04:35 -0400
commit9321d526dd731588f09508af48de50041785a26a (patch)
treeb8db96367019c85c18e8685d8cc9225b2d0332ec /include/linux/audit.h
parentecefbd94b834fa32559d854646d777c56749ef1c (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.h206
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)
527extern unsigned int audit_serial(void); 527extern unsigned int audit_serial(void);
528extern int auditsc_get_stamp(struct audit_context *ctx, 528extern int auditsc_get_stamp(struct audit_context *ctx,
529 struct timespec *t, unsigned int *serial); 529 struct timespec *t, unsigned int *serial);
530extern int audit_set_loginuid(kuid_t loginuid); 530extern int audit_set_loginuid(kuid_t loginuid);
531#define audit_get_loginuid(t) ((t)->loginuid) 531
532#define audit_get_sessionid(t) ((t)->sessionid) 532static inline kuid_t audit_get_loginuid(struct task_struct *tsk)
533{
534 return tsk->loginuid;
535}
536
537static inline int audit_get_sessionid(struct task_struct *tsk)
538{
539 return tsk->sessionid;
540}
541
533extern void audit_log_task_context(struct audit_buffer *ab); 542extern void audit_log_task_context(struct audit_buffer *ab);
534extern void audit_log_task_info(struct audit_buffer *ab, struct task_struct *tsk); 543extern void audit_log_task_info(struct audit_buffer *ab, struct task_struct *tsk);
535extern void __audit_ipc_obj(struct kern_ipc_perm *ipcp); 544extern void __audit_ipc_obj(struct kern_ipc_perm *ipcp);
@@ -626,38 +635,101 @@ static inline void audit_mmap_fd(int fd, int flags)
626extern int audit_n_rules; 635extern int audit_n_rules;
627extern int audit_signals; 636extern int audit_signals;
628#else /* CONFIG_AUDITSYSCALL */ 637#else /* CONFIG_AUDITSYSCALL */
629#define audit_alloc(t) ({ 0; }) 638static 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 642static 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) 644static 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) 648static 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) 650static 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) 654static 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) 656static 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; }) 658static 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) 660static 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) 663static 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) 665static 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) 668static inline void audit_core_dumps(long signr)
660#define audit_ptrace(t) ((void)0) 669{ }
670static inline void __audit_seccomp(unsigned long syscall, long signr, int code)
671{ }
672static inline void audit_seccomp(unsigned long syscall, long signr, int code)
673{ }
674static inline int auditsc_get_stamp(struct audit_context *ctx,
675 struct timespec *t, unsigned int *serial)
676{
677 return 0;
678}
679static inline kuid_t audit_get_loginuid(struct task_struct *tsk)
680{
681 return INVALID_UID;
682}
683static inline int audit_get_sessionid(struct task_struct *tsk)
684{
685 return -1;
686}
687static inline void audit_log_task_context(struct audit_buffer *ab)
688{ }
689static inline void audit_log_task_info(struct audit_buffer *ab,
690 struct task_struct *tsk)
691{ }
692static inline void audit_ipc_obj(struct kern_ipc_perm *ipcp)
693{ }
694static inline void audit_ipc_set_perm(unsigned long qbytes, uid_t uid,
695 gid_t gid, umode_t mode)
696{ }
697static inline int audit_bprm(struct linux_binprm *bprm)
698{
699 return 0;
700}
701static inline void audit_socketcall(int nargs, unsigned long *args)
702{ }
703static inline void audit_fd_pair(int fd1, int fd2)
704{ }
705static inline int audit_sockaddr(int len, void *addr)
706{
707 return 0;
708}
709static inline void audit_mq_open(int oflag, umode_t mode, struct mq_attr *attr)
710{ }
711static inline void audit_mq_sendrecv(mqd_t mqdes, size_t msg_len,
712 unsigned int msg_prio,
713 const struct timespec *abs_timeout)
714{ }
715static inline void audit_mq_notify(mqd_t mqdes,
716 const struct sigevent *notification)
717{ }
718static inline void audit_mq_getsetattr(mqd_t mqdes, struct mq_attr *mqstat)
719{ }
720static 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}
726static inline void audit_log_capset(pid_t pid, const struct cred *new,
727 const struct cred *old)
728{ }
729static inline void audit_mmap_fd(int fd, int flags)
730{ }
731static 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,
681extern void audit_log_n_string(struct audit_buffer *ab, 753extern 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));
685extern void audit_log_n_untrustedstring(struct audit_buffer *ab, 756extern 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
699extern void audit_log_secctx(struct audit_buffer *ab, u32 secid); 770extern void audit_log_secctx(struct audit_buffer *ab, u32 secid);
700#else 771#else
701#define audit_log_secctx(b,s) do { ; } while (0) 772static inline void audit_log_secctx(struct audit_buffer *ab, u32 secid)
773{ }
702#endif 774#endif
703 775
704extern int audit_update_lsm_rules(void); 776extern 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);
712extern int audit_enabled; 784extern int audit_enabled;
713#else 785#else /* CONFIG_AUDIT */
714#define audit_log(c,g,t,f,...) do { ; } while (0) 786static inline __printf(4, 5)
715#define audit_log_start(c,g,t) ({ NULL; }) 787void 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) 790static 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) 795static inline __printf(2, 3)
724#define audit_log_d_path(b, p, d) do { ; } while (0) 796void 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) 798static inline void audit_log_end(struct audit_buffer *ab)
727#define audit_log_secctx(b,s) do { ; } while (0) 799{ }
800static inline void audit_log_n_hex(struct audit_buffer *ab,
801 const unsigned char *buf, size_t len)
802{ }
803static inline void audit_log_n_string(struct audit_buffer *ab,
804 const char *buf, size_t n)
805{ }
806static inline void audit_log_n_untrustedstring(struct audit_buffer *ab,
807 const char *string, size_t n)
808{ }
809static inline void audit_log_untrustedstring(struct audit_buffer *ab,
810 const char *string)
811{ }
812static inline void audit_log_d_path(struct audit_buffer *ab,
813 const char *prefix,
814 const struct path *path)
815{ }
816static inline void audit_log_key(struct audit_buffer *ab, char *key)
817{ }
818static inline void audit_log_link_denied(const char *string,
819 const struct path *link)
820{ }
821static 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 */
825static 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