xref: /illumos-gate/usr/src/cmd/sgs/rtld/common/_audit.h (revision 7247f888)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	__AUDIT_DOT_H
28 #define	__AUDIT_DOT_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 
33 #ifndef _ASM
34 
35 #include <sys/types.h>
36 #include <rtld.h>
37 
38 #ifdef	__cplusplus
39 extern "C" {
40 #endif
41 
42 /*
43  * Define all auditing structures.
44  *
45  * A shared object may be a client of an audit library, in which case the
46  * identify of the shared object is passed to the auditor using a cookie.
47  */
48 typedef struct {
49 	Rt_map *	ac_lmp;		/* audit library identifier */
50 	uintptr_t	ac_cookie;	/* cookie assigned to audit library */
51 	Word		ac_flags;	/*	and its associated flags */
52 } Audit_client;
53 
54 #define	FLG_AC_BINDTO	0x00001
55 #define	FLG_AC_BINDFROM	0x00002
56 
57 /*
58  * Each shared object being audited may provide a list of client structures
59  * and dynamic plts (one per auditor).
60  */
61 struct audit_info {
62 	uint_t		ai_cnt;		/* no. of clients */
63 	Audit_client *	ai_clients;	/* array of client structures */
64 	void *		ai_dynplts;	/* array of dynamic plts */
65 };
66 
67 /*
68  * Define an Audit Descriptor - each audit object is added to this descriptor
69  * as an Audit Interface.  There is one global audit descriptor - auditors,
70  * and a specific object my require its own - AUDITORS(lmp).
71  */
72 struct audit_desc {
73 	char		*ad_name;	/* originating audit names */
74 	List		ad_list;	/* audit objs Audit Interface list */
75 	uint_t		ad_cnt;		/* no. of audit objs in this desc. */
76 	uint_t		ad_flags;	/* audit capabilities found */
77 };
78 
79 /*
80  * Define an Audit List descriptor for each audit object.
81  */
82 struct audit_list {
83 	const char	*al_libname;	/* object name for diagnostics */
84 	Rt_map		*al_lmp;	/* object link-map */
85 	Grp_hdl		*al_ghp;	/* object handle */
86 	uint_t		al_flags;	/* audit capabilities found */
87 	uint_t		(*al_version)(uint_t);
88 	void		(*al_preinit)(uintptr_t *);
89 	char		*(*al_objsearch)(const char *, uintptr_t *, uint_t);
90 	uint_t		(*al_objopen)(Link_map *, Lmid_t, uintptr_t *);
91 	int		(*al_objfilter)(uintptr_t *, const char *, uintptr_t *,
92 				uint_t);
93 	uint_t		(*al_objclose)(uintptr_t *);
94 	void		(*al_activity)(uintptr_t *, uint_t);
95 #if	defined(_ELF64)
96 	uintptr_t	(*al_pltenter)(Sym *, uint_t, uintptr_t *, uintptr_t *,
97 				void *, uint_t *, const char *);
98 	uintptr_t	(*al_pltexit)(Sym *, uint_t, uintptr_t *, uintptr_t *,
99 				uintptr_t, const char *);
100 	uintptr_t	(*al_symbind)(Sym *, uint_t, uintptr_t *,
101 				uintptr_t *, uint_t *, const char *);
102 #else
103 	uintptr_t	(*al_pltenter)(Sym *, uint_t, uintptr_t *, uintptr_t *,
104 				void *, uint_t *);
105 	uintptr_t	(*al_pltexit)(Sym *, uint_t, uintptr_t *, uintptr_t *,
106 				uintptr_t);
107 	uintptr_t	(*al_symbind)(Sym *, uint_t, uintptr_t *,
108 				uintptr_t *, uint_t *);
109 #endif /* _ELF64 */
110 	uint_t		al_vernum;	/* object version */
111 };
112 
113 /*
114  * Link-Edit audit functions
115  */
116 extern int		audit_setup(Rt_map *, Audit_desc *, uint_t);
117 
118 extern void		audit_desc_cleanup(Rt_map *);
119 extern void		audit_info_cleanup(Rt_map *);
120 
121 extern int		audit_objopen(Rt_map *, Rt_map *);
122 extern int		audit_objfilter(Rt_map *, const char *, Rt_map *,
123 			    uint_t flags);
124 extern void		audit_activity(Rt_map *, uint_t);
125 extern void		audit_preinit(Rt_map *);
126 extern char		*audit_objsearch(Rt_map *, const char *, uint_t);
127 extern void		audit_objclose(Rt_map *, Rt_map *);
128 extern void		_audit_objclose(List *, Rt_map *);
129 extern Addr		audit_symbind(Rt_map *, Rt_map *, Sym *, uint_t,
130 			    Addr value, uint_t *);
131 extern Addr		audit_pltenter(Rt_map *, Rt_map *, Sym *, uint_t,
132 			    void *, uint_t *);
133 extern Addr		audit_pltexit(uintptr_t, Rt_map *, Rt_map *, Sym *,
134 			    uint_t);
135 
136 extern uint_t		audit_flags;
137 
138 #endif /* _ASM */
139 
140 /*
141  * Values for audit_flags.  Intended to be the same as the LML equivalents
142  * but kept in a separate variable to simplify boot_elf.s coding.
143  */
144 #define	AF_PLTENTER	0x01		/* same as LML_AUD_PLTENTER */
145 #define	AF_PLTEXIT	0x02		/* Same as LML_AUD_PLTEXIT */
146 
147 #ifdef	__cplusplus
148 }
149 #endif
150 
151 #endif /* __AUDIT_DOT_H */
152