17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 57247f888Srie * Common Development and Distribution License (the "License"). 67247f888Srie * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217247f888Srie 227c478bd9Sstevel@tonic-gate /* 23*2020b2b6SRod Evans * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate #ifndef __AUDIT_DOT_H 277c478bd9Sstevel@tonic-gate #define __AUDIT_DOT_H 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate #ifndef _ASM 307c478bd9Sstevel@tonic-gate 317c478bd9Sstevel@tonic-gate #include <sys/types.h> 327c478bd9Sstevel@tonic-gate #include <rtld.h> 337c478bd9Sstevel@tonic-gate 347c478bd9Sstevel@tonic-gate #ifdef __cplusplus 357c478bd9Sstevel@tonic-gate extern "C" { 367c478bd9Sstevel@tonic-gate #endif 377c478bd9Sstevel@tonic-gate 387c478bd9Sstevel@tonic-gate /* 397c478bd9Sstevel@tonic-gate * Define all auditing structures. 407c478bd9Sstevel@tonic-gate * 41*2020b2b6SRod Evans * A shared object may be a client of one or more audit libraries. Calls to an 42*2020b2b6SRod Evans * auditor are accompanied with cookies that identify an object being audited. 43*2020b2b6SRod Evans * These cookies are initialized to the link-map pointers of the object being 44*2020b2b6SRod Evans * audited, however the auditor is free to re-allocate these cookies, and thus 45*2020b2b6SRod Evans * associate their own data with each object being audited. 46*2020b2b6SRod Evans * 47*2020b2b6SRod Evans * With auditing version LAV_VERSION5, local auditors can provide la_preinit() 48*2020b2b6SRod Evans * and la_activity() routines, each of which should be passed a cookie that 49*2020b2b6SRod Evans * represents the link-map of the head of the associated link-map list. These 50*2020b2b6SRod Evans * cookies are maintained on the associated link-map list, using the lm_cookies 51*2020b2b6SRod Evans * alist. These cookies are created by _audit_add_head(), and dynamically 52*2020b2b6SRod Evans * retrieved by the _audit_preinit() and _audit_activity() routines. 53*2020b2b6SRod Evans * 54*2020b2b6SRod Evans * Having these cookies kept on the link-map list decouples these cookies from 55*2020b2b6SRod Evans * the Audit_client structure of the object being locally audited. In addition, 56*2020b2b6SRod Evans * this model ensures that multiple objects, undergoing local auditing from the 57*2020b2b6SRod Evans * same auditor, receive the same head link-map cookie. 587c478bd9Sstevel@tonic-gate */ 597c478bd9Sstevel@tonic-gate typedef struct { 6057ef7aa9SRod Evans Rt_map *ac_lmp; /* audit library identifier */ 617c478bd9Sstevel@tonic-gate uintptr_t ac_cookie; /* cookie assigned to audit library */ 62*2020b2b6SRod Evans Word ac_flags; /* and its associated flags */ 637c478bd9Sstevel@tonic-gate } Audit_client; 647c478bd9Sstevel@tonic-gate 657c478bd9Sstevel@tonic-gate #define FLG_AC_BINDTO 0x00001 667c478bd9Sstevel@tonic-gate #define FLG_AC_BINDFROM 0x00002 677c478bd9Sstevel@tonic-gate 687c478bd9Sstevel@tonic-gate /* 697c478bd9Sstevel@tonic-gate * Each shared object being audited may provide a list of client structures 707c478bd9Sstevel@tonic-gate * and dynamic plts (one per auditor). 717c478bd9Sstevel@tonic-gate */ 727c478bd9Sstevel@tonic-gate struct audit_info { 737c478bd9Sstevel@tonic-gate uint_t ai_cnt; /* no. of clients */ 7457ef7aa9SRod Evans Audit_client *ai_clients; /* array of client structures */ 7557ef7aa9SRod Evans void *ai_dynplts; /* array of dynamic plts */ 767c478bd9Sstevel@tonic-gate }; 777c478bd9Sstevel@tonic-gate 787c478bd9Sstevel@tonic-gate /* 797c478bd9Sstevel@tonic-gate * Define an Audit Descriptor - each audit object is added to this descriptor 807c478bd9Sstevel@tonic-gate * as an Audit Interface. There is one global audit descriptor - auditors, 817c478bd9Sstevel@tonic-gate * and a specific object my require its own - AUDITORS(lmp). 827c478bd9Sstevel@tonic-gate */ 837c478bd9Sstevel@tonic-gate struct audit_desc { 847c478bd9Sstevel@tonic-gate char *ad_name; /* originating audit names */ 8557ef7aa9SRod Evans APlist *ad_list; /* audit objs Audit Interface list */ 867c478bd9Sstevel@tonic-gate uint_t ad_cnt; /* no. of audit objs in this desc. */ 87*2020b2b6SRod Evans uint_t ad_flags; /* audit capabilities found. See */ 88*2020b2b6SRod Evans /* LML_TFLG_AUD_* flags */ 897c478bd9Sstevel@tonic-gate }; 907c478bd9Sstevel@tonic-gate 917c478bd9Sstevel@tonic-gate /* 927c478bd9Sstevel@tonic-gate * Define an Audit List descriptor for each audit object. 937c478bd9Sstevel@tonic-gate */ 947c478bd9Sstevel@tonic-gate struct audit_list { 957c478bd9Sstevel@tonic-gate const char *al_libname; /* object name for diagnostics */ 967c478bd9Sstevel@tonic-gate Rt_map *al_lmp; /* object link-map */ 977c478bd9Sstevel@tonic-gate Grp_hdl *al_ghp; /* object handle */ 987c478bd9Sstevel@tonic-gate uint_t al_flags; /* audit capabilities found */ 997c478bd9Sstevel@tonic-gate uint_t (*al_version)(uint_t); 1007c478bd9Sstevel@tonic-gate void (*al_preinit)(uintptr_t *); 1017c478bd9Sstevel@tonic-gate char *(*al_objsearch)(const char *, uintptr_t *, uint_t); 1027c478bd9Sstevel@tonic-gate uint_t (*al_objopen)(Link_map *, Lmid_t, uintptr_t *); 1037c478bd9Sstevel@tonic-gate int (*al_objfilter)(uintptr_t *, const char *, uintptr_t *, 1047c478bd9Sstevel@tonic-gate uint_t); 1057c478bd9Sstevel@tonic-gate uint_t (*al_objclose)(uintptr_t *); 1067c478bd9Sstevel@tonic-gate void (*al_activity)(uintptr_t *, uint_t); 1077c478bd9Sstevel@tonic-gate #if defined(_ELF64) 1087c478bd9Sstevel@tonic-gate uintptr_t (*al_pltenter)(Sym *, uint_t, uintptr_t *, uintptr_t *, 1097c478bd9Sstevel@tonic-gate void *, uint_t *, const char *); 1107c478bd9Sstevel@tonic-gate uintptr_t (*al_pltexit)(Sym *, uint_t, uintptr_t *, uintptr_t *, 1117c478bd9Sstevel@tonic-gate uintptr_t, const char *); 1127c478bd9Sstevel@tonic-gate uintptr_t (*al_symbind)(Sym *, uint_t, uintptr_t *, 1137c478bd9Sstevel@tonic-gate uintptr_t *, uint_t *, const char *); 1147c478bd9Sstevel@tonic-gate #else 1157c478bd9Sstevel@tonic-gate uintptr_t (*al_pltenter)(Sym *, uint_t, uintptr_t *, uintptr_t *, 1167c478bd9Sstevel@tonic-gate void *, uint_t *); 1177c478bd9Sstevel@tonic-gate uintptr_t (*al_pltexit)(Sym *, uint_t, uintptr_t *, uintptr_t *, 1187c478bd9Sstevel@tonic-gate uintptr_t); 1197c478bd9Sstevel@tonic-gate uintptr_t (*al_symbind)(Sym *, uint_t, uintptr_t *, 1207c478bd9Sstevel@tonic-gate uintptr_t *, uint_t *); 1217c478bd9Sstevel@tonic-gate #endif /* _ELF64 */ 1227c478bd9Sstevel@tonic-gate uint_t al_vernum; /* object version */ 1237c478bd9Sstevel@tonic-gate }; 1247c478bd9Sstevel@tonic-gate 1257c478bd9Sstevel@tonic-gate /* 1267c478bd9Sstevel@tonic-gate * Link-Edit audit functions 1277c478bd9Sstevel@tonic-gate */ 1289aa23310Srie extern int audit_setup(Rt_map *, Audit_desc *, uint_t, int *); 1297c478bd9Sstevel@tonic-gate 1307247f888Srie extern void audit_desc_cleanup(Rt_map *); 1317247f888Srie extern void audit_info_cleanup(Rt_map *); 1327c478bd9Sstevel@tonic-gate 1337c478bd9Sstevel@tonic-gate extern int audit_objopen(Rt_map *, Rt_map *); 1347c478bd9Sstevel@tonic-gate extern int audit_objfilter(Rt_map *, const char *, Rt_map *, 1357c478bd9Sstevel@tonic-gate uint_t flags); 1367c478bd9Sstevel@tonic-gate extern void audit_activity(Rt_map *, uint_t); 1377c478bd9Sstevel@tonic-gate extern void audit_preinit(Rt_map *); 1387c478bd9Sstevel@tonic-gate extern char *audit_objsearch(Rt_map *, const char *, uint_t); 1397c478bd9Sstevel@tonic-gate extern void audit_objclose(Rt_map *, Rt_map *); 14057ef7aa9SRod Evans extern void _audit_objclose(APlist *, Rt_map *); 1417c478bd9Sstevel@tonic-gate extern Addr audit_symbind(Rt_map *, Rt_map *, Sym *, uint_t, 1427c478bd9Sstevel@tonic-gate Addr value, uint_t *); 1437c478bd9Sstevel@tonic-gate extern Addr audit_pltenter(Rt_map *, Rt_map *, Sym *, uint_t, 1447c478bd9Sstevel@tonic-gate void *, uint_t *); 1457c478bd9Sstevel@tonic-gate extern Addr audit_pltexit(uintptr_t, Rt_map *, Rt_map *, Sym *, 1467c478bd9Sstevel@tonic-gate uint_t); 1477c478bd9Sstevel@tonic-gate 1487c478bd9Sstevel@tonic-gate extern uint_t audit_flags; 1497c478bd9Sstevel@tonic-gate 1507c478bd9Sstevel@tonic-gate #endif /* _ASM */ 1517c478bd9Sstevel@tonic-gate 1527c478bd9Sstevel@tonic-gate /* 1537c478bd9Sstevel@tonic-gate * Values for audit_flags. Intended to be the same as the LML equivalents 1547c478bd9Sstevel@tonic-gate * but kept in a separate variable to simplify boot_elf.s coding. 1557c478bd9Sstevel@tonic-gate */ 1567c478bd9Sstevel@tonic-gate #define AF_PLTENTER 0x01 /* same as LML_AUD_PLTENTER */ 1577c478bd9Sstevel@tonic-gate #define AF_PLTEXIT 0x02 /* Same as LML_AUD_PLTEXIT */ 1587c478bd9Sstevel@tonic-gate 1597c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1607c478bd9Sstevel@tonic-gate } 1617c478bd9Sstevel@tonic-gate #endif 1627c478bd9Sstevel@tonic-gate 1637c478bd9Sstevel@tonic-gate #endif /* __AUDIT_DOT_H */ 164