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.h214
1 files changed, 159 insertions, 55 deletions
diff --git a/include/linux/audit.h b/include/linux/audit.h
index 36abf2aa7e68..2c83e5f7edb1 100644
--- a/include/linux/audit.h
+++ b/include/linux/audit.h
@@ -442,6 +442,8 @@ struct audit_krule {
442struct audit_field { 442struct audit_field {
443 u32 type; 443 u32 type;
444 u32 val; 444 u32 val;
445 kuid_t uid;
446 kgid_t gid;
445 u32 op; 447 u32 op;
446 char *lsm_str; 448 char *lsm_str;
447 void *lsm_rule; 449 void *lsm_rule;
@@ -525,10 +527,20 @@ static inline void audit_ptrace(struct task_struct *t)
525extern unsigned int audit_serial(void); 527extern unsigned int audit_serial(void);
526extern int auditsc_get_stamp(struct audit_context *ctx, 528extern int auditsc_get_stamp(struct audit_context *ctx,
527 struct timespec *t, unsigned int *serial); 529 struct timespec *t, unsigned int *serial);
528extern int audit_set_loginuid(uid_t loginuid); 530extern int audit_set_loginuid(kuid_t loginuid);
529#define audit_get_loginuid(t) ((t)->loginuid) 531
530#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
531extern void audit_log_task_context(struct audit_buffer *ab); 542extern void audit_log_task_context(struct audit_buffer *ab);
543extern void audit_log_task_info(struct audit_buffer *ab, struct task_struct *tsk);
532extern void __audit_ipc_obj(struct kern_ipc_perm *ipcp); 544extern void __audit_ipc_obj(struct kern_ipc_perm *ipcp);
533extern void __audit_ipc_set_perm(unsigned long qbytes, uid_t uid, gid_t gid, umode_t mode); 545extern void __audit_ipc_set_perm(unsigned long qbytes, uid_t uid, gid_t gid, umode_t mode);
534extern int __audit_bprm(struct linux_binprm *bprm); 546extern int __audit_bprm(struct linux_binprm *bprm);
@@ -623,37 +635,101 @@ static inline void audit_mmap_fd(int fd, int flags)
623extern int audit_n_rules; 635extern int audit_n_rules;
624extern int audit_signals; 636extern int audit_signals;
625#else /* CONFIG_AUDITSYSCALL */ 637#else /* CONFIG_AUDITSYSCALL */
626#define audit_alloc(t) ({ 0; }) 638static inline int audit_alloc(struct task_struct *task)
627#define audit_free(t) do { ; } while (0) 639{
628#define audit_syscall_entry(ta,a,b,c,d,e) do { ; } while (0) 640 return 0;
629#define audit_syscall_exit(r) do { ; } while (0) 641}
630#define audit_dummy_context() 1 642static inline void audit_free(struct task_struct *task)
631#define audit_getname(n) do { ; } while (0) 643{ }
632#define audit_putname(n) do { ; } while (0) 644static inline void audit_syscall_entry(int arch, int major, unsigned long a0,
633#define __audit_inode(n,d) do { ; } while (0) 645 unsigned long a1, unsigned long a2,
634#define __audit_inode_child(i,p) do { ; } while (0) 646 unsigned long a3)
635#define audit_inode(n,d) do { (void)(d); } while (0) 647{ }
636#define audit_inode_child(i,p) do { ; } while (0) 648static inline void audit_syscall_exit(void *pt_regs)
637#define audit_core_dumps(i) do { ; } while (0) 649{ }
638#define audit_seccomp(i,s,c) do { ; } while (0) 650static inline int audit_dummy_context(void)
639#define auditsc_get_stamp(c,t,s) (0) 651{
640#define audit_get_loginuid(t) (-1) 652 return 1;
641#define audit_get_sessionid(t) (-1) 653}
642#define audit_log_task_context(b) do { ; } while (0) 654static inline void audit_getname(const char *name)
643#define audit_ipc_obj(i) ((void)0) 655{ }
644#define audit_ipc_set_perm(q,u,g,m) ((void)0) 656static inline void audit_putname(const char *name)
645#define audit_bprm(p) ({ 0; }) 657{ }
646#define audit_socketcall(n,a) ((void)0) 658static inline void __audit_inode(const char *name, const struct dentry *dentry)
647#define audit_fd_pair(n,a) ((void)0) 659{ }
648#define audit_sockaddr(len, addr) ({ 0; }) 660static inline void __audit_inode_child(const struct dentry *dentry,
649#define audit_mq_open(o,m,a) ((void)0) 661 const struct inode *parent)
650#define audit_mq_sendrecv(d,l,p,t) ((void)0) 662{ }
651#define audit_mq_notify(d,n) ((void)0) 663static inline void audit_inode(const char *name, const struct dentry *dentry)
652#define audit_mq_getsetattr(d,s) ((void)0) 664{ }
653#define audit_log_bprm_fcaps(b, ncr, ocr) ({ 0; }) 665static inline void audit_inode_child(const struct dentry *dentry,
654#define audit_log_capset(pid, ncr, ocr) ((void)0) 666 const struct inode *parent)
655#define audit_mmap_fd(fd, flags) ((void)0) 667{ }
656#define audit_ptrace(t) ((void)0) 668static inline void audit_core_dumps(long signr)
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{ }
657#define audit_n_rules 0 733#define audit_n_rules 0
658#define audit_signals 0 734#define audit_signals 0
659#endif /* CONFIG_AUDITSYSCALL */ 735#endif /* CONFIG_AUDITSYSCALL */
@@ -677,7 +753,6 @@ extern void audit_log_n_hex(struct audit_buffer *ab,
677extern void audit_log_n_string(struct audit_buffer *ab, 753extern void audit_log_n_string(struct audit_buffer *ab,
678 const char *buf, 754 const char *buf,
679 size_t n); 755 size_t n);
680#define audit_log_string(a,b) audit_log_n_string(a, b, strlen(b));
681extern void audit_log_n_untrustedstring(struct audit_buffer *ab, 756extern void audit_log_n_untrustedstring(struct audit_buffer *ab,
682 const char *string, 757 const char *string,
683 size_t n); 758 size_t n);
@@ -694,34 +769,63 @@ extern void audit_log_lost(const char *message);
694#ifdef CONFIG_SECURITY 769#ifdef CONFIG_SECURITY
695extern void audit_log_secctx(struct audit_buffer *ab, u32 secid); 770extern void audit_log_secctx(struct audit_buffer *ab, u32 secid);
696#else 771#else
697#define audit_log_secctx(b,s) do { ; } while (0) 772static inline void audit_log_secctx(struct audit_buffer *ab, u32 secid)
773{ }
698#endif 774#endif
699 775
700extern int audit_update_lsm_rules(void); 776extern int audit_update_lsm_rules(void);
701 777
702 /* Private API (for audit.c only) */ 778 /* Private API (for audit.c only) */
703extern int audit_filter_user(struct netlink_skb_parms *cb); 779extern int audit_filter_user(void);
704extern int audit_filter_type(int type); 780extern int audit_filter_type(int type);
705extern int audit_receive_filter(int type, int pid, int uid, int seq, 781extern int audit_receive_filter(int type, int pid, int seq,
706 void *data, size_t datasz, uid_t loginuid, 782 void *data, size_t datasz, kuid_t loginuid,
707 u32 sessionid, u32 sid); 783 u32 sessionid, u32 sid);
708extern int audit_enabled; 784extern int audit_enabled;
709#else 785#else /* CONFIG_AUDIT */
710#define audit_log(c,g,t,f,...) do { ; } while (0) 786static inline __printf(4, 5)
711#define audit_log_start(c,g,t) ({ NULL; }) 787void audit_log(struct audit_context *ctx, gfp_t gfp_mask, int type,
712#define audit_log_vformat(b,f,a) do { ; } while (0) 788 const char *fmt, ...)
713#define audit_log_format(b,f,...) do { ; } while (0) 789{ }
714#define audit_log_end(b) do { ; } while (0) 790static inline struct audit_buffer *audit_log_start(struct audit_context *ctx,
715#define audit_log_n_hex(a,b,l) do { ; } while (0) 791 gfp_t gfp_mask, int type)
716#define audit_log_n_string(a,c,l) do { ; } while (0) 792{
717#define audit_log_string(a,c) do { ; } while (0) 793 return NULL;
718#define audit_log_n_untrustedstring(a,n,s) do { ; } while (0) 794}
719#define audit_log_untrustedstring(a,s) do { ; } while (0) 795static inline __printf(2, 3)
720#define audit_log_d_path(b, p, d) do { ; } while (0) 796void audit_log_format(struct audit_buffer *ab, const char *fmt, ...)
721#define audit_log_key(b, k) do { ; } while (0) 797{ }
722#define audit_log_link_denied(o, l) do { ; } while (0) 798static inline void audit_log_end(struct audit_buffer *ab)
723#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{ }
724#define audit_enabled 0 823#define audit_enabled 0
725#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
726#endif 830#endif
727#endif 831#endif