1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* 23*7c478bd9Sstevel@tonic-gate * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 24*7c478bd9Sstevel@tonic-gate * Use is subject to license terms. 25*7c478bd9Sstevel@tonic-gate */ 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate /* 28*7c478bd9Sstevel@tonic-gate * This file contains the declarations of the various data structures 29*7c478bd9Sstevel@tonic-gate * used by the auditing module(s). 30*7c478bd9Sstevel@tonic-gate */ 31*7c478bd9Sstevel@tonic-gate 32*7c478bd9Sstevel@tonic-gate #ifndef _BSM_AUDIT_H 33*7c478bd9Sstevel@tonic-gate #define _BSM_AUDIT_H 34*7c478bd9Sstevel@tonic-gate 35*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 36*7c478bd9Sstevel@tonic-gate 37*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 38*7c478bd9Sstevel@tonic-gate extern "C" { 39*7c478bd9Sstevel@tonic-gate #endif 40*7c478bd9Sstevel@tonic-gate 41*7c478bd9Sstevel@tonic-gate 42*7c478bd9Sstevel@tonic-gate #include <sys/shm.h> /* for shmid_ds structure */ 43*7c478bd9Sstevel@tonic-gate #include <sys/sem.h> /* for semid_ds structure */ 44*7c478bd9Sstevel@tonic-gate #include <sys/msg.h> /* for msqid_ds structure */ 45*7c478bd9Sstevel@tonic-gate #include <sys/atomic.h> /* using atomics */ 46*7c478bd9Sstevel@tonic-gate 47*7c478bd9Sstevel@tonic-gate /* 48*7c478bd9Sstevel@tonic-gate * Audit conditions, statements reguarding what's to be done with 49*7c478bd9Sstevel@tonic-gate * audit records. Neither AUC_ENABLED, AUC_DISABLED, nor AUC_UNSET 50*7c478bd9Sstevel@tonic-gate * are returned on an auditconfig -getcond call. 51*7c478bd9Sstevel@tonic-gate */ 52*7c478bd9Sstevel@tonic-gate /* global state */ 53*7c478bd9Sstevel@tonic-gate #define AUC_DISABLED -1 /* audit module loaded but not enabled */ 54*7c478bd9Sstevel@tonic-gate #define AUC_UNSET 0 /* on/off hasn't been decided */ 55*7c478bd9Sstevel@tonic-gate #define AUC_ENABLED 1 /* loaded and enabled */ 56*7c478bd9Sstevel@tonic-gate /* local zone state */ 57*7c478bd9Sstevel@tonic-gate #define AUC_INIT_AUDIT 4 /* c2audit is ready but auditd has not run */ 58*7c478bd9Sstevel@tonic-gate #define AUC_AUDITING 1 /* auditing is being done */ 59*7c478bd9Sstevel@tonic-gate #define AUC_NOAUDIT 2 /* auditing is not being done */ 60*7c478bd9Sstevel@tonic-gate #define AUC_NOSPACE 3 /* audit enabled, no space for audit records */ 61*7c478bd9Sstevel@tonic-gate 62*7c478bd9Sstevel@tonic-gate /* 63*7c478bd9Sstevel@tonic-gate * The user id -2 is never audited - in fact, a setauid(AU_NOAUDITID) 64*7c478bd9Sstevel@tonic-gate * will turn off auditing. 65*7c478bd9Sstevel@tonic-gate */ 66*7c478bd9Sstevel@tonic-gate #define AU_NOAUDITID -2 67*7c478bd9Sstevel@tonic-gate 68*7c478bd9Sstevel@tonic-gate /* 69*7c478bd9Sstevel@tonic-gate * success/failure bits for asynchronous events 70*7c478bd9Sstevel@tonic-gate */ 71*7c478bd9Sstevel@tonic-gate 72*7c478bd9Sstevel@tonic-gate #define AUM_SUCC 1 /* use the system success preselection mask */ 73*7c478bd9Sstevel@tonic-gate #define AUM_FAIL 2 /* use the system failure preselection mask */ 74*7c478bd9Sstevel@tonic-gate 75*7c478bd9Sstevel@tonic-gate 76*7c478bd9Sstevel@tonic-gate /* 77*7c478bd9Sstevel@tonic-gate * Defines for event modifier field 78*7c478bd9Sstevel@tonic-gate */ 79*7c478bd9Sstevel@tonic-gate #define PAD_READ 0x0001 /* object read */ 80*7c478bd9Sstevel@tonic-gate #define PAD_WRITE 0x0002 /* object write */ 81*7c478bd9Sstevel@tonic-gate #define PAD_NONATTR 0x4000 /* non-attributable event */ 82*7c478bd9Sstevel@tonic-gate #define PAD_FAILURE 0x8000 /* fail audit event */ 83*7c478bd9Sstevel@tonic-gate #define PAD_SPRIVUSE 0x0080 /* successfully used privileged */ 84*7c478bd9Sstevel@tonic-gate #define PAD_FPRIVUSE 0x0100 /* failed use of privileged */ 85*7c478bd9Sstevel@tonic-gate 86*7c478bd9Sstevel@tonic-gate /* 87*7c478bd9Sstevel@tonic-gate * Some typedefs for the fundamentals 88*7c478bd9Sstevel@tonic-gate */ 89*7c478bd9Sstevel@tonic-gate typedef pid_t au_asid_t; 90*7c478bd9Sstevel@tonic-gate typedef uint_t au_class_t; 91*7c478bd9Sstevel@tonic-gate typedef short au_event_t; 92*7c478bd9Sstevel@tonic-gate typedef short au_emod_t; 93*7c478bd9Sstevel@tonic-gate typedef uid_t au_id_t; 94*7c478bd9Sstevel@tonic-gate 95*7c478bd9Sstevel@tonic-gate /* 96*7c478bd9Sstevel@tonic-gate * An audit event mask. 97*7c478bd9Sstevel@tonic-gate */ 98*7c478bd9Sstevel@tonic-gate #define AU_MASK_ALL 0xFFFFFFFF /* all bits on for unsigned int */ 99*7c478bd9Sstevel@tonic-gate #define AU_MASK_NONE 0x0 /* all bits off = no:invalid class */ 100*7c478bd9Sstevel@tonic-gate 101*7c478bd9Sstevel@tonic-gate struct au_mask { 102*7c478bd9Sstevel@tonic-gate unsigned int am_success; /* success bits */ 103*7c478bd9Sstevel@tonic-gate unsigned int am_failure; /* failure bits */ 104*7c478bd9Sstevel@tonic-gate }; 105*7c478bd9Sstevel@tonic-gate typedef struct au_mask au_mask_t; 106*7c478bd9Sstevel@tonic-gate #define as_success am_success 107*7c478bd9Sstevel@tonic-gate #define as_failure am_failure 108*7c478bd9Sstevel@tonic-gate 109*7c478bd9Sstevel@tonic-gate /* 110*7c478bd9Sstevel@tonic-gate * The structure of the terminal ID (ipv4) 111*7c478bd9Sstevel@tonic-gate */ 112*7c478bd9Sstevel@tonic-gate struct au_tid { 113*7c478bd9Sstevel@tonic-gate dev_t port; 114*7c478bd9Sstevel@tonic-gate uint_t machine; 115*7c478bd9Sstevel@tonic-gate }; 116*7c478bd9Sstevel@tonic-gate 117*7c478bd9Sstevel@tonic-gate #if defined(_SYSCALL32) 118*7c478bd9Sstevel@tonic-gate struct au_tid32 { 119*7c478bd9Sstevel@tonic-gate uint_t port; 120*7c478bd9Sstevel@tonic-gate uint_t machine; 121*7c478bd9Sstevel@tonic-gate }; 122*7c478bd9Sstevel@tonic-gate 123*7c478bd9Sstevel@tonic-gate typedef struct au_tid32 au_tid32_t; 124*7c478bd9Sstevel@tonic-gate #endif 125*7c478bd9Sstevel@tonic-gate 126*7c478bd9Sstevel@tonic-gate typedef struct au_tid au_tid_t; 127*7c478bd9Sstevel@tonic-gate 128*7c478bd9Sstevel@tonic-gate /* 129*7c478bd9Sstevel@tonic-gate * The structure of the terminal ID (ipv6) 130*7c478bd9Sstevel@tonic-gate */ 131*7c478bd9Sstevel@tonic-gate struct au_tid_addr { 132*7c478bd9Sstevel@tonic-gate dev_t at_port; 133*7c478bd9Sstevel@tonic-gate uint_t at_type; 134*7c478bd9Sstevel@tonic-gate uint_t at_addr[4]; 135*7c478bd9Sstevel@tonic-gate }; 136*7c478bd9Sstevel@tonic-gate 137*7c478bd9Sstevel@tonic-gate struct au_port_s { 138*7c478bd9Sstevel@tonic-gate uint32_t at_major; /* major # */ 139*7c478bd9Sstevel@tonic-gate uint32_t at_minor; /* minor # */ 140*7c478bd9Sstevel@tonic-gate }; 141*7c478bd9Sstevel@tonic-gate typedef struct au_port_s au_port_t; 142*7c478bd9Sstevel@tonic-gate 143*7c478bd9Sstevel@tonic-gate struct au_tid_addr64 { 144*7c478bd9Sstevel@tonic-gate au_port_t at_port; 145*7c478bd9Sstevel@tonic-gate uint_t at_type; 146*7c478bd9Sstevel@tonic-gate uint_t at_addr[4]; 147*7c478bd9Sstevel@tonic-gate }; 148*7c478bd9Sstevel@tonic-gate typedef struct au_tid_addr64 au_tid64_addr_t; 149*7c478bd9Sstevel@tonic-gate 150*7c478bd9Sstevel@tonic-gate #if defined(_SYSCALL32) 151*7c478bd9Sstevel@tonic-gate struct au_tid_addr32 { 152*7c478bd9Sstevel@tonic-gate uint_t at_port; 153*7c478bd9Sstevel@tonic-gate uint_t at_type; 154*7c478bd9Sstevel@tonic-gate uint_t at_addr[4]; 155*7c478bd9Sstevel@tonic-gate }; 156*7c478bd9Sstevel@tonic-gate 157*7c478bd9Sstevel@tonic-gate typedef struct au_tid_addr32 au_tid32_addr_t; 158*7c478bd9Sstevel@tonic-gate #endif 159*7c478bd9Sstevel@tonic-gate 160*7c478bd9Sstevel@tonic-gate typedef struct au_tid_addr au_tid_addr_t; 161*7c478bd9Sstevel@tonic-gate 162*7c478bd9Sstevel@tonic-gate struct au_ip { 163*7c478bd9Sstevel@tonic-gate uint16_t at_r_port; /* remote port */ 164*7c478bd9Sstevel@tonic-gate uint16_t at_l_port; /* local port */ 165*7c478bd9Sstevel@tonic-gate uint32_t at_type; /* AU_IPv4,... */ 166*7c478bd9Sstevel@tonic-gate uint32_t at_addr[4]; /* remote IP */ 167*7c478bd9Sstevel@tonic-gate }; 168*7c478bd9Sstevel@tonic-gate typedef struct au_ip au_ip_t; 169*7c478bd9Sstevel@tonic-gate 170*7c478bd9Sstevel@tonic-gate /* 171*7c478bd9Sstevel@tonic-gate * Generic network address structure 172*7c478bd9Sstevel@tonic-gate */ 173*7c478bd9Sstevel@tonic-gate struct au_generic_tid { 174*7c478bd9Sstevel@tonic-gate uchar_t gt_type; /* AU_IPADR, AU_DEVICE,... */ 175*7c478bd9Sstevel@tonic-gate union { 176*7c478bd9Sstevel@tonic-gate au_ip_t at_ip; 177*7c478bd9Sstevel@tonic-gate au_port_t at_dev; 178*7c478bd9Sstevel@tonic-gate } gt_adr; 179*7c478bd9Sstevel@tonic-gate }; 180*7c478bd9Sstevel@tonic-gate typedef struct au_generic_tid au_generic_tid_t; 181*7c478bd9Sstevel@tonic-gate 182*7c478bd9Sstevel@tonic-gate /* 183*7c478bd9Sstevel@tonic-gate * au_generic_tid_t gt_type values 184*7c478bd9Sstevel@tonic-gate * 0 is reserved for uninitialized data 185*7c478bd9Sstevel@tonic-gate */ 186*7c478bd9Sstevel@tonic-gate #define AU_IPADR 1 187*7c478bd9Sstevel@tonic-gate #define AU_ETHER 2 188*7c478bd9Sstevel@tonic-gate #define AU_DEVICE 3 189*7c478bd9Sstevel@tonic-gate 190*7c478bd9Sstevel@tonic-gate /* 191*7c478bd9Sstevel@tonic-gate * at_type values - address length used to identify address type 192*7c478bd9Sstevel@tonic-gate */ 193*7c478bd9Sstevel@tonic-gate #define AU_IPv4 4 /* ipv4 type IP address */ 194*7c478bd9Sstevel@tonic-gate #define AU_IPv6 16 /* ipv6 type IP address */ 195*7c478bd9Sstevel@tonic-gate 196*7c478bd9Sstevel@tonic-gate /* 197*7c478bd9Sstevel@tonic-gate * Compatability with SunOS 4.x BSM module 198*7c478bd9Sstevel@tonic-gate * 199*7c478bd9Sstevel@tonic-gate * New code should not contain audit_state_t, 200*7c478bd9Sstevel@tonic-gate * au_state_t, nor au_termid as these types 201*7c478bd9Sstevel@tonic-gate * may go away in future releases. 202*7c478bd9Sstevel@tonic-gate * 203*7c478bd9Sstevel@tonic-gate * typedef new-5.x-bsm-name old-4.x-bsm-name 204*7c478bd9Sstevel@tonic-gate */ 205*7c478bd9Sstevel@tonic-gate 206*7c478bd9Sstevel@tonic-gate typedef au_class_t au_state_t; 207*7c478bd9Sstevel@tonic-gate typedef au_mask_t audit_state_t; 208*7c478bd9Sstevel@tonic-gate typedef au_id_t auid_t; 209*7c478bd9Sstevel@tonic-gate #define ai_state ai_mask; 210*7c478bd9Sstevel@tonic-gate 211*7c478bd9Sstevel@tonic-gate /* 212*7c478bd9Sstevel@tonic-gate * Opcodes for bsm system calls 213*7c478bd9Sstevel@tonic-gate */ 214*7c478bd9Sstevel@tonic-gate 215*7c478bd9Sstevel@tonic-gate #define BSM_GETAUID 19 216*7c478bd9Sstevel@tonic-gate #define BSM_SETAUID 20 217*7c478bd9Sstevel@tonic-gate #define BSM_GETAUDIT 21 218*7c478bd9Sstevel@tonic-gate #define BSM_SETAUDIT 22 219*7c478bd9Sstevel@tonic-gate #define BSM_GETUSERAUDIT 23 220*7c478bd9Sstevel@tonic-gate #define BSM_SETUSERAUDIT 24 221*7c478bd9Sstevel@tonic-gate #define BSM_AUDIT 25 222*7c478bd9Sstevel@tonic-gate #define BSM_AUDITUSER 26 223*7c478bd9Sstevel@tonic-gate #define BSM_AUDITSVC 27 /* EOL announced for Sol 10 */ 224*7c478bd9Sstevel@tonic-gate #define BSM_AUDITON 28 225*7c478bd9Sstevel@tonic-gate #define BSM_AUDITCTL 29 226*7c478bd9Sstevel@tonic-gate #define BSM_GETKERNSTATE 30 227*7c478bd9Sstevel@tonic-gate #define BSM_SETKERNSTATE 31 228*7c478bd9Sstevel@tonic-gate #define BSM_GETPORTAUDIT 32 229*7c478bd9Sstevel@tonic-gate #define BSM_REVOKE 33 230*7c478bd9Sstevel@tonic-gate #define BSM_AUDITSTAT 34 231*7c478bd9Sstevel@tonic-gate #define BSM_GETAUDIT_ADDR 35 232*7c478bd9Sstevel@tonic-gate #define BSM_SETAUDIT_ADDR 36 233*7c478bd9Sstevel@tonic-gate #define BSM_AUDITDOOR 37 234*7c478bd9Sstevel@tonic-gate 235*7c478bd9Sstevel@tonic-gate /* 236*7c478bd9Sstevel@tonic-gate * Auditctl(2) commands 237*7c478bd9Sstevel@tonic-gate */ 238*7c478bd9Sstevel@tonic-gate #define A_GETPOLICY 2 /* get audit policy */ 239*7c478bd9Sstevel@tonic-gate #define A_SETPOLICY 3 /* set audit policy */ 240*7c478bd9Sstevel@tonic-gate #define A_GETKMASK 4 /* get kernel event preselection mask */ 241*7c478bd9Sstevel@tonic-gate #define A_SETKMASK 5 /* set kernel event preselection mask */ 242*7c478bd9Sstevel@tonic-gate #define A_GETQCTRL 6 /* get kernel audit queue ctrl parameters */ 243*7c478bd9Sstevel@tonic-gate #define A_SETQCTRL 7 /* set kernel audit queue ctrl parameters */ 244*7c478bd9Sstevel@tonic-gate #define A_GETCWD 8 /* get process current working directory */ 245*7c478bd9Sstevel@tonic-gate #define A_GETCAR 9 /* get process current active root */ 246*7c478bd9Sstevel@tonic-gate #define A_GETSTAT 12 /* get audit statistics */ 247*7c478bd9Sstevel@tonic-gate #define A_SETSTAT 13 /* (re)set audit statistics */ 248*7c478bd9Sstevel@tonic-gate #define A_SETUMASK 14 /* set preselection mask for procs with auid */ 249*7c478bd9Sstevel@tonic-gate #define A_SETSMASK 15 /* set preselection mask for procs with asid */ 250*7c478bd9Sstevel@tonic-gate #define A_GETCOND 20 /* get audit system on/off condition */ 251*7c478bd9Sstevel@tonic-gate #define A_SETCOND 21 /* set audit system on/off condition */ 252*7c478bd9Sstevel@tonic-gate #define A_GETCLASS 22 /* get audit event to class mapping */ 253*7c478bd9Sstevel@tonic-gate #define A_SETCLASS 23 /* set audit event to class mapping */ 254*7c478bd9Sstevel@tonic-gate #define A_GETPINFO 24 /* get audit info for an arbitrary pid */ 255*7c478bd9Sstevel@tonic-gate #define A_SETPMASK 25 /* set preselection mask for an given pid */ 256*7c478bd9Sstevel@tonic-gate #define A_SETFSIZE 26 /* set audit file size */ 257*7c478bd9Sstevel@tonic-gate #define A_GETFSIZE 27 /* get audit file size */ 258*7c478bd9Sstevel@tonic-gate #define A_GETPINFO_ADDR 28 /* get audit info for an arbitrary pid */ 259*7c478bd9Sstevel@tonic-gate #define A_GETKAUDIT 29 /* get kernel audit characteristics */ 260*7c478bd9Sstevel@tonic-gate #define A_SETKAUDIT 30 /* set kernel audit characteristics */ 261*7c478bd9Sstevel@tonic-gate 262*7c478bd9Sstevel@tonic-gate /* 263*7c478bd9Sstevel@tonic-gate * Audit Policy parameters (32 bits) 264*7c478bd9Sstevel@tonic-gate */ 265*7c478bd9Sstevel@tonic-gate #define AUDIT_CNT 0x0001 /* do NOT sleep undelivered synch events */ 266*7c478bd9Sstevel@tonic-gate #define AUDIT_AHLT 0x0002 /* HALT machine on undelivered async event */ 267*7c478bd9Sstevel@tonic-gate #define AUDIT_ARGV 0x0004 /* include argv with execv system call events */ 268*7c478bd9Sstevel@tonic-gate #define AUDIT_ARGE 0x0008 /* include arge with execv system call events */ 269*7c478bd9Sstevel@tonic-gate #define AUDIT_PASSWD 0x0010 /* include bad password with "login" events */ 270*7c478bd9Sstevel@tonic-gate #define AUDIT_SEQ 0x0020 /* include sequence attribute */ 271*7c478bd9Sstevel@tonic-gate #define AUDIT_WINDATA 0x0040 /* include interwindow moved data */ 272*7c478bd9Sstevel@tonic-gate #define AUDIT_USER 0x0080 /* make audituser(2) un-privileged */ 273*7c478bd9Sstevel@tonic-gate #define AUDIT_GROUP 0x0100 /* include group attribute with each record */ 274*7c478bd9Sstevel@tonic-gate #define AUDIT_TRAIL 0X0200 /* include trailer token */ 275*7c478bd9Sstevel@tonic-gate #define AUDIT_PATH 0x0400 /* allow multiple paths per event */ 276*7c478bd9Sstevel@tonic-gate #define AUDIT_SCNT 0x0800 /* sleep user events but not kernel events */ 277*7c478bd9Sstevel@tonic-gate #define AUDIT_PUBLIC 0x1000 /* audit even "public" files */ 278*7c478bd9Sstevel@tonic-gate #define AUDIT_ZONENAME 0x2000 /* emit zonename token */ 279*7c478bd9Sstevel@tonic-gate #define AUDIT_PERZONE 0x4000 /* auditd and audit queue for each zone */ 280*7c478bd9Sstevel@tonic-gate /* 281*7c478bd9Sstevel@tonic-gate * If AUDIT_GLOBAL changes, corresponding changes are required in 282*7c478bd9Sstevel@tonic-gate * audit_syscalls.c's setpolicy(). 283*7c478bd9Sstevel@tonic-gate */ 284*7c478bd9Sstevel@tonic-gate #define AUDIT_GLOBAL (AUDIT_AHLT | AUDIT_PERZONE) 285*7c478bd9Sstevel@tonic-gate #define AUDIT_LOCAL (AUDIT_CNT | AUDIT_ARGV | AUDIT_ARGE |\ 286*7c478bd9Sstevel@tonic-gate AUDIT_PASSWD | AUDIT_SEQ | AUDIT_WINDATA |\ 287*7c478bd9Sstevel@tonic-gate AUDIT_USER | AUDIT_GROUP | AUDIT_TRAIL | AUDIT_PATH |\ 288*7c478bd9Sstevel@tonic-gate AUDIT_PUBLIC | AUDIT_SCNT | AUDIT_ZONENAME) 289*7c478bd9Sstevel@tonic-gate 290*7c478bd9Sstevel@tonic-gate /* 291*7c478bd9Sstevel@tonic-gate * Kernel audit queue control parameters 292*7c478bd9Sstevel@tonic-gate * 293*7c478bd9Sstevel@tonic-gate * audit record recording blocks at hiwater # undelived records 294*7c478bd9Sstevel@tonic-gate * audit record recording resumes at lowwater # undelivered audit records 295*7c478bd9Sstevel@tonic-gate * bufsz determines how big the data xfers will be to the audit trail 296*7c478bd9Sstevel@tonic-gate */ 297*7c478bd9Sstevel@tonic-gate struct au_qctrl { 298*7c478bd9Sstevel@tonic-gate size_t aq_hiwater; /* kernel audit queue, high water mark */ 299*7c478bd9Sstevel@tonic-gate size_t aq_lowater; /* kernel audit queue, low water mark */ 300*7c478bd9Sstevel@tonic-gate size_t aq_bufsz; /* kernel audit queue, write size to trail */ 301*7c478bd9Sstevel@tonic-gate clock_t aq_delay; /* delay before flushing audit queue */ 302*7c478bd9Sstevel@tonic-gate }; 303*7c478bd9Sstevel@tonic-gate 304*7c478bd9Sstevel@tonic-gate #if defined(_SYSCALL32) 305*7c478bd9Sstevel@tonic-gate struct au_qctrl32 { 306*7c478bd9Sstevel@tonic-gate size32_t aq_hiwater; 307*7c478bd9Sstevel@tonic-gate size32_t aq_lowater; 308*7c478bd9Sstevel@tonic-gate size32_t aq_bufsz; 309*7c478bd9Sstevel@tonic-gate clock32_t aq_delay; 310*7c478bd9Sstevel@tonic-gate }; 311*7c478bd9Sstevel@tonic-gate #endif 312*7c478bd9Sstevel@tonic-gate 313*7c478bd9Sstevel@tonic-gate 314*7c478bd9Sstevel@tonic-gate /* 315*7c478bd9Sstevel@tonic-gate * default values of hiwater and lowater (note hi > lo) 316*7c478bd9Sstevel@tonic-gate */ 317*7c478bd9Sstevel@tonic-gate #define AQ_HIWATER 100 318*7c478bd9Sstevel@tonic-gate #define AQ_MAXHIGH 100000 319*7c478bd9Sstevel@tonic-gate #define AQ_LOWATER 10 320*7c478bd9Sstevel@tonic-gate #define AQ_BUFSZ 8192 321*7c478bd9Sstevel@tonic-gate #define AQ_MAXBUFSZ 1048576 322*7c478bd9Sstevel@tonic-gate #define AQ_DELAY 20 323*7c478bd9Sstevel@tonic-gate #define AQ_MAXDELAY 20000 324*7c478bd9Sstevel@tonic-gate 325*7c478bd9Sstevel@tonic-gate struct auditinfo { 326*7c478bd9Sstevel@tonic-gate au_id_t ai_auid; 327*7c478bd9Sstevel@tonic-gate au_mask_t ai_mask; 328*7c478bd9Sstevel@tonic-gate au_tid_t ai_termid; 329*7c478bd9Sstevel@tonic-gate au_asid_t ai_asid; 330*7c478bd9Sstevel@tonic-gate }; 331*7c478bd9Sstevel@tonic-gate 332*7c478bd9Sstevel@tonic-gate #if defined(_SYSCALL32) 333*7c478bd9Sstevel@tonic-gate struct auditinfo32 { 334*7c478bd9Sstevel@tonic-gate au_id_t ai_auid; 335*7c478bd9Sstevel@tonic-gate au_mask_t ai_mask; 336*7c478bd9Sstevel@tonic-gate au_tid32_t ai_termid; 337*7c478bd9Sstevel@tonic-gate au_asid_t ai_asid; 338*7c478bd9Sstevel@tonic-gate }; 339*7c478bd9Sstevel@tonic-gate 340*7c478bd9Sstevel@tonic-gate typedef struct auditinfo32 auditinfo32_t; 341*7c478bd9Sstevel@tonic-gate #endif 342*7c478bd9Sstevel@tonic-gate 343*7c478bd9Sstevel@tonic-gate typedef struct auditinfo auditinfo_t; 344*7c478bd9Sstevel@tonic-gate 345*7c478bd9Sstevel@tonic-gate struct auditinfo_addr { 346*7c478bd9Sstevel@tonic-gate au_id_t ai_auid; 347*7c478bd9Sstevel@tonic-gate au_mask_t ai_mask; 348*7c478bd9Sstevel@tonic-gate au_tid_addr_t ai_termid; 349*7c478bd9Sstevel@tonic-gate au_asid_t ai_asid; 350*7c478bd9Sstevel@tonic-gate }; 351*7c478bd9Sstevel@tonic-gate 352*7c478bd9Sstevel@tonic-gate struct auditinfo_addr64 { 353*7c478bd9Sstevel@tonic-gate au_id_t ai_auid; 354*7c478bd9Sstevel@tonic-gate au_mask_t ai_mask; 355*7c478bd9Sstevel@tonic-gate au_tid64_addr_t ai_termid; 356*7c478bd9Sstevel@tonic-gate au_asid_t ai_asid; 357*7c478bd9Sstevel@tonic-gate }; 358*7c478bd9Sstevel@tonic-gate typedef struct auditinfo_addr64 auditinfo64_addr_t; 359*7c478bd9Sstevel@tonic-gate 360*7c478bd9Sstevel@tonic-gate #if defined(_SYSCALL32) 361*7c478bd9Sstevel@tonic-gate struct auditinfo_addr32 { 362*7c478bd9Sstevel@tonic-gate au_id_t ai_auid; 363*7c478bd9Sstevel@tonic-gate au_mask_t ai_mask; 364*7c478bd9Sstevel@tonic-gate au_tid32_addr_t ai_termid; 365*7c478bd9Sstevel@tonic-gate au_asid_t ai_asid; 366*7c478bd9Sstevel@tonic-gate }; 367*7c478bd9Sstevel@tonic-gate 368*7c478bd9Sstevel@tonic-gate typedef struct auditinfo_addr32 auditinfo32_addr_t; 369*7c478bd9Sstevel@tonic-gate #endif 370*7c478bd9Sstevel@tonic-gate 371*7c478bd9Sstevel@tonic-gate typedef struct auditinfo_addr auditinfo_addr_t; 372*7c478bd9Sstevel@tonic-gate 373*7c478bd9Sstevel@tonic-gate struct auditpinfo { 374*7c478bd9Sstevel@tonic-gate pid_t ap_pid; 375*7c478bd9Sstevel@tonic-gate au_id_t ap_auid; 376*7c478bd9Sstevel@tonic-gate au_mask_t ap_mask; 377*7c478bd9Sstevel@tonic-gate au_tid_t ap_termid; 378*7c478bd9Sstevel@tonic-gate au_asid_t ap_asid; 379*7c478bd9Sstevel@tonic-gate }; 380*7c478bd9Sstevel@tonic-gate 381*7c478bd9Sstevel@tonic-gate #if defined(_SYSCALL32) 382*7c478bd9Sstevel@tonic-gate struct auditpinfo32 { 383*7c478bd9Sstevel@tonic-gate pid_t ap_pid; 384*7c478bd9Sstevel@tonic-gate au_id_t ap_auid; 385*7c478bd9Sstevel@tonic-gate au_mask_t ap_mask; 386*7c478bd9Sstevel@tonic-gate au_tid32_t ap_termid; 387*7c478bd9Sstevel@tonic-gate au_asid_t ap_asid; 388*7c478bd9Sstevel@tonic-gate }; 389*7c478bd9Sstevel@tonic-gate #endif 390*7c478bd9Sstevel@tonic-gate 391*7c478bd9Sstevel@tonic-gate 392*7c478bd9Sstevel@tonic-gate struct auditpinfo_addr { 393*7c478bd9Sstevel@tonic-gate pid_t ap_pid; 394*7c478bd9Sstevel@tonic-gate au_id_t ap_auid; 395*7c478bd9Sstevel@tonic-gate au_mask_t ap_mask; 396*7c478bd9Sstevel@tonic-gate au_tid_addr_t ap_termid; 397*7c478bd9Sstevel@tonic-gate au_asid_t ap_asid; 398*7c478bd9Sstevel@tonic-gate }; 399*7c478bd9Sstevel@tonic-gate 400*7c478bd9Sstevel@tonic-gate #if defined(_SYSCALL32) 401*7c478bd9Sstevel@tonic-gate struct auditpinfo_addr32 { 402*7c478bd9Sstevel@tonic-gate pid_t ap_pid; 403*7c478bd9Sstevel@tonic-gate au_id_t ap_auid; 404*7c478bd9Sstevel@tonic-gate au_mask_t ap_mask; 405*7c478bd9Sstevel@tonic-gate au_tid32_addr_t ap_termid; 406*7c478bd9Sstevel@tonic-gate au_asid_t ap_asid; 407*7c478bd9Sstevel@tonic-gate }; 408*7c478bd9Sstevel@tonic-gate #endif 409*7c478bd9Sstevel@tonic-gate 410*7c478bd9Sstevel@tonic-gate 411*7c478bd9Sstevel@tonic-gate struct au_evclass_map { 412*7c478bd9Sstevel@tonic-gate au_event_t ec_number; 413*7c478bd9Sstevel@tonic-gate au_class_t ec_class; 414*7c478bd9Sstevel@tonic-gate }; 415*7c478bd9Sstevel@tonic-gate typedef struct au_evclass_map au_evclass_map_t; 416*7c478bd9Sstevel@tonic-gate 417*7c478bd9Sstevel@tonic-gate /* 418*7c478bd9Sstevel@tonic-gate * Audit stat structures (used to be in audit_stat.h 419*7c478bd9Sstevel@tonic-gate */ 420*7c478bd9Sstevel@tonic-gate 421*7c478bd9Sstevel@tonic-gate struct audit_stat { 422*7c478bd9Sstevel@tonic-gate unsigned int as_version; /* version of kernel audit code */ 423*7c478bd9Sstevel@tonic-gate unsigned int as_numevent; /* number of kernel audit events */ 424*7c478bd9Sstevel@tonic-gate uint32_t as_generated; /* # records processed */ 425*7c478bd9Sstevel@tonic-gate uint32_t as_nonattrib; /* # non-attributed records produced */ 426*7c478bd9Sstevel@tonic-gate uint32_t as_kernel; /* # records produced by kernel */ 427*7c478bd9Sstevel@tonic-gate uint32_t as_audit; /* # records processed by audit(2) */ 428*7c478bd9Sstevel@tonic-gate uint32_t as_auditctl; /* # records processed by auditctl(2) */ 429*7c478bd9Sstevel@tonic-gate uint32_t as_enqueue; /* # records put onto audit queue */ 430*7c478bd9Sstevel@tonic-gate uint32_t as_written; /* # records written to audit trail */ 431*7c478bd9Sstevel@tonic-gate uint32_t as_wblocked; /* # times write blked on audit queue */ 432*7c478bd9Sstevel@tonic-gate uint32_t as_rblocked; /* # times read blked on audit queue */ 433*7c478bd9Sstevel@tonic-gate uint32_t as_dropped; /* # of dropped audit records */ 434*7c478bd9Sstevel@tonic-gate uint32_t as_totalsize; /* total number bytes of audit data */ 435*7c478bd9Sstevel@tonic-gate uint32_t as_memused; /* no longer used */ 436*7c478bd9Sstevel@tonic-gate }; 437*7c478bd9Sstevel@tonic-gate typedef struct audit_stat au_stat_t; 438*7c478bd9Sstevel@tonic-gate extern int au_naevent; 439*7c478bd9Sstevel@tonic-gate 440*7c478bd9Sstevel@tonic-gate /* 441*7c478bd9Sstevel@tonic-gate * Secondary stat structure for file size stuff. The stat structure was 442*7c478bd9Sstevel@tonic-gate * not combined to preserve the semantics of the 5.1 - 5.3 A_GETSTAT call 443*7c478bd9Sstevel@tonic-gate */ 444*7c478bd9Sstevel@tonic-gate struct audit_fstat { 445*7c478bd9Sstevel@tonic-gate unsigned int af_filesz; 446*7c478bd9Sstevel@tonic-gate unsigned int af_currsz; 447*7c478bd9Sstevel@tonic-gate }; 448*7c478bd9Sstevel@tonic-gate typedef struct audit_fstat au_fstat_t; 449*7c478bd9Sstevel@tonic-gate 450*7c478bd9Sstevel@tonic-gate /* set kernel audit context dependent on AUDIT_PERZONE policy */ 451*7c478bd9Sstevel@tonic-gate #define SET_KCTX_PZ zone_getspecific(au_zone_key,\ 452*7c478bd9Sstevel@tonic-gate (audit_policy & AUDIT_PERZONE) ?\ 453*7c478bd9Sstevel@tonic-gate curproc->p_zone :\ 454*7c478bd9Sstevel@tonic-gate global_zone) 455*7c478bd9Sstevel@tonic-gate /* set kernel audit context to global zone */ 456*7c478bd9Sstevel@tonic-gate #define SET_KCTX_GZ zone_getspecific(au_zone_key,\ 457*7c478bd9Sstevel@tonic-gate global_zone) 458*7c478bd9Sstevel@tonic-gate /* set kernel audit context to local zone */ 459*7c478bd9Sstevel@tonic-gate #define SET_KCTX_LZ zone_getspecific(au_zone_key, curproc->p_zone) 460*7c478bd9Sstevel@tonic-gate 461*7c478bd9Sstevel@tonic-gate #define AS_INC(a, b, c) atomic_add_32(&(c->auk_statistics.a), (b)) 462*7c478bd9Sstevel@tonic-gate #define AS_DEC(a, b, c) atomic_add_32(&(c->auk_statistics.a), -(b)) 463*7c478bd9Sstevel@tonic-gate 464*7c478bd9Sstevel@tonic-gate /* 465*7c478bd9Sstevel@tonic-gate * audit token IPC types (shm, sem, msg) [for ipc attribute] 466*7c478bd9Sstevel@tonic-gate */ 467*7c478bd9Sstevel@tonic-gate 468*7c478bd9Sstevel@tonic-gate #define AT_IPC_MSG ((char)1) /* message IPC id */ 469*7c478bd9Sstevel@tonic-gate #define AT_IPC_SEM ((char)2) /* semaphore IPC id */ 470*7c478bd9Sstevel@tonic-gate #define AT_IPC_SHM ((char)3) /* shared memory IPC id */ 471*7c478bd9Sstevel@tonic-gate 472*7c478bd9Sstevel@tonic-gate #if defined(_KERNEL) 473*7c478bd9Sstevel@tonic-gate 474*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 475*7c478bd9Sstevel@tonic-gate } 476*7c478bd9Sstevel@tonic-gate #endif 477*7c478bd9Sstevel@tonic-gate 478*7c478bd9Sstevel@tonic-gate #include <sys/types.h> 479*7c478bd9Sstevel@tonic-gate #include <sys/model.h> 480*7c478bd9Sstevel@tonic-gate #include <sys/proc.h> 481*7c478bd9Sstevel@tonic-gate #include <sys/stream.h> 482*7c478bd9Sstevel@tonic-gate #include <sys/stropts.h> 483*7c478bd9Sstevel@tonic-gate #include <sys/file.h> 484*7c478bd9Sstevel@tonic-gate #include <sys/pathname.h> 485*7c478bd9Sstevel@tonic-gate #include <sys/vnode.h> 486*7c478bd9Sstevel@tonic-gate #include <sys/systm.h> 487*7c478bd9Sstevel@tonic-gate #include <netinet/in.h> 488*7c478bd9Sstevel@tonic-gate #include <c2/audit_door_infc.h> 489*7c478bd9Sstevel@tonic-gate #include <sys/crypto/ioctladmin.h> 490*7c478bd9Sstevel@tonic-gate 491*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 492*7c478bd9Sstevel@tonic-gate extern "C" { 493*7c478bd9Sstevel@tonic-gate #endif 494*7c478bd9Sstevel@tonic-gate 495*7c478bd9Sstevel@tonic-gate struct fcntla; 496*7c478bd9Sstevel@tonic-gate struct t_audit_data; 497*7c478bd9Sstevel@tonic-gate struct audit_path; 498*7c478bd9Sstevel@tonic-gate struct priv_set; 499*7c478bd9Sstevel@tonic-gate struct devplcysys; 500*7c478bd9Sstevel@tonic-gate 501*7c478bd9Sstevel@tonic-gate struct auditcalls { 502*7c478bd9Sstevel@tonic-gate long code; 503*7c478bd9Sstevel@tonic-gate long a1; 504*7c478bd9Sstevel@tonic-gate long a2; 505*7c478bd9Sstevel@tonic-gate long a3; 506*7c478bd9Sstevel@tonic-gate long a4; 507*7c478bd9Sstevel@tonic-gate long a5; 508*7c478bd9Sstevel@tonic-gate }; 509*7c478bd9Sstevel@tonic-gate 510*7c478bd9Sstevel@tonic-gate int audit(caddr_t, int); 511*7c478bd9Sstevel@tonic-gate int _audit(caddr_t, int); 512*7c478bd9Sstevel@tonic-gate int auditsys(struct auditcalls *, union rval *); /* fake stub */ 513*7c478bd9Sstevel@tonic-gate int _auditsys(struct auditcalls *, union rval *); /* real deal */ 514*7c478bd9Sstevel@tonic-gate void audit_cryptoadm(int, char *, crypto_mech_name_t *, 515*7c478bd9Sstevel@tonic-gate uint_t, uint_t, uint32_t, int); 516*7c478bd9Sstevel@tonic-gate void audit_init(void); 517*7c478bd9Sstevel@tonic-gate void audit_newproc(struct proc *); 518*7c478bd9Sstevel@tonic-gate void audit_pfree(struct proc *); 519*7c478bd9Sstevel@tonic-gate void audit_thread_create(kthread_id_t); 520*7c478bd9Sstevel@tonic-gate void audit_thread_free(kthread_id_t); 521*7c478bd9Sstevel@tonic-gate int audit_savepath(struct pathname *, struct vnode *, int, cred_t *); 522*7c478bd9Sstevel@tonic-gate void audit_addcomponent(struct pathname *); 523*7c478bd9Sstevel@tonic-gate void audit_anchorpath(struct pathname *, int); 524*7c478bd9Sstevel@tonic-gate void audit_symlink(struct pathname *, struct pathname *); 525*7c478bd9Sstevel@tonic-gate void audit_symlink_create(struct vnode *, char *, char *, int); 526*7c478bd9Sstevel@tonic-gate int file_is_public(struct vattr *); 527*7c478bd9Sstevel@tonic-gate void audit_attributes(struct vnode *); 528*7c478bd9Sstevel@tonic-gate void audit_falloc(struct file *); 529*7c478bd9Sstevel@tonic-gate void audit_unfalloc(struct file *); 530*7c478bd9Sstevel@tonic-gate void audit_exit(int, int); 531*7c478bd9Sstevel@tonic-gate void audit_core_start(int); 532*7c478bd9Sstevel@tonic-gate void audit_core_finish(int); 533*7c478bd9Sstevel@tonic-gate void audit_stropen(struct vnode *, dev_t *, int, struct cred *); 534*7c478bd9Sstevel@tonic-gate void audit_strclose(struct vnode *, int, struct cred *); 535*7c478bd9Sstevel@tonic-gate void audit_strioctl(struct vnode *, int, intptr_t, int, int, struct cred *, 536*7c478bd9Sstevel@tonic-gate int *); 537*7c478bd9Sstevel@tonic-gate void audit_strgetmsg(struct vnode *, struct strbuf *, struct strbuf *, 538*7c478bd9Sstevel@tonic-gate unsigned char *, int *, int); 539*7c478bd9Sstevel@tonic-gate void audit_strputmsg(struct vnode *, struct strbuf *, struct strbuf *, 540*7c478bd9Sstevel@tonic-gate unsigned char, int, int); 541*7c478bd9Sstevel@tonic-gate void audit_closef(struct file *); 542*7c478bd9Sstevel@tonic-gate int audit_getf(int); 543*7c478bd9Sstevel@tonic-gate void audit_setf(struct file *, int); 544*7c478bd9Sstevel@tonic-gate void audit_copen(int, struct file *, struct vnode *); 545*7c478bd9Sstevel@tonic-gate void audit_reboot(void); 546*7c478bd9Sstevel@tonic-gate void audit_vncreate_start(void); 547*7c478bd9Sstevel@tonic-gate void audit_setfsat_path(int argnum); 548*7c478bd9Sstevel@tonic-gate void audit_vncreate_finish(struct vnode *, int); 549*7c478bd9Sstevel@tonic-gate void audit_exec(const char *, const char *, ssize_t, ssize_t); 550*7c478bd9Sstevel@tonic-gate void audit_enterprom(int); 551*7c478bd9Sstevel@tonic-gate void audit_exitprom(int); 552*7c478bd9Sstevel@tonic-gate void audit_chdirec(struct vnode *, struct vnode **); 553*7c478bd9Sstevel@tonic-gate void audit_sock(int, struct queue *, struct msgb *, int); 554*7c478bd9Sstevel@tonic-gate void audit_free(void); 555*7c478bd9Sstevel@tonic-gate int audit_start(unsigned int, unsigned int, int, klwp_t *); 556*7c478bd9Sstevel@tonic-gate void audit_finish(unsigned int, unsigned int, int, union rval *); 557*7c478bd9Sstevel@tonic-gate int audit_async_start(label_t *, int, int); 558*7c478bd9Sstevel@tonic-gate void audit_async_finish(caddr_t *, int, int); 559*7c478bd9Sstevel@tonic-gate void audit_async_discard_backend(void *); 560*7c478bd9Sstevel@tonic-gate void audit_async_done(caddr_t *, int); 561*7c478bd9Sstevel@tonic-gate void audit_async_drop(caddr_t *, int); 562*7c478bd9Sstevel@tonic-gate 563*7c478bd9Sstevel@tonic-gate #ifndef AUK_CONTEXT_T 564*7c478bd9Sstevel@tonic-gate #define AUK_CONTEXT_T 565*7c478bd9Sstevel@tonic-gate typedef struct au_kcontext au_kcontext_t; 566*7c478bd9Sstevel@tonic-gate #endif 567*7c478bd9Sstevel@tonic-gate 568*7c478bd9Sstevel@tonic-gate int audit_success(au_kcontext_t *, struct t_audit_data *, int); 569*7c478bd9Sstevel@tonic-gate int auditme(au_kcontext_t *, struct t_audit_data *, au_state_t); 570*7c478bd9Sstevel@tonic-gate void audit_fixpath(struct audit_path *, int); 571*7c478bd9Sstevel@tonic-gate void audit_ipc(int, int, void *); 572*7c478bd9Sstevel@tonic-gate void audit_ipcget(int, void *); 573*7c478bd9Sstevel@tonic-gate void audit_lookupname(); 574*7c478bd9Sstevel@tonic-gate int audit_pathcomp(struct pathname *, vnode_t *, cred_t *); 575*7c478bd9Sstevel@tonic-gate void audit_fdsend(int, struct file *, int); 576*7c478bd9Sstevel@tonic-gate void audit_fdrecv(int, struct file *); 577*7c478bd9Sstevel@tonic-gate int audit_c2_revoke(struct fcntla *, rval_t *); 578*7c478bd9Sstevel@tonic-gate void audit_priv(int, const struct priv_set *, int); 579*7c478bd9Sstevel@tonic-gate void audit_setppriv(int, int, const struct priv_set *, const cred_t *); 580*7c478bd9Sstevel@tonic-gate void audit_devpolicy(int, const struct devplcysys *); 581*7c478bd9Sstevel@tonic-gate void audit_update_context(proc_t *, cred_t *); 582*7c478bd9Sstevel@tonic-gate 583*7c478bd9Sstevel@tonic-gate #endif 584*7c478bd9Sstevel@tonic-gate 585*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 586*7c478bd9Sstevel@tonic-gate } 587*7c478bd9Sstevel@tonic-gate #endif 588*7c478bd9Sstevel@tonic-gate 589*7c478bd9Sstevel@tonic-gate #endif /* _BSM_AUDIT_H */ 590