Home | History | Annotate | Download | only in common
      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 2009 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 #ifndef _ASM
     31 
     32 #include <sys/types.h>
     33 #include <rtld.h>
     34 
     35 #ifdef	__cplusplus
     36 extern "C" {
     37 #endif
     38 
     39 /*
     40  * Define all auditing structures.
     41  *
     42  * A shared object may be a client of an audit library, in which case the
     43  * identify of the shared object is passed to the auditor using a cookie.
     44  */
     45 typedef struct {
     46 	Rt_map		*ac_lmp;	/* audit library identifier */
     47 	uintptr_t	ac_cookie;	/* cookie assigned to audit library */
     48 	Word		ac_flags;	/*	and its associated flags */
     49 } Audit_client;
     50 
     51 #define	FLG_AC_BINDTO	0x00001
     52 #define	FLG_AC_BINDFROM	0x00002
     53 
     54 /*
     55  * Each shared object being audited may provide a list of client structures
     56  * and dynamic plts (one per auditor).
     57  */
     58 struct audit_info {
     59 	uint_t		ai_cnt;		/* no. of clients */
     60 	Audit_client	*ai_clients;	/* array of client structures */
     61 	void		*ai_dynplts;	/* array of dynamic plts */
     62 };
     63 
     64 /*
     65  * Define an Audit Descriptor - each audit object is added to this descriptor
     66  * as an Audit Interface.  There is one global audit descriptor - auditors,
     67  * and a specific object my require its own - AUDITORS(lmp).
     68  */
     69 struct audit_desc {
     70 	char		*ad_name;	/* originating audit names */
     71 	APlist		*ad_list;	/* audit objs Audit Interface list */
     72 	uint_t		ad_cnt;		/* no. of audit objs in this desc. */
     73 	uint_t		ad_flags;	/* audit capabilities found */
     74 };
     75 
     76 /*
     77  * Define an Audit List descriptor for each audit object.
     78  */
     79 struct audit_list {
     80 	const char	*al_libname;	/* object name for diagnostics */
     81 	Rt_map		*al_lmp;	/* object link-map */
     82 	Grp_hdl		*al_ghp;	/* object handle */
     83 	uint_t		al_flags;	/* audit capabilities found */
     84 	uint_t		(*al_version)(uint_t);
     85 	void		(*al_preinit)(uintptr_t *);
     86 	char		*(*al_objsearch)(const char *, uintptr_t *, uint_t);
     87 	uint_t		(*al_objopen)(Link_map *, Lmid_t, uintptr_t *);
     88 	int		(*al_objfilter)(uintptr_t *, const char *, uintptr_t *,
     89 				uint_t);
     90 	uint_t		(*al_objclose)(uintptr_t *);
     91 	void		(*al_activity)(uintptr_t *, uint_t);
     92 #if	defined(_ELF64)
     93 	uintptr_t	(*al_pltenter)(Sym *, uint_t, uintptr_t *, uintptr_t *,
     94 				void *, uint_t *, const char *);
     95 	uintptr_t	(*al_pltexit)(Sym *, uint_t, uintptr_t *, uintptr_t *,
     96 				uintptr_t, const char *);
     97 	uintptr_t	(*al_symbind)(Sym *, uint_t, uintptr_t *,
     98 				uintptr_t *, uint_t *, const char *);
     99 #else
    100 	uintptr_t	(*al_pltenter)(Sym *, uint_t, uintptr_t *, uintptr_t *,
    101 				void *, uint_t *);
    102 	uintptr_t	(*al_pltexit)(Sym *, uint_t, uintptr_t *, uintptr_t *,
    103 				uintptr_t);
    104 	uintptr_t	(*al_symbind)(Sym *, uint_t, uintptr_t *,
    105 				uintptr_t *, uint_t *);
    106 #endif /* _ELF64 */
    107 	uint_t		al_vernum;	/* object version */
    108 };
    109 
    110 /*
    111  * Link-Edit audit functions
    112  */
    113 extern int		audit_setup(Rt_map *, Audit_desc *, uint_t, int *);
    114 
    115 extern void		audit_desc_cleanup(Rt_map *);
    116 extern void		audit_info_cleanup(Rt_map *);
    117 
    118 extern int		audit_objopen(Rt_map *, Rt_map *);
    119 extern int		audit_objfilter(Rt_map *, const char *, Rt_map *,
    120 			    uint_t flags);
    121 extern void		audit_activity(Rt_map *, uint_t);
    122 extern void		audit_preinit(Rt_map *);
    123 extern char		*audit_objsearch(Rt_map *, const char *, uint_t);
    124 extern void		audit_objclose(Rt_map *, Rt_map *);
    125 extern void		_audit_objclose(APlist *, Rt_map *);
    126 extern Addr		audit_symbind(Rt_map *, Rt_map *, Sym *, uint_t,
    127 			    Addr value, uint_t *);
    128 extern Addr		audit_pltenter(Rt_map *, Rt_map *, Sym *, uint_t,
    129 			    void *, uint_t *);
    130 extern Addr		audit_pltexit(uintptr_t, Rt_map *, Rt_map *, Sym *,
    131 			    uint_t);
    132 
    133 extern uint_t		audit_flags;
    134 
    135 #endif /* _ASM */
    136 
    137 /*
    138  * Values for audit_flags.  Intended to be the same as the LML equivalents
    139  * but kept in a separate variable to simplify boot_elf.s coding.
    140  */
    141 #define	AF_PLTENTER	0x01		/* same as LML_AUD_PLTENTER */
    142 #define	AF_PLTEXIT	0x02		/* Same as LML_AUD_PLTEXIT */
    143 
    144 #ifdef	__cplusplus
    145 }
    146 #endif
    147 
    148 #endif /* __AUDIT_DOT_H */
    149