xref: /illumos-gate/usr/src/uts/common/c2/audit_event.c (revision 794f0adb)
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
545916cd2Sjpk  * Common Development and Distribution License (the "License").
645916cd2Sjpk  * 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  */
21*794f0adbSRoger A. Faulkner 
227c478bd9Sstevel@tonic-gate /*
234a0fa546SMarek Pospisil  * Copyright (c) 1992, 2010, Oracle and/or its affiliates. All rights reserved.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate /*
277c478bd9Sstevel@tonic-gate  * This file contains the audit event table used to control the production
287c478bd9Sstevel@tonic-gate  * of audit records for each system call.
297c478bd9Sstevel@tonic-gate  */
307c478bd9Sstevel@tonic-gate 
317c478bd9Sstevel@tonic-gate #include <sys/policy.h>
327c478bd9Sstevel@tonic-gate #include <sys/cred.h>
337c478bd9Sstevel@tonic-gate #include <sys/types.h>
347c478bd9Sstevel@tonic-gate #include <sys/systm.h>
357c478bd9Sstevel@tonic-gate #include <sys/systeminfo.h>	/* for sysinfo auditing */
367c478bd9Sstevel@tonic-gate #include <sys/utsname.h>	/* for sysinfo auditing */
377c478bd9Sstevel@tonic-gate #include <sys/proc.h>
387c478bd9Sstevel@tonic-gate #include <sys/vnode.h>
397c478bd9Sstevel@tonic-gate #include <sys/mman.h>		/* for mmap(2) auditing etc. */
407c478bd9Sstevel@tonic-gate #include <sys/fcntl.h>
417c478bd9Sstevel@tonic-gate #include <sys/modctl.h>		/* for modctl auditing */
427c478bd9Sstevel@tonic-gate #include <sys/vnode.h>
437c478bd9Sstevel@tonic-gate #include <sys/user.h>
447c478bd9Sstevel@tonic-gate #include <sys/types.h>
457c478bd9Sstevel@tonic-gate #include <sys/processor.h>
467c478bd9Sstevel@tonic-gate #include <sys/procset.h>
477c478bd9Sstevel@tonic-gate #include <sys/acl.h>
487c478bd9Sstevel@tonic-gate #include <sys/ipc.h>
497c478bd9Sstevel@tonic-gate #include <sys/door.h>
507c478bd9Sstevel@tonic-gate #include <sys/sem.h>
517c478bd9Sstevel@tonic-gate #include <sys/msg.h>
527c478bd9Sstevel@tonic-gate #include <sys/shm.h>
537c478bd9Sstevel@tonic-gate #include <sys/kmem.h>
547c478bd9Sstevel@tonic-gate #include <sys/file.h>		/* for accept */
557c478bd9Sstevel@tonic-gate #include <sys/utssys.h>		/* for fuser */
5645916cd2Sjpk #include <sys/tsol/label.h>
5761b9bf51Srica #include <sys/tsol/tndb.h>
5861b9bf51Srica #include <sys/tsol/tsyscall.h>
597c478bd9Sstevel@tonic-gate #include <c2/audit.h>
607c478bd9Sstevel@tonic-gate #include <c2/audit_kernel.h>
617c478bd9Sstevel@tonic-gate #include <c2/audit_kevents.h>
627c478bd9Sstevel@tonic-gate #include <c2/audit_record.h>
637c478bd9Sstevel@tonic-gate #include <sys/procset.h>
647c478bd9Sstevel@tonic-gate #include <nfs/mount.h>
657c478bd9Sstevel@tonic-gate #include <sys/param.h>
667c478bd9Sstevel@tonic-gate #include <sys/debug.h>
677c478bd9Sstevel@tonic-gate #include <sys/sysmacros.h>
687c478bd9Sstevel@tonic-gate #include <sys/stream.h>
697c478bd9Sstevel@tonic-gate #include <sys/strsubr.h>
707c478bd9Sstevel@tonic-gate #include <sys/stropts.h>
717c478bd9Sstevel@tonic-gate #include <sys/tihdr.h>
727c478bd9Sstevel@tonic-gate #include <sys/socket.h>
737c478bd9Sstevel@tonic-gate #include <sys/socketvar.h>
740f1702c5SYu Xiangning #include <sys/vfs_opreg.h>
750f1702c5SYu Xiangning #include <fs/sockfs/sockcommon.h>
767c478bd9Sstevel@tonic-gate #include <netinet/in.h>
777c478bd9Sstevel@tonic-gate #include <sys/ddi.h>
78df2381bfSpraks #include <sys/port_impl.h>
79df2381bfSpraks 
807c478bd9Sstevel@tonic-gate 
817c478bd9Sstevel@tonic-gate char	_depends_on[] = "fs/sockfs";
827c478bd9Sstevel@tonic-gate 
838fd04b83SRoger A. Faulkner static au_event_t	aui_fchownat(au_event_t);
84*794f0adbSRoger A. Faulkner static au_event_t	aui_fchmodat(au_event_t);
857c478bd9Sstevel@tonic-gate static au_event_t	aui_open(au_event_t);
868fd04b83SRoger A. Faulkner static au_event_t	aui_openat(au_event_t);
878fd04b83SRoger A. Faulkner static au_event_t	aui_unlinkat(au_event_t);
888fd04b83SRoger A. Faulkner static au_event_t	aui_fstatat(au_event_t);
897c478bd9Sstevel@tonic-gate static au_event_t	aui_msgsys(au_event_t);
907c478bd9Sstevel@tonic-gate static au_event_t	aui_shmsys(au_event_t);
917c478bd9Sstevel@tonic-gate static au_event_t	aui_semsys(au_event_t);
927c478bd9Sstevel@tonic-gate static au_event_t	aui_utssys(au_event_t);
937c478bd9Sstevel@tonic-gate static au_event_t	aui_fcntl(au_event_t);
947c478bd9Sstevel@tonic-gate static au_event_t	aui_execve(au_event_t);
957c478bd9Sstevel@tonic-gate static au_event_t	aui_memcntl(au_event_t);
967c478bd9Sstevel@tonic-gate static au_event_t	aui_sysinfo(au_event_t);
97df2381bfSpraks static au_event_t	aui_portfs(au_event_t);
987c478bd9Sstevel@tonic-gate static au_event_t	aui_auditsys(au_event_t);
997c478bd9Sstevel@tonic-gate static au_event_t	aui_modctl(au_event_t);
1007c478bd9Sstevel@tonic-gate static au_event_t	aui_acl(au_event_t);
1017c478bd9Sstevel@tonic-gate static au_event_t	aui_doorfs(au_event_t);
1027c478bd9Sstevel@tonic-gate static au_event_t	aui_privsys(au_event_t);
103657b1f3dSraf static au_event_t	aui_forksys(au_event_t);
10461b9bf51Srica static au_event_t	aui_labelsys(au_event_t);
1054be8c573SJan Friedel static au_event_t	aui_setpgrp(au_event_t);
1067c478bd9Sstevel@tonic-gate 
107cb49a9fdSMarek Pospisil static void	aus_exit(struct t_audit_data *);
1087c478bd9Sstevel@tonic-gate static void	aus_open(struct t_audit_data *);
1098fd04b83SRoger A. Faulkner static void	aus_openat(struct t_audit_data *);
1107c478bd9Sstevel@tonic-gate static void	aus_acl(struct t_audit_data *);
1117c478bd9Sstevel@tonic-gate static void	aus_acct(struct t_audit_data *);
1127c478bd9Sstevel@tonic-gate static void	aus_chown(struct t_audit_data *);
1137c478bd9Sstevel@tonic-gate static void	aus_fchown(struct t_audit_data *);
1147c478bd9Sstevel@tonic-gate static void	aus_lchown(struct t_audit_data *);
1158fd04b83SRoger A. Faulkner static void	aus_fchownat(struct t_audit_data *);
1167c478bd9Sstevel@tonic-gate static void	aus_chmod(struct t_audit_data *);
1177c478bd9Sstevel@tonic-gate static void	aus_facl(struct t_audit_data *);
1187c478bd9Sstevel@tonic-gate static void	aus_fchmod(struct t_audit_data *);
119*794f0adbSRoger A. Faulkner static void	aus_fchmodat(struct t_audit_data *);
1207c478bd9Sstevel@tonic-gate static void	aus_fcntl(struct t_audit_data *);
1217c478bd9Sstevel@tonic-gate static void	aus_mkdir(struct t_audit_data *);
122*794f0adbSRoger A. Faulkner static void	aus_mkdirat(struct t_audit_data *);
1237c478bd9Sstevel@tonic-gate static void	aus_mknod(struct t_audit_data *);
124*794f0adbSRoger A. Faulkner static void	aus_mknodat(struct t_audit_data *);
1257c478bd9Sstevel@tonic-gate static void	aus_mount(struct t_audit_data *);
1267c478bd9Sstevel@tonic-gate static void	aus_umount2(struct t_audit_data *);
1277c478bd9Sstevel@tonic-gate static void	aus_msgsys(struct t_audit_data *);
1287c478bd9Sstevel@tonic-gate static void	aus_semsys(struct t_audit_data *);
1297c478bd9Sstevel@tonic-gate static void	aus_close(struct t_audit_data *);
1307c478bd9Sstevel@tonic-gate static void	aus_fstatfs(struct t_audit_data *);
1317c478bd9Sstevel@tonic-gate static void	aus_setgid(struct t_audit_data *);
1324be8c573SJan Friedel static void	aus_setpgrp(struct t_audit_data *);
1337c478bd9Sstevel@tonic-gate static void	aus_setuid(struct t_audit_data *);
1347c478bd9Sstevel@tonic-gate static void	aus_shmsys(struct t_audit_data *);
1357c478bd9Sstevel@tonic-gate static void	aus_doorfs(struct t_audit_data *);
1367c478bd9Sstevel@tonic-gate static void	aus_ioctl(struct t_audit_data *);
1377c478bd9Sstevel@tonic-gate static void	aus_memcntl(struct t_audit_data *);
1387c478bd9Sstevel@tonic-gate static void	aus_mmap(struct t_audit_data *);
1397c478bd9Sstevel@tonic-gate static void	aus_munmap(struct t_audit_data *);
1407c478bd9Sstevel@tonic-gate static void	aus_priocntlsys(struct t_audit_data *);
1417c478bd9Sstevel@tonic-gate static void	aus_setegid(struct t_audit_data *);
1427c478bd9Sstevel@tonic-gate static void	aus_setgroups(struct t_audit_data *);
1437c478bd9Sstevel@tonic-gate static void	aus_seteuid(struct t_audit_data *);
1447c478bd9Sstevel@tonic-gate static void	aus_putmsg(struct t_audit_data *);
1457c478bd9Sstevel@tonic-gate static void	aus_putpmsg(struct t_audit_data *);
1467c478bd9Sstevel@tonic-gate static void	aus_getmsg(struct t_audit_data *);
1477c478bd9Sstevel@tonic-gate static void	aus_getpmsg(struct t_audit_data *);
1487c478bd9Sstevel@tonic-gate static void	aus_auditsys(struct t_audit_data *);
1497c478bd9Sstevel@tonic-gate static void	aus_sysinfo(struct t_audit_data *);
1507c478bd9Sstevel@tonic-gate static void	aus_modctl(struct t_audit_data *);
1517c478bd9Sstevel@tonic-gate static void	aus_kill(struct t_audit_data *);
1527c478bd9Sstevel@tonic-gate static void	aus_setregid(struct t_audit_data *);
1537c478bd9Sstevel@tonic-gate static void	aus_setreuid(struct t_audit_data *);
15461b9bf51Srica static void	aus_labelsys(struct t_audit_data *);
1557c478bd9Sstevel@tonic-gate 
1567c478bd9Sstevel@tonic-gate static void	auf_mknod(struct t_audit_data *, int, rval_t *);
157*794f0adbSRoger A. Faulkner static void	auf_mknodat(struct t_audit_data *, int, rval_t *);
1587c478bd9Sstevel@tonic-gate static void	auf_msgsys(struct t_audit_data *, int, rval_t *);
1597c478bd9Sstevel@tonic-gate static void	auf_semsys(struct t_audit_data *, int, rval_t *);
1607c478bd9Sstevel@tonic-gate static void	auf_shmsys(struct t_audit_data *, int, rval_t *);
1617c478bd9Sstevel@tonic-gate static void	auf_read(struct t_audit_data *, int, rval_t *);
1627c478bd9Sstevel@tonic-gate static void	auf_write(struct t_audit_data *, int, rval_t *);
1637c478bd9Sstevel@tonic-gate 
1647c478bd9Sstevel@tonic-gate static void	aus_sigqueue(struct t_audit_data *);
1657c478bd9Sstevel@tonic-gate static void	aus_p_online(struct t_audit_data *);
1667c478bd9Sstevel@tonic-gate static void	aus_processor_bind(struct t_audit_data *);
1677c478bd9Sstevel@tonic-gate static void	aus_inst_sync(struct t_audit_data *);
1689acbbeafSnn static void	aus_brandsys(struct t_audit_data *);
1697c478bd9Sstevel@tonic-gate 
1707c478bd9Sstevel@tonic-gate static void	auf_accept(struct t_audit_data *, int, rval_t *);
1717c478bd9Sstevel@tonic-gate 
1727c478bd9Sstevel@tonic-gate static void	auf_bind(struct t_audit_data *, int, rval_t *);
1737c478bd9Sstevel@tonic-gate static void	auf_connect(struct t_audit_data *, int, rval_t *);
1747c478bd9Sstevel@tonic-gate static void	aus_shutdown(struct t_audit_data *);
1757c478bd9Sstevel@tonic-gate static void	auf_setsockopt(struct t_audit_data *, int, rval_t *);
1767c478bd9Sstevel@tonic-gate static void	aus_sockconfig(struct t_audit_data *);
1777c478bd9Sstevel@tonic-gate static void	auf_recv(struct t_audit_data *, int, rval_t *);
1787c478bd9Sstevel@tonic-gate static void	auf_recvmsg(struct t_audit_data *, int, rval_t *);
1797c478bd9Sstevel@tonic-gate static void	auf_send(struct t_audit_data *, int, rval_t *);
1807c478bd9Sstevel@tonic-gate static void	auf_sendmsg(struct t_audit_data *, int, rval_t *);
1817c478bd9Sstevel@tonic-gate static void	auf_recvfrom(struct t_audit_data *, int, rval_t *);
1827c478bd9Sstevel@tonic-gate static void	auf_sendto(struct t_audit_data *, int, rval_t *);
1837c478bd9Sstevel@tonic-gate static void	aus_socket(struct t_audit_data *);
1847c478bd9Sstevel@tonic-gate /*
1857c478bd9Sstevel@tonic-gate  * This table contains mapping information for converting system call numbers
1867c478bd9Sstevel@tonic-gate  * to audit event IDs. In several cases it is necessary to map a single system
1877c478bd9Sstevel@tonic-gate  * call to several events.
1887c478bd9Sstevel@tonic-gate  */
1897c478bd9Sstevel@tonic-gate 
190f9d0e028Sgww #define	aui_null	NULL	/* NULL initialize function */
191f9d0e028Sgww #define	aus_null	NULL	/* NULL start function */
192f9d0e028Sgww #define	auf_null	NULL	/* NULL finish function */
193f9d0e028Sgww 
1947c478bd9Sstevel@tonic-gate struct audit_s2e audit_s2e[] =
1957c478bd9Sstevel@tonic-gate {
1967c478bd9Sstevel@tonic-gate /*
1977c478bd9Sstevel@tonic-gate  * ----------	---------- 	----------	----------
1987c478bd9Sstevel@tonic-gate  * INITIAL	AUDIT		START		SYSTEM
1997c478bd9Sstevel@tonic-gate  * PROCESSING	EVENT		PROCESSING	CALL
2007c478bd9Sstevel@tonic-gate  * ----------	----------	----------	-----------
2017c478bd9Sstevel@tonic-gate  *		FINISH		EVENT
2027c478bd9Sstevel@tonic-gate  *		PROCESSING	CONTROL
2037c478bd9Sstevel@tonic-gate  * ----------------------------------------------------------
2047c478bd9Sstevel@tonic-gate  */
2057c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 0 unused (indirect) */
2067c478bd9Sstevel@tonic-gate 		auf_null,	0,
207cb49a9fdSMarek Pospisil aui_null,	AUE_EXIT,	aus_exit,	/* 1 exit */
2087c478bd9Sstevel@tonic-gate 		auf_null,	S2E_NPT,
2098fd04b83SRoger A. Faulkner aui_null,	AUE_NULL,	aus_null,	/* 2 (loadable) was forkall */
2107c478bd9Sstevel@tonic-gate 		auf_null,	0,
2117c478bd9Sstevel@tonic-gate aui_null,	AUE_READ,	aus_null,	/* 3 read */
2127c478bd9Sstevel@tonic-gate 		auf_read,	S2E_PUB,
2137c478bd9Sstevel@tonic-gate aui_null,	AUE_WRITE,	aus_null,	/* 4 write */
2147c478bd9Sstevel@tonic-gate 		auf_write,	0,
2157c478bd9Sstevel@tonic-gate aui_open,	AUE_OPEN,	aus_open,	/* 5 open */
2167c478bd9Sstevel@tonic-gate 		auf_null,	S2E_SP,
2177c478bd9Sstevel@tonic-gate aui_null,	AUE_CLOSE,	aus_close,	/* 6 close */
2187c478bd9Sstevel@tonic-gate 		auf_null,	0,
219*794f0adbSRoger A. Faulkner aui_null,	AUE_LINK,	aus_null,	/* 7 linkat */
2208fd04b83SRoger A. Faulkner 		auf_null,	0,
2218fd04b83SRoger A. Faulkner aui_null,	AUE_NULL,	aus_null,	/* 8 (loadable) was creat */
2227c478bd9Sstevel@tonic-gate 		auf_null,	0,
2237c478bd9Sstevel@tonic-gate aui_null,	AUE_LINK,	aus_null,	/* 9 link */
2247c478bd9Sstevel@tonic-gate 		auf_null,	0,
2257c478bd9Sstevel@tonic-gate aui_null,	AUE_UNLINK,	aus_null,	/* 10 unlink */
2267c478bd9Sstevel@tonic-gate 		auf_null,	0,
227*794f0adbSRoger A. Faulkner aui_null,	AUE_SYMLINK,	aus_null,	/* 11 symlinkat */
2288fd04b83SRoger A. Faulkner 		auf_null,	0,
2297c478bd9Sstevel@tonic-gate aui_null,	AUE_CHDIR,	aus_null,	/* 12 chdir */
2307c478bd9Sstevel@tonic-gate 		auf_null,	S2E_SP,
2317c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 13 time */
2327c478bd9Sstevel@tonic-gate 		auf_null,	0,
2337c478bd9Sstevel@tonic-gate aui_null,	AUE_MKNOD,	aus_mknod,	/* 14 mknod */
234*794f0adbSRoger A. Faulkner 		auf_mknod,	S2E_MLD,
2357c478bd9Sstevel@tonic-gate aui_null,	AUE_CHMOD,	aus_chmod,	/* 15 chmod */
2367c478bd9Sstevel@tonic-gate 		auf_null,	0,
2377c478bd9Sstevel@tonic-gate aui_null,	AUE_CHOWN,	aus_chown,	/* 16 chown */
2387c478bd9Sstevel@tonic-gate 		auf_null,	0,
2397c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 17 brk */
2407c478bd9Sstevel@tonic-gate 		auf_null,	0,
2417c478bd9Sstevel@tonic-gate aui_null,	AUE_STAT,	aus_null,	/* 18 stat */
2427c478bd9Sstevel@tonic-gate 		auf_null,	S2E_PUB,
2437c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 19 lseek */
2447c478bd9Sstevel@tonic-gate 		auf_null,	0,
2457c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 20 getpid */
2467c478bd9Sstevel@tonic-gate 		auf_null,	0,
2477c478bd9Sstevel@tonic-gate aui_null,	AUE_MOUNT,	aus_mount,	/* 21 mount */
2487c478bd9Sstevel@tonic-gate 		auf_null,	S2E_MLD,
249*794f0adbSRoger A. Faulkner aui_null,	AUE_READLINK,	aus_null,	/* 22 readlinkat */
250*794f0adbSRoger A. Faulkner 		auf_null,	S2E_PUB,
2517c478bd9Sstevel@tonic-gate aui_null,	AUE_SETUID,	aus_setuid,	/* 23 setuid */
2527c478bd9Sstevel@tonic-gate 		auf_null,	0,
2537c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 24 getuid */
2547c478bd9Sstevel@tonic-gate 		auf_null,	0,
2557c478bd9Sstevel@tonic-gate aui_null,	AUE_STIME,	aus_null,	/* 25 stime */
2567c478bd9Sstevel@tonic-gate 		auf_null,	0,
2578fd04b83SRoger A. Faulkner aui_null,	AUE_NULL,	aus_null,	/* 26 pcsample */
2587c478bd9Sstevel@tonic-gate 		auf_null,	0,
2597c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 27 alarm */
2607c478bd9Sstevel@tonic-gate 		auf_null,	0,
2617c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 28 fstat */
2627c478bd9Sstevel@tonic-gate 		auf_null,	0,
2637c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 29 pause */
2647c478bd9Sstevel@tonic-gate 		auf_null,	0,
2658fd04b83SRoger A. Faulkner aui_null,	AUE_NULL,	aus_null,	/* 30 (loadable) was utime */
2667c478bd9Sstevel@tonic-gate 		auf_null,	0,
2677c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 31 stty (TIOCSETP-audit?) */
2687c478bd9Sstevel@tonic-gate 		auf_null,	0,
2697c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 32 gtty */
2707c478bd9Sstevel@tonic-gate 		auf_null,	0,
2717c478bd9Sstevel@tonic-gate aui_null,	AUE_ACCESS,	aus_null,	/* 33 access */
2727c478bd9Sstevel@tonic-gate 		auf_null,	S2E_PUB,
2737c478bd9Sstevel@tonic-gate aui_null,	AUE_NICE,	aus_null,	/* 34 nice */
2747c478bd9Sstevel@tonic-gate 		auf_null,	0,
2757c478bd9Sstevel@tonic-gate aui_null,	AUE_STATFS,	aus_null,	/* 35 statfs */
2767c478bd9Sstevel@tonic-gate 		auf_null,	S2E_PUB,
2777c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 36 sync */
2787c478bd9Sstevel@tonic-gate 		auf_null,	0,
2797c478bd9Sstevel@tonic-gate aui_null,	AUE_KILL,	aus_kill,	/* 37 kill */
2807c478bd9Sstevel@tonic-gate 		auf_null,	0,
2817c478bd9Sstevel@tonic-gate aui_null,	AUE_FSTATFS,	aus_fstatfs,	/* 38 fstatfs */
2827c478bd9Sstevel@tonic-gate 		auf_null,	S2E_PUB,
2834be8c573SJan Friedel aui_setpgrp,	AUE_SETPGRP,	aus_setpgrp,	/* 39 setpgrp */
2847c478bd9Sstevel@tonic-gate 		auf_null,	0,
2859acbbeafSnn aui_null,	AUE_NULL,	aus_null,	/* 40 uucopystr */
2867c478bd9Sstevel@tonic-gate 		auf_null,	0,
2878fd04b83SRoger A. Faulkner aui_null,	AUE_NULL,	aus_null,	/* 41 (loadable) was dup */
2887c478bd9Sstevel@tonic-gate 		auf_null,	0,
2898fd04b83SRoger A. Faulkner aui_null,	AUE_PIPE,	aus_null,	/* 42 (loadable) pipe */
2907c478bd9Sstevel@tonic-gate 		auf_null,	0,
2917c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 43 times */
2927c478bd9Sstevel@tonic-gate 		auf_null,	0,
2937c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 44 profil */
2947c478bd9Sstevel@tonic-gate 		auf_null,	0,
2958fd04b83SRoger A. Faulkner aui_null,	AUE_ACCESS,	aus_null,	/* 45 faccessat */
296c4d3e299SBrent Paulson 		auf_null,	S2E_PUB,
2977c478bd9Sstevel@tonic-gate aui_null,	AUE_SETGID,	aus_setgid,	/* 46 setgid */
2987c478bd9Sstevel@tonic-gate 		auf_null,	0,
2997c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 47 getgid */
3007c478bd9Sstevel@tonic-gate 		auf_null,	0,
301*794f0adbSRoger A. Faulkner aui_null,	AUE_MKNOD,	aus_mknodat,	/* 48 mknodat */
302*794f0adbSRoger A. Faulkner 		auf_mknodat,	S2E_MLD,
3038fd04b83SRoger A. Faulkner aui_msgsys,	AUE_MSGSYS,	aus_msgsys,	/* 49 (loadable) msgsys */
3047c478bd9Sstevel@tonic-gate 		auf_msgsys,	0,
3057c478bd9Sstevel@tonic-gate #if defined(__x86)
3067c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 50 sysi86 */
3077c478bd9Sstevel@tonic-gate 		auf_null,	0,
3087c478bd9Sstevel@tonic-gate #else
3097c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 50 (loadable) was sys3b */
3107c478bd9Sstevel@tonic-gate 		auf_null,	0,
3117c478bd9Sstevel@tonic-gate #endif /* __x86 */
3128fd04b83SRoger A. Faulkner aui_null,	AUE_ACCT,	aus_acct,	/* 51 (loadable) sysacct */
3137c478bd9Sstevel@tonic-gate 		auf_null,	0,
3148fd04b83SRoger A. Faulkner aui_shmsys,	AUE_SHMSYS,	aus_shmsys,	/* 52 (loadable) shmsys */
3157c478bd9Sstevel@tonic-gate 		auf_shmsys,	0,
3168fd04b83SRoger A. Faulkner aui_semsys,	AUE_SEMSYS,	aus_semsys,	/* 53 (loadable) semsys */
3177c478bd9Sstevel@tonic-gate 		auf_semsys,	0,
3187c478bd9Sstevel@tonic-gate aui_null,	AUE_IOCTL,	aus_ioctl,	/* 54 ioctl */
3197c478bd9Sstevel@tonic-gate 		auf_null,	0,
3207c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 55 uadmin */
3217c478bd9Sstevel@tonic-gate 		auf_null,	0,
3228fd04b83SRoger A. Faulkner aui_fchownat,	AUE_NULL,	aus_fchownat,	/* 56 fchownat */
323c4d3e299SBrent Paulson 		auf_null,	0,
3247c478bd9Sstevel@tonic-gate aui_utssys,	AUE_FUSERS,	aus_null,	/* 57 utssys */
3257c478bd9Sstevel@tonic-gate 		auf_null,	0,
3267c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 58 fsync */
3277c478bd9Sstevel@tonic-gate 		auf_null,	0,
3287c478bd9Sstevel@tonic-gate aui_execve,	AUE_EXECVE,	aus_null,	/* 59 exece */
3297c478bd9Sstevel@tonic-gate 		auf_null,	S2E_MLD,
3307c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 60 umask */
3317c478bd9Sstevel@tonic-gate 		auf_null,	0,
3327c478bd9Sstevel@tonic-gate aui_null,	AUE_CHROOT,	aus_null,	/* 61 chroot */
3337c478bd9Sstevel@tonic-gate 		auf_null,	S2E_SP,
3347c478bd9Sstevel@tonic-gate aui_fcntl,	AUE_FCNTL,	aus_fcntl,	/* 62 fcntl */
3357c478bd9Sstevel@tonic-gate 		auf_null,	0,
3367c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 63 ulimit */
3377c478bd9Sstevel@tonic-gate 		auf_null,	0,
3388fd04b83SRoger A. Faulkner aui_null,	AUE_RENAME,	aus_null,	/* 64 renameat */
339c4d3e299SBrent Paulson 		auf_null,	0,
3408fd04b83SRoger A. Faulkner aui_unlinkat,	AUE_NULL,	aus_null,	/* 65 unlinkat */
341c4d3e299SBrent Paulson 		auf_null,	0,
3428fd04b83SRoger A. Faulkner aui_fstatat,	AUE_NULL,	aus_null,	/* 66 fstatat */
343c4d3e299SBrent Paulson 		auf_null,	S2E_PUB,
3448fd04b83SRoger A. Faulkner aui_fstatat,	AUE_NULL,	aus_null,	/* 67 fstatat64 */
345c4d3e299SBrent Paulson 		auf_null,	S2E_PUB,
3468fd04b83SRoger A. Faulkner aui_openat,	AUE_OPEN,	aus_openat,	/* 68 openat */
347c4d3e299SBrent Paulson 		auf_null,	S2E_SP,
3488fd04b83SRoger A. Faulkner aui_openat,	AUE_OPEN,	aus_openat,	/* 69 openat64 */
349c4d3e299SBrent Paulson 		auf_null,	S2E_SP,
3508fd04b83SRoger A. Faulkner aui_null,	AUE_NULL,	aus_null,	/* 70 tasksys */
3517c478bd9Sstevel@tonic-gate 		auf_null,	0,
3528fd04b83SRoger A. Faulkner aui_null,	AUE_NULL,	aus_null,	/* 71 (loadable) acctctl */
3537c478bd9Sstevel@tonic-gate 		auf_null,	0,
3548fd04b83SRoger A. Faulkner aui_null,	AUE_NULL,	aus_null,	/* 72 (loadable) exacct */
3557c478bd9Sstevel@tonic-gate 		auf_null,	0,
3568fd04b83SRoger A. Faulkner aui_null,	AUE_NULL,	aus_null,	/* 73 getpagesizes */
3577c478bd9Sstevel@tonic-gate 		auf_null,	0,
3588fd04b83SRoger A. Faulkner aui_null,	AUE_NULL,	aus_null,	/* 74 rctlsys */
3597c478bd9Sstevel@tonic-gate 		auf_null,	0,
360f48205beScasper aui_null,	AUE_NULL,	aus_null,	/* 75 sidsys */
3617c478bd9Sstevel@tonic-gate 		auf_null,	0,
3628fd04b83SRoger A. Faulkner aui_null,	AUE_NULL,	aus_null,	/* 76 (loadable) was fsat */
3637c478bd9Sstevel@tonic-gate 		auf_null,	0,
3648fd04b83SRoger A. Faulkner aui_null,	AUE_NULL,	aus_null,	/* 77 syslwp_park */
3657c478bd9Sstevel@tonic-gate 		auf_null,	0,
3668fd04b83SRoger A. Faulkner aui_null,	AUE_NULL,	aus_null,	/* 78 sendfilev */
3677c478bd9Sstevel@tonic-gate 		auf_null,	0,
3687c478bd9Sstevel@tonic-gate aui_null,	AUE_RMDIR,	aus_null,	/* 79 rmdir */
3697c478bd9Sstevel@tonic-gate 		auf_null,	0,
3707c478bd9Sstevel@tonic-gate aui_null,	AUE_MKDIR,	aus_mkdir,	/* 80 mkdir */
3717c478bd9Sstevel@tonic-gate 		auf_null,	0,
3727c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 81 getdents */
3737c478bd9Sstevel@tonic-gate 		auf_null,	0,
3747c478bd9Sstevel@tonic-gate aui_privsys,	AUE_NULL,	aus_null,	/* 82 privsys */
3757c478bd9Sstevel@tonic-gate 		auf_null,	0,
3768fd04b83SRoger A. Faulkner aui_null,	AUE_NULL,	aus_null,	/* 83 ucredsys */
3777c478bd9Sstevel@tonic-gate 		auf_null,	0,
3787c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 84 sysfs */
3797c478bd9Sstevel@tonic-gate 		auf_null,	0,
3807c478bd9Sstevel@tonic-gate aui_null,	AUE_GETMSG,	aus_getmsg,	/* 85 getmsg */
3817c478bd9Sstevel@tonic-gate 		auf_null,	0,
3827c478bd9Sstevel@tonic-gate aui_null,	AUE_PUTMSG,	aus_putmsg,	/* 86 putmsg */
3837c478bd9Sstevel@tonic-gate 		auf_null,	0,
3848fd04b83SRoger A. Faulkner aui_null,	AUE_NULL,	aus_null,	/* 87 (loadable) was poll */
3857c478bd9Sstevel@tonic-gate 		auf_null,	0,
3867c478bd9Sstevel@tonic-gate aui_null,	AUE_LSTAT,	aus_null,	/* 88 lstat */
3877c478bd9Sstevel@tonic-gate 		auf_null,	S2E_PUB,
3887c478bd9Sstevel@tonic-gate aui_null,	AUE_SYMLINK,	aus_null,	/* 89 symlink */
3897c478bd9Sstevel@tonic-gate 		auf_null,	0,
3907c478bd9Sstevel@tonic-gate aui_null,	AUE_READLINK,	aus_null,	/* 90 readlink */
3917c478bd9Sstevel@tonic-gate 		auf_null,	S2E_PUB,
3927c478bd9Sstevel@tonic-gate aui_null,	AUE_SETGROUPS,	aus_setgroups,	/* 91 setgroups */
3937c478bd9Sstevel@tonic-gate 		auf_null,	0,
3947c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 92 getgroups */
3957c478bd9Sstevel@tonic-gate 		auf_null,	0,
3967c478bd9Sstevel@tonic-gate aui_null,	AUE_FCHMOD,	aus_fchmod,	/* 93 fchmod */
3977c478bd9Sstevel@tonic-gate 		auf_null,	0,
3987c478bd9Sstevel@tonic-gate aui_null,	AUE_FCHOWN,	aus_fchown,	/* 94 fchown */
3997c478bd9Sstevel@tonic-gate 		auf_null,	0,
4007c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 95 sigprocmask */
4017c478bd9Sstevel@tonic-gate 		auf_null,	0,
4027c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 96 sigsuspend */
4037c478bd9Sstevel@tonic-gate 		auf_null,	0,
4047c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 97 sigaltstack */
4057c478bd9Sstevel@tonic-gate 		auf_null,	0,
4067c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 98 sigaction */
4077c478bd9Sstevel@tonic-gate 		auf_null,	0,
4087c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 99 sigpending */
4097c478bd9Sstevel@tonic-gate 		auf_null,	0,
4107c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 100 setcontext */
4117c478bd9Sstevel@tonic-gate 		auf_null,	0,
412*794f0adbSRoger A. Faulkner aui_fchmodat,	AUE_NULL,	aus_fchmodat,	/* 101 fchmodat */
4137c478bd9Sstevel@tonic-gate 		auf_null,	0,
414*794f0adbSRoger A. Faulkner aui_null,	AUE_MKDIR,	aus_mkdirat,	/* 102 mkdirat */
4157c478bd9Sstevel@tonic-gate 		auf_null,	0,
4167c478bd9Sstevel@tonic-gate aui_null,	AUE_STATVFS,	aus_null,	/* 103 statvfs */
4177c478bd9Sstevel@tonic-gate 		auf_null,	S2E_PUB,
4187c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 104 fstatvfs */
4197c478bd9Sstevel@tonic-gate 		auf_null,	0,
4208fd04b83SRoger A. Faulkner aui_null,	AUE_NULL,	aus_null,	/* 105 getloadavg */
4217c478bd9Sstevel@tonic-gate 		auf_null,	0,
4227c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 106 nfssys */
4237c478bd9Sstevel@tonic-gate 		auf_null,	0,
4248fd04b83SRoger A. Faulkner aui_null,	AUE_NULL,	aus_null,	/* 107 waitsys */
4257c478bd9Sstevel@tonic-gate 		auf_null,	0,
4268fd04b83SRoger A. Faulkner aui_null,	AUE_NULL,	aus_null,	/* 108 sigsendsys */
4277c478bd9Sstevel@tonic-gate 		auf_null,	0,
4287c478bd9Sstevel@tonic-gate #if defined(__x86)
4297c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 109 hrtsys */
4307c478bd9Sstevel@tonic-gate 		auf_null,	0,
4317c478bd9Sstevel@tonic-gate #else
4327c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 109 (loadable) */
4337c478bd9Sstevel@tonic-gate 		auf_null,	0,
4347c478bd9Sstevel@tonic-gate #endif /* __x86 */
4358fd04b83SRoger A. Faulkner aui_null,	AUE_UTIMES,	aus_null,	/* 110 utimesys */
436c4d3e299SBrent Paulson 		auf_null,	0,
4378fd04b83SRoger A. Faulkner aui_null,	AUE_NULL,	aus_null,	/* 111 sigresend */
4387c478bd9Sstevel@tonic-gate 		auf_null,	0,
4398fd04b83SRoger A. Faulkner aui_null,	AUE_PRIOCNTLSYS, aus_priocntlsys, /* 112 priocntlsys */
4407c478bd9Sstevel@tonic-gate 		auf_null,	0,
4417c478bd9Sstevel@tonic-gate aui_null,	AUE_PATHCONF,	aus_null,	/* 113 pathconf */
4427c478bd9Sstevel@tonic-gate 		auf_null,	S2E_PUB,
4437c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 114 mincore */
4447c478bd9Sstevel@tonic-gate 		auf_null,	0,
4457c478bd9Sstevel@tonic-gate aui_null,	AUE_MMAP,	aus_mmap,	/* 115 mmap */
4467c478bd9Sstevel@tonic-gate 		auf_null,	0,
4477c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 116 mprotect */
4487c478bd9Sstevel@tonic-gate 		auf_null,	0,
4497c478bd9Sstevel@tonic-gate aui_null,	AUE_MUNMAP,	aus_munmap,	/* 117 munmap */
4507c478bd9Sstevel@tonic-gate 		auf_null,	0,
4517c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 118 fpathconf */
4527c478bd9Sstevel@tonic-gate 		auf_null,	0,
4537c478bd9Sstevel@tonic-gate aui_null,	AUE_VFORK,	aus_null,	/* 119 vfork */
4547c478bd9Sstevel@tonic-gate 		auf_null,	0,
4557c478bd9Sstevel@tonic-gate aui_null,	AUE_FCHDIR,	aus_null,	/* 120 fchdir */
4567c478bd9Sstevel@tonic-gate 		auf_null,	0,
4577c478bd9Sstevel@tonic-gate aui_null,	AUE_READ,	aus_null,	/* 121 readv */
4587c478bd9Sstevel@tonic-gate 		auf_read,	S2E_PUB,
4597c478bd9Sstevel@tonic-gate aui_null,	AUE_WRITE,	aus_null,	/* 122 writev */
4607c478bd9Sstevel@tonic-gate 		auf_write,	0,
4618fd04b83SRoger A. Faulkner aui_null,	AUE_NULL,	aus_null,	/* 123 (loadable) was xstat */
4627c478bd9Sstevel@tonic-gate 		auf_null,	0,
4638fd04b83SRoger A. Faulkner aui_null,	AUE_NULL,	aus_null,	/* 124 (loadable) was lxstat */
4648fd04b83SRoger A. Faulkner 		auf_null,	0,
4658fd04b83SRoger A. Faulkner aui_null,	AUE_NULL,	aus_null,	/* 125 (loadable) was fxstat */
4668fd04b83SRoger A. Faulkner 		auf_null,	0,
4678fd04b83SRoger A. Faulkner aui_null,	AUE_NULL,	aus_null,	/* 126 (loadable) was xmknod */
4688fd04b83SRoger A. Faulkner 		auf_null,	0,
4698fd04b83SRoger A. Faulkner aui_null,	AUE_NULL,	aus_null,	/* 127 mmapobj */
4707c478bd9Sstevel@tonic-gate 		auf_null,	0,
4717c478bd9Sstevel@tonic-gate aui_null,	AUE_SETRLIMIT,	aus_null,	/* 128 setrlimit */
4727c478bd9Sstevel@tonic-gate 		auf_null,	0,
4737c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 129 getrlimit */
4747c478bd9Sstevel@tonic-gate 		auf_null,	0,
4757c478bd9Sstevel@tonic-gate aui_null,	AUE_LCHOWN,	aus_lchown,	/* 130 lchown */
4767c478bd9Sstevel@tonic-gate 		auf_null,	0,
4777c478bd9Sstevel@tonic-gate aui_memcntl,	AUE_MEMCNTL,	aus_memcntl,	/* 131 memcntl */
4787c478bd9Sstevel@tonic-gate 		auf_null,	0,
4797c478bd9Sstevel@tonic-gate aui_null,	AUE_GETPMSG,	aus_getpmsg,	/* 132 getpmsg */
4807c478bd9Sstevel@tonic-gate 		auf_null,	0,
4817c478bd9Sstevel@tonic-gate aui_null,	AUE_PUTPMSG,	aus_putpmsg,	/* 133 putpmsg */
4827c478bd9Sstevel@tonic-gate 		auf_null,	0,
4837c478bd9Sstevel@tonic-gate aui_null,	AUE_RENAME,	aus_null,	/* 134 rename */
4847c478bd9Sstevel@tonic-gate 		auf_null,	0,
4857c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 135 uname */
4867c478bd9Sstevel@tonic-gate 		auf_null,	0,
4877c478bd9Sstevel@tonic-gate aui_null,	AUE_SETEGID,	aus_setegid,	/* 136 setegid */
4887c478bd9Sstevel@tonic-gate 		auf_null,	0,
4897c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 137 sysconfig */
4907c478bd9Sstevel@tonic-gate 		auf_null,	0,
4917c478bd9Sstevel@tonic-gate aui_null,	AUE_ADJTIME,	aus_null,	/* 138 adjtime */
4927c478bd9Sstevel@tonic-gate 		auf_null,	0,
4937c478bd9Sstevel@tonic-gate aui_sysinfo,	AUE_SYSINFO,	aus_sysinfo,	/* 139 systeminfo */
4947c478bd9Sstevel@tonic-gate 		auf_null,	0,
4958fd04b83SRoger A. Faulkner aui_null,	AUE_NULL,	aus_null,	/* 140 (loadable) sharefs */
4967c478bd9Sstevel@tonic-gate 		auf_null,	0,
4977c478bd9Sstevel@tonic-gate aui_null,	AUE_SETEUID,	aus_seteuid,	/* 141 seteuid */
4987c478bd9Sstevel@tonic-gate 		auf_null,	0,
499657b1f3dSraf aui_forksys,	AUE_NULL,	aus_null,	/* 142 forksys */
5007c478bd9Sstevel@tonic-gate 		auf_null,	0,
5018fd04b83SRoger A. Faulkner aui_null,	AUE_NULL,	aus_null,	/* 143 (loadable) was fork1 */
5027c478bd9Sstevel@tonic-gate 		auf_null,	0,
5037c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 144 sigwait */
5047c478bd9Sstevel@tonic-gate 		auf_null,	0,
5057c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 145 lwp_info */
5067c478bd9Sstevel@tonic-gate 		auf_null,	0,
5077c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 146 yield */
5087c478bd9Sstevel@tonic-gate 		auf_null,	0,
5098fd04b83SRoger A. Faulkner aui_null,	AUE_NULL,	aus_null,	/* 147 (loadable) */
5108fd04b83SRoger A. Faulkner 						/*	was lwp_sema_wait */
5117c478bd9Sstevel@tonic-gate 		auf_null,	0,
5127c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 148 lwp_sema_post */
5137c478bd9Sstevel@tonic-gate 		auf_null,	0,
5147c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 149 lwp_sema_trywait */
5157c478bd9Sstevel@tonic-gate 		auf_null,	0,
5168fd04b83SRoger A. Faulkner aui_null,	AUE_NULL,	aus_null,	/* 150 lwp_detach */
5177c478bd9Sstevel@tonic-gate 		auf_null,	0,
5188fd04b83SRoger A. Faulkner aui_null,	AUE_NULL,	aus_null,	/* 151 corectl */
5197c478bd9Sstevel@tonic-gate 		auf_null,	0,
5207c478bd9Sstevel@tonic-gate aui_modctl,	AUE_MODCTL,	aus_modctl,	/* 152 modctl */
5217c478bd9Sstevel@tonic-gate 		auf_null,	0,
5227c478bd9Sstevel@tonic-gate aui_null,	AUE_FCHROOT,	aus_null,	/* 153 fchroot */
5237c478bd9Sstevel@tonic-gate 		auf_null,	0,
5248fd04b83SRoger A. Faulkner aui_null,	AUE_NULL,	aus_null,	/* 154 (loadable) was utimes */
5257c478bd9Sstevel@tonic-gate 		auf_null,	0,
5267c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 155 vhangup */
5277c478bd9Sstevel@tonic-gate 		auf_null,	0,
5287c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 156 gettimeofday */
5297c478bd9Sstevel@tonic-gate 		auf_null,	0,
5307c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 157 getitimer */
5317c478bd9Sstevel@tonic-gate 		auf_null,	0,
5327c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 158 setitimer */
5337c478bd9Sstevel@tonic-gate 		auf_null,	0,
5347c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 159 lwp_create */
5357c478bd9Sstevel@tonic-gate 		auf_null,	0,
5367c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 160 lwp_exit */
5377c478bd9Sstevel@tonic-gate 		auf_null,	0,
5387c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 161 lwp_suspend */
5397c478bd9Sstevel@tonic-gate 		auf_null,	0,
5407c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 162 lwp_continue */
5417c478bd9Sstevel@tonic-gate 		auf_null,	0,
5427c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 163 lwp_kill */
5437c478bd9Sstevel@tonic-gate 		auf_null,	0,
5447c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 164 lwp_self */
5457c478bd9Sstevel@tonic-gate 		auf_null,	0,
5468fd04b83SRoger A. Faulkner aui_null,	AUE_NULL,	aus_null,	/* 165 lwp_sigmask */
5477c478bd9Sstevel@tonic-gate 		auf_null,	0,
5488fd04b83SRoger A. Faulkner aui_null,	AUE_NULL,	aus_null,	/* 166 lwp_private */
5497c478bd9Sstevel@tonic-gate 		auf_null,	0,
5507c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 167 lwp_wait */
5517c478bd9Sstevel@tonic-gate 		auf_null,	0,
552883492d5Sraf aui_null,	AUE_NULL,	aus_null,	/* 168 lwp_mutex_wakeup  */
5537c478bd9Sstevel@tonic-gate 		auf_null,	0,
5548fd04b83SRoger A. Faulkner aui_null,	AUE_NULL,	aus_null,	/* 169 (loadable) */
5558fd04b83SRoger A. Faulkner 						/*	was lwp_mutex_lock */
5567c478bd9Sstevel@tonic-gate 		auf_null,	0,
5577c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 170 lwp_cond_wait */
5587c478bd9Sstevel@tonic-gate 		auf_null,	0,
5597c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 171 lwp_cond_signal */
5607c478bd9Sstevel@tonic-gate 		auf_null,	0,
5617c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 172 lwp_cond_broadcast */
5627c478bd9Sstevel@tonic-gate 		auf_null,	0,
5637c478bd9Sstevel@tonic-gate aui_null,	AUE_READ,	aus_null,	/* 173 pread */
5647c478bd9Sstevel@tonic-gate 		auf_read,	S2E_PUB,
5657c478bd9Sstevel@tonic-gate aui_null,	AUE_WRITE,	aus_null,	/* 174 pwrite */
5667c478bd9Sstevel@tonic-gate 		auf_write,	0,
5677c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 175 llseek */
5687c478bd9Sstevel@tonic-gate 		auf_null,	0,
5698fd04b83SRoger A. Faulkner aui_null,	AUE_INST_SYNC,	aus_inst_sync,  /* 176 (loadable) inst_sync */
5707c478bd9Sstevel@tonic-gate 		auf_null,	0,
5719acbbeafSnn aui_null,	AUE_BRANDSYS,	aus_brandsys,	/* 177 brandsys */
5727c478bd9Sstevel@tonic-gate 		auf_null,	0,
5738fd04b83SRoger A. Faulkner aui_null,	AUE_NULL,	aus_null,	/* 178 (loadable) kaio */
5747c478bd9Sstevel@tonic-gate 		auf_null,	0,
5758fd04b83SRoger A. Faulkner aui_null,	AUE_NULL,	aus_null,	/* 179 (loadable) cpc */
5767c478bd9Sstevel@tonic-gate 		auf_null,	0,
5778fd04b83SRoger A. Faulkner aui_null,	AUE_NULL,	aus_null,	/* 180 lgrpsys */
5787c478bd9Sstevel@tonic-gate 		auf_null,	0,
5798fd04b83SRoger A. Faulkner aui_null,	AUE_NULL,	aus_null,	/* 181 rusagesys */
5807c478bd9Sstevel@tonic-gate 		auf_null,	0,
581df2381bfSpraks aui_portfs,	AUE_PORTFS,	aus_null,	/* 182 (loadable) portfs */
5827e309bc2SJan Friedel 		auf_null,	S2E_MLD,
5838fd04b83SRoger A. Faulkner aui_null,	AUE_NULL,	aus_null,	/* 183 pollsys */
5847c478bd9Sstevel@tonic-gate 		auf_null,	0,
58561b9bf51Srica aui_labelsys,	AUE_NULL,	aus_labelsys,	/* 184 labelsys */
5867c478bd9Sstevel@tonic-gate 		auf_null,	0,
5877c478bd9Sstevel@tonic-gate aui_acl,	AUE_ACLSET,	aus_acl,	/* 185 acl */
5887c478bd9Sstevel@tonic-gate 		auf_null,	0,
5897c478bd9Sstevel@tonic-gate aui_auditsys,	AUE_AUDITSYS,	aus_auditsys,	/* 186 auditsys  */
5907c478bd9Sstevel@tonic-gate 		auf_null,	0,
5918fd04b83SRoger A. Faulkner aui_null,	AUE_PROCESSOR_BIND, aus_processor_bind, /* 187 processor_bind */
5928fd04b83SRoger A. Faulkner 		auf_null,	0,
5937c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 188 processor_info */
5947c478bd9Sstevel@tonic-gate 		auf_null,	0,
5957c478bd9Sstevel@tonic-gate aui_null,	AUE_P_ONLINE,	aus_p_online,	/* 189 p_online */
5967c478bd9Sstevel@tonic-gate 		auf_null,	0,
5977c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_sigqueue,	/* 190 sigqueue */
5987c478bd9Sstevel@tonic-gate 		auf_null,	0,
5997c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 191 clock_gettime */
6007c478bd9Sstevel@tonic-gate 		auf_null,	0,
6017c478bd9Sstevel@tonic-gate aui_null,	AUE_CLOCK_SETTIME,	aus_null,	/* 192 clock_settime */
6027c478bd9Sstevel@tonic-gate 		auf_null,	0,
6037c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 193 clock_getres */
6047c478bd9Sstevel@tonic-gate 		auf_null,	0,
6057c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 194 timer_create */
6067c478bd9Sstevel@tonic-gate 		auf_null,	0,
6077c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 195 timer_delete */
6087c478bd9Sstevel@tonic-gate 		auf_null,	0,
6097c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 196 timer_settime */
6107c478bd9Sstevel@tonic-gate 		auf_null,	0,
6117c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 197 timer_gettime */
6127c478bd9Sstevel@tonic-gate 		auf_null,	0,
6137c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 198 timer_getoverrun */
6147c478bd9Sstevel@tonic-gate 		auf_null,	0,
6157c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 199 nanosleep */
6167c478bd9Sstevel@tonic-gate 		auf_null,	0,
6177c478bd9Sstevel@tonic-gate aui_acl,	AUE_FACLSET,	aus_facl,	/* 200 facl */
6187c478bd9Sstevel@tonic-gate 		auf_null,	0,
6197c478bd9Sstevel@tonic-gate aui_doorfs,	AUE_DOORFS,	aus_doorfs,	/* 201 (loadable) doorfs */
6207c478bd9Sstevel@tonic-gate 		auf_null,	0,
6217c478bd9Sstevel@tonic-gate aui_null,	AUE_SETREUID,	aus_setreuid,	/* 202 setreuid */
6227c478bd9Sstevel@tonic-gate 		auf_null,	0,
6237c478bd9Sstevel@tonic-gate aui_null,	AUE_SETREGID,	aus_setregid,	/* 203 setregid */
6247c478bd9Sstevel@tonic-gate 		auf_null,	0,
6257c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 204 install_utrap */
6267c478bd9Sstevel@tonic-gate 		auf_null,	0,
6277c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 205 signotify */
6287c478bd9Sstevel@tonic-gate 		auf_null,	0,
6297c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 206 schedctl */
6307c478bd9Sstevel@tonic-gate 		auf_null,	0,
6317c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 207 (loadable) pset */
6327c478bd9Sstevel@tonic-gate 		auf_null,	0,
6338fd04b83SRoger A. Faulkner aui_null,	AUE_NULL,	aus_null,	/* 208 sparc_utrap_install */
6347c478bd9Sstevel@tonic-gate 		auf_null,	0,
6357c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 209 resolvepath */
6367c478bd9Sstevel@tonic-gate 		auf_null,	0,
6377c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 210 lwp_mutex_timedlock */
6387c478bd9Sstevel@tonic-gate 		auf_null,	0,
6397c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 211 lwp_sema_timedwait */
6407c478bd9Sstevel@tonic-gate 		auf_null,	0,
6417c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 212 lwp_rwlock_sys */
6427c478bd9Sstevel@tonic-gate 		auf_null,	0,
6438fd04b83SRoger A. Faulkner aui_null,	AUE_NULL,	aus_null,	/* 213 getdents64 */
6447c478bd9Sstevel@tonic-gate 		auf_null,	0,
6457c478bd9Sstevel@tonic-gate aui_null,	AUE_MMAP,	aus_mmap,	/* 214 mmap64 */
6467c478bd9Sstevel@tonic-gate 		auf_null,	0,
6477c478bd9Sstevel@tonic-gate aui_null,	AUE_STAT,	aus_null,	/* 215 stat64 */
6487c478bd9Sstevel@tonic-gate 		auf_null,	S2E_PUB,
6497c478bd9Sstevel@tonic-gate aui_null,	AUE_LSTAT,	aus_null,	/* 216 lstat64 */
6507c478bd9Sstevel@tonic-gate 		auf_null,	S2E_PUB,
6517c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 217 fstat64 */
6527c478bd9Sstevel@tonic-gate 		auf_null,	0,
6537c478bd9Sstevel@tonic-gate aui_null,	AUE_STATVFS,	aus_null,	/* 218 statvfs64 */
6547c478bd9Sstevel@tonic-gate 		auf_null,	S2E_PUB,
6557c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 219 fstatvfs64 */
6567c478bd9Sstevel@tonic-gate 		auf_null,	0,
6577c478bd9Sstevel@tonic-gate aui_null,	AUE_SETRLIMIT,	aus_null,	/* 220 setrlimit64 */
6587c478bd9Sstevel@tonic-gate 		auf_null,	0,
6597c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 221 getrlimit64 */
6607c478bd9Sstevel@tonic-gate 		auf_null,	0,
6617c478bd9Sstevel@tonic-gate aui_null,	AUE_READ,	aus_null,	/* 222 pread64  */
6627c478bd9Sstevel@tonic-gate 		auf_read,	S2E_PUB,
6637c478bd9Sstevel@tonic-gate aui_null,	AUE_WRITE,	aus_null,	/* 223 pwrite64 */
6647c478bd9Sstevel@tonic-gate 		auf_write,	0,
6658fd04b83SRoger A. Faulkner aui_null,	AUE_NULL,	aus_null,	/* 224 (loadable) was creat64 */
6668fd04b83SRoger A. Faulkner 		auf_null,	0,
6677c478bd9Sstevel@tonic-gate aui_open,	AUE_OPEN,	aus_open,	/* 225 open64 */
6687c478bd9Sstevel@tonic-gate 		auf_null,	S2E_SP,
6697c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 226 (loadable) rpcsys */
6707c478bd9Sstevel@tonic-gate 		auf_null,	0,
6718fd04b83SRoger A. Faulkner aui_null,	AUE_NULL,	aus_null,	/* 227 zone */
6727c478bd9Sstevel@tonic-gate 		auf_null,	0,
6738fd04b83SRoger A. Faulkner aui_null,	AUE_NULL,	aus_null,	/* 228 (loadable) autofssys */
6747c478bd9Sstevel@tonic-gate 		auf_null,	0,
6758fd04b83SRoger A. Faulkner aui_null,	AUE_NULL,	aus_null,	/* 229 getcwd */
6767c478bd9Sstevel@tonic-gate 		auf_null,	0,
6777c478bd9Sstevel@tonic-gate aui_null,	AUE_SOCKET,	aus_socket,	/* 230 so_socket */
6787c478bd9Sstevel@tonic-gate 		auf_null,	0,
6797c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 231 so_socketpair */
6807c478bd9Sstevel@tonic-gate 		auf_null,	0,
6817c478bd9Sstevel@tonic-gate aui_null,	AUE_BIND,	aus_null,	/* 232 bind */
6827c478bd9Sstevel@tonic-gate 		auf_bind,	0,
6837c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 233 listen */
6847c478bd9Sstevel@tonic-gate 		auf_null,	0,
6857c478bd9Sstevel@tonic-gate aui_null,	AUE_ACCEPT,	aus_null,	/* 234 accept */
6867c478bd9Sstevel@tonic-gate 		auf_accept,	0,
6877c478bd9Sstevel@tonic-gate aui_null,	AUE_CONNECT,	aus_null,	/* 235 connect */
6887c478bd9Sstevel@tonic-gate 		auf_connect,	0,
6897c478bd9Sstevel@tonic-gate aui_null,	AUE_SHUTDOWN,	aus_shutdown,	/* 236 shutdown */
6907c478bd9Sstevel@tonic-gate 		auf_null,	0,
6917c478bd9Sstevel@tonic-gate aui_null,	AUE_READ,	aus_null,	/* 237 recv */
6927c478bd9Sstevel@tonic-gate 		auf_recv,	0,
6937c478bd9Sstevel@tonic-gate aui_null,	AUE_RECVFROM,	aus_null,	/* 238 recvfrom */
6947c478bd9Sstevel@tonic-gate 		auf_recvfrom,	0,
6957c478bd9Sstevel@tonic-gate aui_null,	AUE_RECVMSG,	aus_null,	/* 239 recvmsg */
6967c478bd9Sstevel@tonic-gate 		auf_recvmsg,	0,
6977c478bd9Sstevel@tonic-gate aui_null,	AUE_WRITE,	aus_null,	/* 240 send */
6987c478bd9Sstevel@tonic-gate 		auf_send,	0,
6997c478bd9Sstevel@tonic-gate aui_null,	AUE_SENDMSG,	aus_null,	/* 241 sendmsg */
7007c478bd9Sstevel@tonic-gate 		auf_sendmsg,	0,
7017c478bd9Sstevel@tonic-gate aui_null,	AUE_SENDTO,	aus_null,	/* 242 sendto */
7027c478bd9Sstevel@tonic-gate 		auf_sendto,	0,
7037c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 243 getpeername */
7047c478bd9Sstevel@tonic-gate 		auf_null,	0,
7057c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 244 getsockname */
7067c478bd9Sstevel@tonic-gate 		auf_null,	0,
7077c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 245 getsockopt */
7087c478bd9Sstevel@tonic-gate 		auf_null,	0,
7097c478bd9Sstevel@tonic-gate aui_null,	AUE_SETSOCKOPT,	aus_null,	/* 246 setsockopt */
7107c478bd9Sstevel@tonic-gate 		auf_setsockopt,	0,
7117c478bd9Sstevel@tonic-gate aui_null,	AUE_SOCKCONFIG,	aus_sockconfig,	/* 247 sockconfig */
7127c478bd9Sstevel@tonic-gate 		auf_null,	0,
7137c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 248 ntp_gettime */
7147c478bd9Sstevel@tonic-gate 		auf_null,	0,
7158fd04b83SRoger A. Faulkner aui_null,	AUE_NTP_ADJTIME, aus_null,	/* 249 ntp_adjtime */
7167c478bd9Sstevel@tonic-gate 		auf_null,	0,
7177c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 250 lwp_mutex_unlock */
7187c478bd9Sstevel@tonic-gate 		auf_null,	0,
7197c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 251 lwp_mutex_trylock */
7207c478bd9Sstevel@tonic-gate 		auf_null,	0,
721883492d5Sraf aui_null,	AUE_NULL,	aus_null,	/* 252 lwp_mutex_register */
7227c478bd9Sstevel@tonic-gate 		auf_null,	0,
7237c478bd9Sstevel@tonic-gate aui_null,	AUE_NULL,	aus_null,	/* 253 cladm */
7247c478bd9Sstevel@tonic-gate 		auf_null,	0,
7259acbbeafSnn aui_null,	AUE_NULL,	aus_null,	/* 254 uucopy */
7267c478bd9Sstevel@tonic-gate 		auf_null,	0,
7277c478bd9Sstevel@tonic-gate aui_null,	AUE_UMOUNT2,	aus_umount2,	/* 255 umount2 */
7287c478bd9Sstevel@tonic-gate 		auf_null,	0
7297c478bd9Sstevel@tonic-gate };
7307c478bd9Sstevel@tonic-gate 
7317c478bd9Sstevel@tonic-gate uint_t num_syscall = sizeof (audit_s2e) / sizeof (struct audit_s2e);
7327c478bd9Sstevel@tonic-gate 
7337c478bd9Sstevel@tonic-gate 
734cb49a9fdSMarek Pospisil /* exit start function */
735cb49a9fdSMarek Pospisil /*ARGSUSED*/
736cb49a9fdSMarek Pospisil static void
737cb49a9fdSMarek Pospisil aus_exit(struct t_audit_data *tad)
738cb49a9fdSMarek Pospisil {
739cb49a9fdSMarek Pospisil 	uint32_t rval;
740cb49a9fdSMarek Pospisil 	struct a {
741cb49a9fdSMarek Pospisil 		long rval;
742cb49a9fdSMarek Pospisil 	} *uap = (struct a *)ttolwp(curthread)->lwp_ap;
743cb49a9fdSMarek Pospisil 
744cb49a9fdSMarek Pospisil 	rval = (uint32_t)uap->rval;
745cb49a9fdSMarek Pospisil 	au_uwrite(au_to_arg32(1, "exit status", rval));
746cb49a9fdSMarek Pospisil }
747cb49a9fdSMarek Pospisil 
7487c478bd9Sstevel@tonic-gate /* acct start function */
7497c478bd9Sstevel@tonic-gate /*ARGSUSED*/
7507c478bd9Sstevel@tonic-gate static void
7517c478bd9Sstevel@tonic-gate aus_acct(struct t_audit_data *tad)
7527c478bd9Sstevel@tonic-gate {
7537c478bd9Sstevel@tonic-gate 	klwp_t *clwp = ttolwp(curthread);
7547c478bd9Sstevel@tonic-gate 	uintptr_t fname;
7557c478bd9Sstevel@tonic-gate 
7567c478bd9Sstevel@tonic-gate 	struct a {
7577c478bd9Sstevel@tonic-gate 		long	fname;		/* char * */
7587c478bd9Sstevel@tonic-gate 	} *uap = (struct a *)clwp->lwp_ap;
7597c478bd9Sstevel@tonic-gate 
7607c478bd9Sstevel@tonic-gate 	fname = (uintptr_t)uap->fname;
7617c478bd9Sstevel@tonic-gate 
7627c478bd9Sstevel@tonic-gate 	if (fname == 0)
7637c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32(1, "accounting off", (uint32_t)0));
7647c478bd9Sstevel@tonic-gate }
7657c478bd9Sstevel@tonic-gate 
7667c478bd9Sstevel@tonic-gate /* chown start function */
7677c478bd9Sstevel@tonic-gate /*ARGSUSED*/
7687c478bd9Sstevel@tonic-gate static void
7697c478bd9Sstevel@tonic-gate aus_chown(struct t_audit_data *tad)
7707c478bd9Sstevel@tonic-gate {
7717c478bd9Sstevel@tonic-gate 	klwp_t *clwp = ttolwp(curthread);
7727c478bd9Sstevel@tonic-gate 	uint32_t uid, gid;
7737c478bd9Sstevel@tonic-gate 
7747c478bd9Sstevel@tonic-gate 	struct a {
7757c478bd9Sstevel@tonic-gate 		long	fname;		/* char * */
7767c478bd9Sstevel@tonic-gate 		long	uid;
7777c478bd9Sstevel@tonic-gate 		long	gid;
7787c478bd9Sstevel@tonic-gate 	} *uap = (struct a *)clwp->lwp_ap;
7797c478bd9Sstevel@tonic-gate 
7807c478bd9Sstevel@tonic-gate 	uid = (uint32_t)uap->uid;
7817c478bd9Sstevel@tonic-gate 	gid = (uint32_t)uap->gid;
7827c478bd9Sstevel@tonic-gate 
7837c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_arg32(2, "new file uid", uid));
7847c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_arg32(3, "new file gid", gid));
7857c478bd9Sstevel@tonic-gate }
7867c478bd9Sstevel@tonic-gate 
7877c478bd9Sstevel@tonic-gate /* fchown start function */
7887c478bd9Sstevel@tonic-gate /*ARGSUSED*/
7897c478bd9Sstevel@tonic-gate static void
7907c478bd9Sstevel@tonic-gate aus_fchown(struct t_audit_data *tad)
7917c478bd9Sstevel@tonic-gate {
7927c478bd9Sstevel@tonic-gate 	klwp_t *clwp = ttolwp(curthread);
7937c478bd9Sstevel@tonic-gate 	uint32_t uid, gid, fd;
7947c478bd9Sstevel@tonic-gate 	struct file  *fp;
7957c478bd9Sstevel@tonic-gate 	struct vnode *vp;
7967c478bd9Sstevel@tonic-gate 	struct f_audit_data *fad;
7977c478bd9Sstevel@tonic-gate 
7987c478bd9Sstevel@tonic-gate 	struct a {
7997c478bd9Sstevel@tonic-gate 		long fd;
8007c478bd9Sstevel@tonic-gate 		long uid;
8017c478bd9Sstevel@tonic-gate 		long gid;
8027c478bd9Sstevel@tonic-gate 	} *uap = (struct a *)clwp->lwp_ap;
8037c478bd9Sstevel@tonic-gate 
8047c478bd9Sstevel@tonic-gate 	fd  = (uint32_t)uap->fd;
8057c478bd9Sstevel@tonic-gate 	uid = (uint32_t)uap->uid;
8067c478bd9Sstevel@tonic-gate 	gid = (uint32_t)uap->gid;
8077c478bd9Sstevel@tonic-gate 
8087c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_arg32(2, "new file uid", uid));
8097c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_arg32(3, "new file gid", gid));
8107c478bd9Sstevel@tonic-gate 
8117c478bd9Sstevel@tonic-gate 		/*
8127c478bd9Sstevel@tonic-gate 		 * convert file pointer to file descriptor
8137c478bd9Sstevel@tonic-gate 		 *   Note: fd ref count incremented here.
8147c478bd9Sstevel@tonic-gate 		 */
8157c478bd9Sstevel@tonic-gate 	if ((fp = getf(fd)) == NULL)
8167c478bd9Sstevel@tonic-gate 		return;
8177c478bd9Sstevel@tonic-gate 
8187c478bd9Sstevel@tonic-gate 	/* get path from file struct here */
8197c478bd9Sstevel@tonic-gate 	fad = F2A(fp);
8207c478bd9Sstevel@tonic-gate 	if (fad->fad_aupath != NULL) {
8217c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_path(fad->fad_aupath));
8227c478bd9Sstevel@tonic-gate 	} else {
8237c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32(1, "no path: fd", fd));
8247c478bd9Sstevel@tonic-gate 	}
8257c478bd9Sstevel@tonic-gate 
8267c478bd9Sstevel@tonic-gate 	vp = fp->f_vnode;
8277c478bd9Sstevel@tonic-gate 	audit_attributes(vp);
8287c478bd9Sstevel@tonic-gate 
8297c478bd9Sstevel@tonic-gate 	/* decrement file descriptor reference count */
8307c478bd9Sstevel@tonic-gate 	releasef(fd);
8317c478bd9Sstevel@tonic-gate }
8327c478bd9Sstevel@tonic-gate 
8337c478bd9Sstevel@tonic-gate /*ARGSUSED*/
8347c478bd9Sstevel@tonic-gate static void
8357c478bd9Sstevel@tonic-gate aus_lchown(struct t_audit_data *tad)
8367c478bd9Sstevel@tonic-gate {
8377c478bd9Sstevel@tonic-gate 	klwp_t *clwp = ttolwp(curthread);
8387c478bd9Sstevel@tonic-gate 	uint32_t uid, gid;
8397c478bd9Sstevel@tonic-gate 
8407c478bd9Sstevel@tonic-gate 
8417c478bd9Sstevel@tonic-gate 	struct a {
8427c478bd9Sstevel@tonic-gate 		long	fname;		/* char	* */
8437c478bd9Sstevel@tonic-gate 		long	uid;
8447c478bd9Sstevel@tonic-gate 		long	gid;
8457c478bd9Sstevel@tonic-gate 	} *uap = (struct a *)clwp->lwp_ap;
8467c478bd9Sstevel@tonic-gate 
8477c478bd9Sstevel@tonic-gate 	uid = (uint32_t)uap->uid;
8487c478bd9Sstevel@tonic-gate 	gid = (uint32_t)uap->gid;
8497c478bd9Sstevel@tonic-gate 
8507c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_arg32(2, "new file uid", uid));
8517c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_arg32(3, "new file gid", gid));
8527c478bd9Sstevel@tonic-gate }
8537c478bd9Sstevel@tonic-gate 
8548fd04b83SRoger A. Faulkner static au_event_t
8558fd04b83SRoger A. Faulkner aui_fchownat(au_event_t e)
8568fd04b83SRoger A. Faulkner {
8578fd04b83SRoger A. Faulkner 	klwp_t *clwp = ttolwp(curthread);
8588fd04b83SRoger A. Faulkner 
8598fd04b83SRoger A. Faulkner 	struct a {
8608fd04b83SRoger A. Faulkner 		long	fd;
8618fd04b83SRoger A. Faulkner 		long	fname;		/* char * */
8628fd04b83SRoger A. Faulkner 		long	uid;
8638fd04b83SRoger A. Faulkner 		long	gid;
8648fd04b83SRoger A. Faulkner 		long	flags;
8658fd04b83SRoger A. Faulkner 	} *uap = (struct a *)clwp->lwp_ap;
8668fd04b83SRoger A. Faulkner 
8678fd04b83SRoger A. Faulkner 	if (uap->fname == NULL)
8688fd04b83SRoger A. Faulkner 		e = AUE_FCHOWN;
8698fd04b83SRoger A. Faulkner 	else if (uap->flags & AT_SYMLINK_NOFOLLOW)
8708fd04b83SRoger A. Faulkner 		e = AUE_LCHOWN;
8718fd04b83SRoger A. Faulkner 	else
8728fd04b83SRoger A. Faulkner 		e = AUE_CHOWN;
8738fd04b83SRoger A. Faulkner 
8748fd04b83SRoger A. Faulkner 	return (e);
8758fd04b83SRoger A. Faulkner }
8768fd04b83SRoger A. Faulkner 
8778fd04b83SRoger A. Faulkner /*ARGSUSED*/
8788fd04b83SRoger A. Faulkner static void
8798fd04b83SRoger A. Faulkner aus_fchownat(struct t_audit_data *tad)
8808fd04b83SRoger A. Faulkner {
8818fd04b83SRoger A. Faulkner 	klwp_t *clwp = ttolwp(curthread);
8828fd04b83SRoger A. Faulkner 	uint32_t uid, gid;
8838fd04b83SRoger A. Faulkner 
8848fd04b83SRoger A. Faulkner 	struct a {
8858fd04b83SRoger A. Faulkner 		long	fd;
8868fd04b83SRoger A. Faulkner 		long	fname;		/* char * */
8878fd04b83SRoger A. Faulkner 		long	uid;
8888fd04b83SRoger A. Faulkner 		long	gid;
8898fd04b83SRoger A. Faulkner 		long	flags;
8908fd04b83SRoger A. Faulkner 	} *uap = (struct a *)clwp->lwp_ap;
8918fd04b83SRoger A. Faulkner 
8928fd04b83SRoger A. Faulkner 	uid = (uint32_t)uap->uid;
8938fd04b83SRoger A. Faulkner 	gid = (uint32_t)uap->gid;
8948fd04b83SRoger A. Faulkner 
8958fd04b83SRoger A. Faulkner 	au_uwrite(au_to_arg32(3, "new file uid", uid));
8968fd04b83SRoger A. Faulkner 	au_uwrite(au_to_arg32(4, "new file gid", gid));
8978fd04b83SRoger A. Faulkner }
8988fd04b83SRoger A. Faulkner 
8997c478bd9Sstevel@tonic-gate /*ARGSUSED*/
9007c478bd9Sstevel@tonic-gate static void
9017c478bd9Sstevel@tonic-gate aus_chmod(struct t_audit_data *tad)
9027c478bd9Sstevel@tonic-gate {
9037c478bd9Sstevel@tonic-gate 	klwp_t *clwp = ttolwp(curthread);
9047c478bd9Sstevel@tonic-gate 	uint32_t fmode;
9057c478bd9Sstevel@tonic-gate 
9067c478bd9Sstevel@tonic-gate 	struct a {
9077c478bd9Sstevel@tonic-gate 		long	fname;		/* char	* */
9087c478bd9Sstevel@tonic-gate 		long	fmode;
9097c478bd9Sstevel@tonic-gate 	} *uap = (struct a *)clwp->lwp_ap;
9107c478bd9Sstevel@tonic-gate 
9117c478bd9Sstevel@tonic-gate 	fmode = (uint32_t)uap->fmode;
9127c478bd9Sstevel@tonic-gate 
9137c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_arg32(2, "new file mode", fmode&07777));
9147c478bd9Sstevel@tonic-gate }
9157c478bd9Sstevel@tonic-gate 
9167c478bd9Sstevel@tonic-gate /*ARGSUSED*/
9177c478bd9Sstevel@tonic-gate static void
9187c478bd9Sstevel@tonic-gate aus_fchmod(struct t_audit_data *tad)
9197c478bd9Sstevel@tonic-gate {
9207c478bd9Sstevel@tonic-gate 	klwp_t *clwp = ttolwp(curthread);
9217c478bd9Sstevel@tonic-gate 	uint32_t fmode, fd;
9227c478bd9Sstevel@tonic-gate 	struct file  *fp;
9237c478bd9Sstevel@tonic-gate 	struct vnode *vp;
9247c478bd9Sstevel@tonic-gate 	struct f_audit_data *fad;
9257c478bd9Sstevel@tonic-gate 
9267c478bd9Sstevel@tonic-gate 	struct a {
9277c478bd9Sstevel@tonic-gate 		long	fd;
9287c478bd9Sstevel@tonic-gate 		long	fmode;
9297c478bd9Sstevel@tonic-gate 	} *uap = (struct a *)clwp->lwp_ap;
9307c478bd9Sstevel@tonic-gate 
9317c478bd9Sstevel@tonic-gate 	fd = (uint32_t)uap->fd;
9327c478bd9Sstevel@tonic-gate 	fmode = (uint32_t)uap->fmode;
9337c478bd9Sstevel@tonic-gate 
9347c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_arg32(2, "new file mode", fmode&07777));
9357c478bd9Sstevel@tonic-gate 
936*794f0adbSRoger A. Faulkner 	/*
937*794f0adbSRoger A. Faulkner 	 * convert file pointer to file descriptor
938*794f0adbSRoger A. Faulkner 	 *   Note: fd ref count incremented here.
939*794f0adbSRoger A. Faulkner 	 */
9407c478bd9Sstevel@tonic-gate 	if ((fp = getf(fd)) == NULL)
9417c478bd9Sstevel@tonic-gate 		return;
9427c478bd9Sstevel@tonic-gate 
943*794f0adbSRoger A. Faulkner 	/* get path from file struct here */
944*794f0adbSRoger A. Faulkner 	fad = F2A(fp);
945*794f0adbSRoger A. Faulkner 	if (fad->fad_aupath != NULL) {
946*794f0adbSRoger A. Faulkner 		au_uwrite(au_to_path(fad->fad_aupath));
947*794f0adbSRoger A. Faulkner 	} else {
948*794f0adbSRoger A. Faulkner 		au_uwrite(au_to_arg32(1, "no path: fd", fd));
949*794f0adbSRoger A. Faulkner 	}
950*794f0adbSRoger A. Faulkner 
951*794f0adbSRoger A. Faulkner 	vp = fp->f_vnode;
952*794f0adbSRoger A. Faulkner 	audit_attributes(vp);
953*794f0adbSRoger A. Faulkner 
954*794f0adbSRoger A. Faulkner 	/* decrement file descriptor reference count */
955*794f0adbSRoger A. Faulkner 	releasef(fd);
956*794f0adbSRoger A. Faulkner }
957*794f0adbSRoger A. Faulkner 
958*794f0adbSRoger A. Faulkner static au_event_t
959*794f0adbSRoger A. Faulkner aui_fchmodat(au_event_t e)
960*794f0adbSRoger A. Faulkner {
961*794f0adbSRoger A. Faulkner 	klwp_t *clwp = ttolwp(curthread);
962*794f0adbSRoger A. Faulkner 
963*794f0adbSRoger A. Faulkner 	struct a {
964*794f0adbSRoger A. Faulkner 		long	fd;
965*794f0adbSRoger A. Faulkner 		long	fname;		/* char	* */
966*794f0adbSRoger A. Faulkner 		long	fmode;
967*794f0adbSRoger A. Faulkner 		long	flag;
968*794f0adbSRoger A. Faulkner 	} *uap = (struct a *)clwp->lwp_ap;
969*794f0adbSRoger A. Faulkner 
970*794f0adbSRoger A. Faulkner 	if (uap->fname == NULL)
971*794f0adbSRoger A. Faulkner 		e = AUE_FCHMOD;
972*794f0adbSRoger A. Faulkner 	else
973*794f0adbSRoger A. Faulkner 		e = AUE_CHMOD;
974*794f0adbSRoger A. Faulkner 
975*794f0adbSRoger A. Faulkner 	return (e);
976*794f0adbSRoger A. Faulkner }
977*794f0adbSRoger A. Faulkner 
978*794f0adbSRoger A. Faulkner /*ARGSUSED*/
979*794f0adbSRoger A. Faulkner static void
980*794f0adbSRoger A. Faulkner aus_fchmodat(struct t_audit_data *tad)
981*794f0adbSRoger A. Faulkner {
982*794f0adbSRoger A. Faulkner 	klwp_t *clwp = ttolwp(curthread);
983*794f0adbSRoger A. Faulkner 	uint32_t fmode;
984*794f0adbSRoger A. Faulkner 	uint32_t fd;
985*794f0adbSRoger A. Faulkner 	struct file  *fp;
986*794f0adbSRoger A. Faulkner 	struct vnode *vp;
987*794f0adbSRoger A. Faulkner 	struct f_audit_data *fad;
988*794f0adbSRoger A. Faulkner 
989*794f0adbSRoger A. Faulkner 	struct a {
990*794f0adbSRoger A. Faulkner 		long	fd;
991*794f0adbSRoger A. Faulkner 		long	fname;		/* char	* */
992*794f0adbSRoger A. Faulkner 		long	fmode;
993*794f0adbSRoger A. Faulkner 		long	flag;
994*794f0adbSRoger A. Faulkner 	} *uap = (struct a *)clwp->lwp_ap;
995*794f0adbSRoger A. Faulkner 
996*794f0adbSRoger A. Faulkner 	fd = (uint32_t)uap->fd;
997*794f0adbSRoger A. Faulkner 	fmode = (uint32_t)uap->fmode;
998*794f0adbSRoger A. Faulkner 
999*794f0adbSRoger A. Faulkner 	au_uwrite(au_to_arg32(2, "new file mode", fmode&07777));
1000*794f0adbSRoger A. Faulkner 
1001*794f0adbSRoger A. Faulkner 	if (fd == AT_FDCWD || uap->fname != NULL)	/* same as chmod() */
1002*794f0adbSRoger A. Faulkner 		return;
1003*794f0adbSRoger A. Faulkner 
1004*794f0adbSRoger A. Faulkner 	/*
1005*794f0adbSRoger A. Faulkner 	 * convert file pointer to file descriptor
1006*794f0adbSRoger A. Faulkner 	 *   Note: fd ref count incremented here.
1007*794f0adbSRoger A. Faulkner 	 */
1008*794f0adbSRoger A. Faulkner 	if ((fp = getf(fd)) == NULL)
1009*794f0adbSRoger A. Faulkner 		return;
1010*794f0adbSRoger A. Faulkner 
1011*794f0adbSRoger A. Faulkner 	/* get path from file struct here */
10127c478bd9Sstevel@tonic-gate 	fad = F2A(fp);
10137c478bd9Sstevel@tonic-gate 	if (fad->fad_aupath != NULL) {
10147c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_path(fad->fad_aupath));
10157c478bd9Sstevel@tonic-gate 	} else {
10167c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32(1, "no path: fd", fd));
10177c478bd9Sstevel@tonic-gate 	}
10187c478bd9Sstevel@tonic-gate 
10197c478bd9Sstevel@tonic-gate 	vp = fp->f_vnode;
10207c478bd9Sstevel@tonic-gate 	audit_attributes(vp);
10217c478bd9Sstevel@tonic-gate 
10227c478bd9Sstevel@tonic-gate 	/* decrement file descriptor reference count */
10237c478bd9Sstevel@tonic-gate 	releasef(fd);
10247c478bd9Sstevel@tonic-gate }
10257c478bd9Sstevel@tonic-gate 
10268fd04b83SRoger A. Faulkner /*
10278fd04b83SRoger A. Faulkner  * convert open mode to appropriate open event
10288fd04b83SRoger A. Faulkner  */
10298fd04b83SRoger A. Faulkner au_event_t
10308fd04b83SRoger A. Faulkner open_event(uint_t fm)
10318fd04b83SRoger A. Faulkner {
10328fd04b83SRoger A. Faulkner 	au_event_t e;
10338fd04b83SRoger A. Faulkner 
1034*794f0adbSRoger A. Faulkner 	switch (fm & (O_ACCMODE | O_CREAT | O_TRUNC)) {
10358fd04b83SRoger A. Faulkner 	case O_RDONLY:
10368fd04b83SRoger A. Faulkner 		e = AUE_OPEN_R;
10378fd04b83SRoger A. Faulkner 		break;
10388fd04b83SRoger A. Faulkner 	case O_RDONLY | O_CREAT:
10398fd04b83SRoger A. Faulkner 		e = AUE_OPEN_RC;
10408fd04b83SRoger A. Faulkner 		break;
10418fd04b83SRoger A. Faulkner 	case O_RDONLY | O_TRUNC:
10428fd04b83SRoger A. Faulkner 		e = AUE_OPEN_RT;
10438fd04b83SRoger A. Faulkner 		break;
10448fd04b83SRoger A. Faulkner 	case O_RDONLY | O_TRUNC | O_CREAT:
10458fd04b83SRoger A. Faulkner 		e = AUE_OPEN_RTC;
10468fd04b83SRoger A. Faulkner 		break;
10478fd04b83SRoger A. Faulkner 	case O_WRONLY:
10488fd04b83SRoger A. Faulkner 		e = AUE_OPEN_W;
10498fd04b83SRoger A. Faulkner 		break;
10508fd04b83SRoger A. Faulkner 	case O_WRONLY | O_CREAT:
10518fd04b83SRoger A. Faulkner 		e = AUE_OPEN_WC;
10528fd04b83SRoger A. Faulkner 		break;
10538fd04b83SRoger A. Faulkner 	case O_WRONLY | O_TRUNC:
10548fd04b83SRoger A. Faulkner 		e = AUE_OPEN_WT;
10558fd04b83SRoger A. Faulkner 		break;
10568fd04b83SRoger A. Faulkner 	case O_WRONLY | O_TRUNC | O_CREAT:
10578fd04b83SRoger A. Faulkner 		e = AUE_OPEN_WTC;
10588fd04b83SRoger A. Faulkner 		break;
10598fd04b83SRoger A. Faulkner 	case O_RDWR:
10608fd04b83SRoger A. Faulkner 		e = AUE_OPEN_RW;
10618fd04b83SRoger A. Faulkner 		break;
10628fd04b83SRoger A. Faulkner 	case O_RDWR | O_CREAT:
10638fd04b83SRoger A. Faulkner 		e = AUE_OPEN_RWC;
10648fd04b83SRoger A. Faulkner 		break;
10658fd04b83SRoger A. Faulkner 	case O_RDWR | O_TRUNC:
10668fd04b83SRoger A. Faulkner 		e = AUE_OPEN_RWT;
10678fd04b83SRoger A. Faulkner 		break;
10688fd04b83SRoger A. Faulkner 	case O_RDWR | O_TRUNC | O_CREAT:
10698fd04b83SRoger A. Faulkner 		e = AUE_OPEN_RWTC;
10708fd04b83SRoger A. Faulkner 		break;
1071*794f0adbSRoger A. Faulkner 	case O_SEARCH:
1072*794f0adbSRoger A. Faulkner 		e = AUE_OPEN_S;
1073*794f0adbSRoger A. Faulkner 		break;
1074*794f0adbSRoger A. Faulkner 	case O_EXEC:
1075*794f0adbSRoger A. Faulkner 		e = AUE_OPEN_E;
1076*794f0adbSRoger A. Faulkner 		break;
10778fd04b83SRoger A. Faulkner 	default:
10788fd04b83SRoger A. Faulkner 		e = AUE_NULL;
10798fd04b83SRoger A. Faulkner 		break;
10808fd04b83SRoger A. Faulkner 	}
10817c478bd9Sstevel@tonic-gate 
10828fd04b83SRoger A. Faulkner 	return (e);
10838fd04b83SRoger A. Faulkner }
10848fd04b83SRoger A. Faulkner 
10858fd04b83SRoger A. Faulkner /* ARGSUSED */
10867c478bd9Sstevel@tonic-gate static au_event_t
10877c478bd9Sstevel@tonic-gate aui_open(au_event_t e)
10887c478bd9Sstevel@tonic-gate {
10897c478bd9Sstevel@tonic-gate 	klwp_t *clwp = ttolwp(curthread);
10907c478bd9Sstevel@tonic-gate 	uint_t fm;
10917c478bd9Sstevel@tonic-gate 
10927c478bd9Sstevel@tonic-gate 	struct a {
10937c478bd9Sstevel@tonic-gate 		long	fnamep;		/* char	* */
10947c478bd9Sstevel@tonic-gate 		long	fmode;
10957c478bd9Sstevel@tonic-gate 		long	cmode;
10967c478bd9Sstevel@tonic-gate 	} *uap = (struct a *)clwp->lwp_ap;
10977c478bd9Sstevel@tonic-gate 
10987c478bd9Sstevel@tonic-gate 	fm = (uint_t)uap->fmode;
10997c478bd9Sstevel@tonic-gate 
11008fd04b83SRoger A. Faulkner 	return (open_event(fm));
11017c478bd9Sstevel@tonic-gate }
11027c478bd9Sstevel@tonic-gate 
11037c478bd9Sstevel@tonic-gate static void
11047c478bd9Sstevel@tonic-gate aus_open(struct t_audit_data *tad)
11057c478bd9Sstevel@tonic-gate {
11067c478bd9Sstevel@tonic-gate 	klwp_t *clwp = ttolwp(curthread);
11077c478bd9Sstevel@tonic-gate 	uint_t fm;
11087c478bd9Sstevel@tonic-gate 
11097c478bd9Sstevel@tonic-gate 	struct a {
11107c478bd9Sstevel@tonic-gate 		long	fnamep;		/* char	* */
11117c478bd9Sstevel@tonic-gate 		long	fmode;
11127c478bd9Sstevel@tonic-gate 		long	cmode;
11137c478bd9Sstevel@tonic-gate 	} *uap = (struct a *)clwp->lwp_ap;
11147c478bd9Sstevel@tonic-gate 
11157c478bd9Sstevel@tonic-gate 	fm = (uint_t)uap->fmode;
11167c478bd9Sstevel@tonic-gate 
11177c478bd9Sstevel@tonic-gate 	/* If no write, create, or trunc modes, mark as a public op */
11188fd04b83SRoger A. Faulkner 	if ((fm & (O_RDONLY|O_WRONLY|O_RDWR|O_CREAT|O_TRUNC)) == O_RDONLY)
11194a0fa546SMarek Pospisil 		tad->tad_ctrl |= TAD_PUBLIC_EV;
11207c478bd9Sstevel@tonic-gate }
11217c478bd9Sstevel@tonic-gate 
11228fd04b83SRoger A. Faulkner /* ARGSUSED */
11237c478bd9Sstevel@tonic-gate static au_event_t
11248fd04b83SRoger A. Faulkner aui_openat(au_event_t e)
11257c478bd9Sstevel@tonic-gate {
11268fd04b83SRoger A. Faulkner 	t_audit_data_t *tad = T2A(curthread);
11277c478bd9Sstevel@tonic-gate 	klwp_t *clwp = ttolwp(curthread);
11288fd04b83SRoger A. Faulkner 	uint_t fm;
11298fd04b83SRoger A. Faulkner 
11307c478bd9Sstevel@tonic-gate 	struct a {
11318fd04b83SRoger A. Faulkner 		long	filedes;
11328fd04b83SRoger A. Faulkner 		long	fnamep;		/* char	* */
11338fd04b83SRoger A. Faulkner 		long	fmode;
11348fd04b83SRoger A. Faulkner 		long	cmode;
11357c478bd9Sstevel@tonic-gate 	} *uap = (struct a *)clwp->lwp_ap;
11367c478bd9Sstevel@tonic-gate 
11378fd04b83SRoger A. Faulkner 	fm = (uint_t)uap->fmode;
11387c478bd9Sstevel@tonic-gate 
1139c4d3e299SBrent Paulson 	/*
1140c4d3e299SBrent Paulson 	 * __openattrdirat() does an extra pathname lookup in order to
1141c4d3e299SBrent Paulson 	 * enter the extended system attribute namespace of the referenced
1142c4d3e299SBrent Paulson 	 * extended attribute filename.
1143c4d3e299SBrent Paulson 	 */
1144c4d3e299SBrent Paulson 	if (fm & FXATTRDIROPEN)
1145c4d3e299SBrent Paulson 		tad->tad_ctrl |= TAD_MLD;
11467c478bd9Sstevel@tonic-gate 
11478fd04b83SRoger A. Faulkner 	return (open_event(fm));
11488fd04b83SRoger A. Faulkner }
11497c478bd9Sstevel@tonic-gate 
11508fd04b83SRoger A. Faulkner static void
11518fd04b83SRoger A. Faulkner aus_openat(struct t_audit_data *tad)
11528fd04b83SRoger A. Faulkner {
11538fd04b83SRoger A. Faulkner 	klwp_t *clwp = ttolwp(curthread);
11548fd04b83SRoger A. Faulkner 	uint_t fm;
11557c478bd9Sstevel@tonic-gate 
11568fd04b83SRoger A. Faulkner 	struct a {
11578fd04b83SRoger A. Faulkner 		long	filedes;
11588fd04b83SRoger A. Faulkner 		long	fnamep;		/* char	* */
11598fd04b83SRoger A. Faulkner 		long	fmode;
11608fd04b83SRoger A. Faulkner 		long	cmode;
11618fd04b83SRoger A. Faulkner 	} *uap = (struct a *)clwp->lwp_ap;
11627c478bd9Sstevel@tonic-gate 
11638fd04b83SRoger A. Faulkner 	fm = (uint_t)uap->fmode;
11647c478bd9Sstevel@tonic-gate 
11658fd04b83SRoger A. Faulkner 	/* If no write, create, or trunc modes, mark as a public op */
11668fd04b83SRoger A. Faulkner 	if ((fm & (O_RDONLY|O_WRONLY|O_RDWR|O_CREAT|O_TRUNC)) == O_RDONLY)
11674a0fa546SMarek Pospisil 		tad->tad_ctrl |= TAD_PUBLIC_EV;
11687c478bd9Sstevel@tonic-gate }
11697c478bd9Sstevel@tonic-gate 
11708fd04b83SRoger A. Faulkner static au_event_t
11718fd04b83SRoger A. Faulkner aui_unlinkat(au_event_t e)
11727c478bd9Sstevel@tonic-gate {
11737c478bd9Sstevel@tonic-gate 	klwp_t *clwp = ttolwp(curthread);
11748fd04b83SRoger A. Faulkner 
11757c478bd9Sstevel@tonic-gate 	struct a {
11768fd04b83SRoger A. Faulkner 		long	filedes;
11778fd04b83SRoger A. Faulkner 		long	fnamep;		/* char	* */
11788fd04b83SRoger A. Faulkner 		long	flags;
11797c478bd9Sstevel@tonic-gate 	} *uap = (struct a *)clwp->lwp_ap;
11807c478bd9Sstevel@tonic-gate 
11818fd04b83SRoger A. Faulkner 	if (uap->flags & AT_REMOVEDIR)
11828fd04b83SRoger A. Faulkner 		e = AUE_RMDIR;
11838fd04b83SRoger A. Faulkner 	else
11848fd04b83SRoger A. Faulkner 		e = AUE_UNLINK;
11857c478bd9Sstevel@tonic-gate 
11868fd04b83SRoger A. Faulkner 	return (e);
11878fd04b83SRoger A. Faulkner }
11887c478bd9Sstevel@tonic-gate 
11898fd04b83SRoger A. Faulkner static au_event_t
11908fd04b83SRoger A. Faulkner aui_fstatat(au_event_t e)
11918fd04b83SRoger A. Faulkner {
11928fd04b83SRoger A. Faulkner 	klwp_t *clwp = ttolwp(curthread);
11937c478bd9Sstevel@tonic-gate 
11948fd04b83SRoger A. Faulkner 	struct a {
11958fd04b83SRoger A. Faulkner 		long	filedes;
11968fd04b83SRoger A. Faulkner 		long	fnamep;		/* char	* */
11978fd04b83SRoger A. Faulkner 		long	statb;
11988fd04b83SRoger A. Faulkner 		long	flags;
11998fd04b83SRoger A. Faulkner 	} *uap = (struct a *)clwp->lwp_ap;
12008fd04b83SRoger A. Faulkner 
12018fd04b83SRoger A. Faulkner 	if (uap->fnamep == NULL)
12028fd04b83SRoger A. Faulkner 		e = AUE_FSTAT;
12038fd04b83SRoger A. Faulkner 	else if (uap->flags & AT_SYMLINK_NOFOLLOW)
12048fd04b83SRoger A. Faulkner 		e = AUE_LSTAT;
12058fd04b83SRoger A. Faulkner 	else
12068fd04b83SRoger A. Faulkner 		e = AUE_STAT;
12078fd04b83SRoger A. Faulkner 
12088fd04b83SRoger A. Faulkner 	return (e);
12097c478bd9Sstevel@tonic-gate }
12107c478bd9Sstevel@tonic-gate 
12117c478bd9Sstevel@tonic-gate /* msgsys */
12127c478bd9Sstevel@tonic-gate static au_event_t
12137c478bd9Sstevel@tonic-gate aui_msgsys(au_event_t e)
12147c478bd9Sstevel@tonic-gate {
12157c478bd9Sstevel@tonic-gate 	klwp_t *clwp = ttolwp(curthread);
12167c478bd9Sstevel@tonic-gate 	uint_t fm;
12177c478bd9Sstevel@tonic-gate 
12187c478bd9Sstevel@tonic-gate 	struct a {
12197c478bd9Sstevel@tonic-gate 		long	id;	/* function code id */
12207c478bd9Sstevel@tonic-gate 		long	ap;	/* arg pointer for recvmsg */
12217c478bd9Sstevel@tonic-gate 	} *uap = (struct a *)clwp->lwp_ap;
12227c478bd9Sstevel@tonic-gate 
12237c478bd9Sstevel@tonic-gate 	struct b {
12247c478bd9Sstevel@tonic-gate 		long	msgid;
12257c478bd9Sstevel@tonic-gate 		long	cmd;
12267c478bd9Sstevel@tonic-gate 		long	buf;	/* struct msqid_ds * */
12277c478bd9Sstevel@tonic-gate 	} *uap1 = (struct b *)&clwp->lwp_ap[1];
12287c478bd9Sstevel@tonic-gate 
12297c478bd9Sstevel@tonic-gate 	fm  = (uint_t)uap->id;
12307c478bd9Sstevel@tonic-gate 
12317c478bd9Sstevel@tonic-gate 	switch (fm) {
12327c478bd9Sstevel@tonic-gate 	case 0:		/* msgget */
12337c478bd9Sstevel@tonic-gate 		e = AUE_MSGGET;
12347c478bd9Sstevel@tonic-gate 		break;
12357c478bd9Sstevel@tonic-gate 	case 1:		/* msgctl */
12367c478bd9Sstevel@tonic-gate 		switch ((uint_t)uap1->cmd) {
12377c478bd9Sstevel@tonic-gate 		case IPC_RMID:
12387c478bd9Sstevel@tonic-gate 			e = AUE_MSGCTL_RMID;
12397c478bd9Sstevel@tonic-gate 			break;
12407c478bd9Sstevel@tonic-gate 		case IPC_SET:
12417c478bd9Sstevel@tonic-gate 			e = AUE_MSGCTL_SET;
12427c478bd9Sstevel@tonic-gate 			break;
12437c478bd9Sstevel@tonic-gate 		case IPC_STAT:
12447c478bd9Sstevel@tonic-gate 			e = AUE_MSGCTL_STAT;
12457c478bd9Sstevel@tonic-gate 			break;
12467c478bd9Sstevel@tonic-gate 		default:
12477c478bd9Sstevel@tonic-gate 			e = AUE_MSGCTL;
12487c478bd9Sstevel@tonic-gate 			break;
12497c478bd9Sstevel@tonic-gate 		}
12507c478bd9Sstevel@tonic-gate 		break;
12517c478bd9Sstevel@tonic-gate 	case 2:		/* msgrcv */
12527c478bd9Sstevel@tonic-gate 		e = AUE_MSGRCV;
12537c478bd9Sstevel@tonic-gate 		break;
12547c478bd9Sstevel@tonic-gate 	case 3:		/* msgsnd */
12557c478bd9Sstevel@tonic-gate 		e = AUE_MSGSND;
12567c478bd9Sstevel@tonic-gate 		break;
12577c478bd9Sstevel@tonic-gate 	default:	/* illegal system call */
12587c478bd9Sstevel@tonic-gate 		e = AUE_NULL;
12597c478bd9Sstevel@tonic-gate 		break;
12607c478bd9Sstevel@tonic-gate 	}
12617c478bd9Sstevel@tonic-gate 
12627c478bd9Sstevel@tonic-gate 	return (e);
12637c478bd9Sstevel@tonic-gate }
12647c478bd9Sstevel@tonic-gate 
12657c478bd9Sstevel@tonic-gate 
12667c478bd9Sstevel@tonic-gate /* shmsys */
12677c478bd9Sstevel@tonic-gate static au_event_t
12687c478bd9Sstevel@tonic-gate aui_shmsys(au_event_t e)
12697c478bd9Sstevel@tonic-gate {
12707c478bd9Sstevel@tonic-gate 	klwp_t *clwp = ttolwp(curthread);
12717c478bd9Sstevel@tonic-gate 	int fm;
12727c478bd9Sstevel@tonic-gate 
12737c478bd9Sstevel@tonic-gate 	struct a {		/* shmsys */
12747c478bd9Sstevel@tonic-gate 		long	id;	/* function code id */
12757c478bd9Sstevel@tonic-gate 	} *uap = (struct a *)clwp->lwp_ap;
12767c478bd9Sstevel@tonic-gate 
12777c478bd9Sstevel@tonic-gate 	struct b {		/* ctrl */
12787c478bd9Sstevel@tonic-gate 		long	shmid;
12797c478bd9Sstevel@tonic-gate 		long	cmd;
12807c478bd9Sstevel@tonic-gate 		long	arg;		/* struct shmid_ds * */
12817c478bd9Sstevel@tonic-gate 	} *uap1 = (struct b *)&clwp->lwp_ap[1];
12827c478bd9Sstevel@tonic-gate 	fm  = (uint_t)uap->id;
12837c478bd9Sstevel@tonic-gate 
12847c478bd9Sstevel@tonic-gate 	switch (fm) {
12857c478bd9Sstevel@tonic-gate 	case 0:		/* shmat */
12867c478bd9Sstevel@tonic-gate 		e = AUE_SHMAT;
12877c478bd9Sstevel@tonic-gate 		break;
12887c478bd9Sstevel@tonic-gate 	case 1:		/* shmctl */
12897c478bd9Sstevel@tonic-gate 		switch ((uint_t)uap1->cmd) {
12907c478bd9Sstevel@tonic-gate 		case IPC_RMID:
12917c478bd9Sstevel@tonic-gate 			e = AUE_SHMCTL_RMID;
12927c478bd9Sstevel@tonic-gate 			break;
12937c478bd9Sstevel@tonic-gate 		case IPC_SET:
12947c478bd9Sstevel@tonic-gate 			e = AUE_SHMCTL_SET;
12957c478bd9Sstevel@tonic-gate 			break;
12967c478bd9Sstevel@tonic-gate 		case IPC_STAT:
12977c478bd9Sstevel@tonic-gate 			e = AUE_SHMCTL_STAT;
12987c478bd9Sstevel@tonic-gate 			break;
12997c478bd9Sstevel@tonic-gate 		default:
13007c478bd9Sstevel@tonic-gate 			e = AUE_SHMCTL;
13017c478bd9Sstevel@tonic-gate 			break;
13027c478bd9Sstevel@tonic-gate 		}
13037c478bd9Sstevel@tonic-gate 		break;
13047c478bd9Sstevel@tonic-gate 	case 2:		/* shmdt */
13057c478bd9Sstevel@tonic-gate 		e = AUE_SHMDT;
13067c478bd9Sstevel@tonic-gate 		break;
13077c478bd9Sstevel@tonic-gate 	case 3:		/* shmget */
13087c478bd9Sstevel@tonic-gate 		e = AUE_SHMGET;
13097c478bd9Sstevel@tonic-gate 		break;
13107c478bd9Sstevel@tonic-gate 	default:	/* illegal system call */
13117c478bd9Sstevel@tonic-gate 		e = AUE_NULL;
13127c478bd9Sstevel@tonic-gate 		break;
13137c478bd9Sstevel@tonic-gate 	}
13147c478bd9Sstevel@tonic-gate 
13157c478bd9Sstevel@tonic-gate 	return (e);
13167c478bd9Sstevel@tonic-gate }
13177c478bd9Sstevel@tonic-gate 
13187c478bd9Sstevel@tonic-gate 
13197c478bd9Sstevel@tonic-gate /* semsys */
13207c478bd9Sstevel@tonic-gate static au_event_t
13217c478bd9Sstevel@tonic-gate aui_semsys(au_event_t e)
13227c478bd9Sstevel@tonic-gate {
13237c478bd9Sstevel@tonic-gate 	klwp_t *clwp = ttolwp(curthread);
13247c478bd9Sstevel@tonic-gate 	uint_t fm;
13257c478bd9Sstevel@tonic-gate 
13267c478bd9Sstevel@tonic-gate 	struct a {		/* semsys */
13277c478bd9Sstevel@tonic-gate 		long	id;
13287c478bd9Sstevel@tonic-gate 	} *uap = (struct a *)clwp->lwp_ap;
13297c478bd9Sstevel@tonic-gate 
13307c478bd9Sstevel@tonic-gate 	struct b {		/* ctrl */
13317c478bd9Sstevel@tonic-gate 		long	semid;
13327c478bd9Sstevel@tonic-gate 		long	semnum;
13337c478bd9Sstevel@tonic-gate 		long	cmd;
13347c478bd9Sstevel@tonic-gate 		long	arg;
13357c478bd9Sstevel@tonic-gate 	} *uap1 = (struct b *)&clwp->lwp_ap[1];
13367c478bd9Sstevel@tonic-gate 
13377c478bd9Sstevel@tonic-gate 	fm = (uint_t)uap->id;
13387c478bd9Sstevel@tonic-gate 
13397c478bd9Sstevel@tonic-gate 	switch (fm) {
13407c478bd9Sstevel@tonic-gate 	case 0:		/* semctl */
13417c478bd9Sstevel@tonic-gate 		switch ((uint_t)uap1->cmd) {
13427c478bd9Sstevel@tonic-gate 		case IPC_RMID:
13437c478bd9Sstevel@tonic-gate 			e = AUE_SEMCTL_RMID;
13447c478bd9Sstevel@tonic-gate 			break;
13457c478bd9Sstevel@tonic-gate 		case IPC_SET:
13467c478bd9Sstevel@tonic-gate 			e = AUE_SEMCTL_SET;
13477c478bd9Sstevel@tonic-gate 			break;
13487c478bd9Sstevel@tonic-gate 		case IPC_STAT:
13497c478bd9Sstevel@tonic-gate 			e = AUE_SEMCTL_STAT;
13507c478bd9Sstevel@tonic-gate 			break;
13517c478bd9Sstevel@tonic-gate 		case GETNCNT:
13527c478bd9Sstevel@tonic-gate 			e = AUE_SEMCTL_GETNCNT;
13537c478bd9Sstevel@tonic-gate 			break;
13547c478bd9Sstevel@tonic-gate 		case GETPID:
13557c478bd9Sstevel@tonic-gate 			e = AUE_SEMCTL_GETPID;
13567c478bd9Sstevel@tonic-gate 			break;
13577c478bd9Sstevel@tonic-gate 		case GETVAL:
13587c478bd9Sstevel@tonic-gate 			e = AUE_SEMCTL_GETVAL;
13597c478bd9Sstevel@tonic-gate 			break;
13607c478bd9Sstevel@tonic-gate 		case GETALL:
13617c478bd9Sstevel@tonic-gate 			e = AUE_SEMCTL_GETALL;
13627c478bd9Sstevel@tonic-gate 			break;
13637c478bd9Sstevel@tonic-gate 		case GETZCNT:
13647c478bd9Sstevel@tonic-gate 			e = AUE_SEMCTL_GETZCNT;
13657c478bd9Sstevel@tonic-gate 			break;
13667c478bd9Sstevel@tonic-gate 		case SETVAL:
13677c478bd9Sstevel@tonic-gate 			e = AUE_SEMCTL_SETVAL;
13687c478bd9Sstevel@tonic-gate 			break;
13697c478bd9Sstevel@tonic-gate 		case SETALL:
13707c478bd9Sstevel@tonic-gate 			e = AUE_SEMCTL_SETALL;
13717c478bd9Sstevel@tonic-gate 			break;
13727c478bd9Sstevel@tonic-gate 		default:
13737c478bd9Sstevel@tonic-gate 			e = AUE_SEMCTL;
13747c478bd9Sstevel@tonic-gate 			break;
13757c478bd9Sstevel@tonic-gate 		}
13767c478bd9Sstevel@tonic-gate 		break;
13777c478bd9Sstevel@tonic-gate 	case 1:		/* semget */
13787c478bd9Sstevel@tonic-gate 		e = AUE_SEMGET;
13797c478bd9Sstevel@tonic-gate 		break;
13807c478bd9Sstevel@tonic-gate 	case 2:		/* semop */
13817c478bd9Sstevel@tonic-gate 		e = AUE_SEMOP;
13827c478bd9Sstevel@tonic-gate 		break;
13837c478bd9Sstevel@tonic-gate 	default:	/* illegal system call */
13847c478bd9Sstevel@tonic-gate 		e = AUE_NULL;
13857c478bd9Sstevel@tonic-gate 		break;
13867c478bd9Sstevel@tonic-gate 	}
13877c478bd9Sstevel@tonic-gate 
13887c478bd9Sstevel@tonic-gate 	return (e);
13897c478bd9Sstevel@tonic-gate }
13907c478bd9Sstevel@tonic-gate 
13917c478bd9Sstevel@tonic-gate /* utssys - uname(2), ustat(2), fusers(2) */
13927c478bd9Sstevel@tonic-gate static au_event_t
13937c478bd9Sstevel@tonic-gate aui_utssys(au_event_t e)
13947c478bd9Sstevel@tonic-gate {
13957c478bd9Sstevel@tonic-gate 	klwp_t *clwp = ttolwp(curthread);
13967c478bd9Sstevel@tonic-gate 	uint_t type;
13977c478bd9Sstevel@tonic-gate 
13987c478bd9Sstevel@tonic-gate 	struct a {
13997c478bd9Sstevel@tonic-gate 		union {
14007c478bd9Sstevel@tonic-gate 			long	cbuf;		/* char * */
14017c478bd9Sstevel@tonic-gate 			long	ubuf;		/* struct stat * */
14027c478bd9Sstevel@tonic-gate 		} ub;
14037c478bd9Sstevel@tonic-gate 		union {
14047c478bd9Sstevel@tonic-gate 			long	mv;	/* for USTAT */
14057c478bd9Sstevel@tonic-gate 			long	flags;	/* for FUSERS */
14067c478bd9Sstevel@tonic-gate 		} un;
14077c478bd9Sstevel@tonic-gate 		long	type;
14087c478bd9Sstevel@tonic-gate 		long	outbp;		/* char * for FUSERS */
14097c478bd9Sstevel@tonic-gate 	} *uap = (struct a *)clwp->lwp_ap;
14107c478bd9Sstevel@tonic-gate 
14117c478bd9Sstevel@tonic-gate 	type = (uint_t)uap->type;
14127c478bd9Sstevel@tonic-gate 
14137c478bd9Sstevel@tonic-gate 	if (type == UTS_FUSERS)
14147c478bd9Sstevel@tonic-gate 		return (e);
14157c478bd9Sstevel@tonic-gate 	else
14167c478bd9Sstevel@tonic-gate 		return ((au_event_t)AUE_NULL);
14177c478bd9Sstevel@tonic-gate }
14187c478bd9Sstevel@tonic-gate 
14197c478bd9Sstevel@tonic-gate static au_event_t
14207c478bd9Sstevel@tonic-gate aui_fcntl(au_event_t e)
14217c478bd9Sstevel@tonic-gate {
14227c478bd9Sstevel@tonic-gate 	klwp_t *clwp = ttolwp(curthread);
14237c478bd9Sstevel@tonic-gate 	uint_t cmd;
14247c478bd9Sstevel@tonic-gate 
14257c478bd9Sstevel@tonic-gate 	struct a {
14267c478bd9Sstevel@tonic-gate 		long	fdes;
14277c478bd9Sstevel@tonic-gate 		long	cmd;
14287c478bd9Sstevel@tonic-gate 		long	arg;
14297c478bd9Sstevel@tonic-gate 	} *uap = (struct a *)clwp->lwp_ap;
14307c478bd9Sstevel@tonic-gate 
14317c478bd9Sstevel@tonic-gate 	cmd = (uint_t)uap->cmd;
14327c478bd9Sstevel@tonic-gate 
14337c478bd9Sstevel@tonic-gate 	switch (cmd) {
14347c478bd9Sstevel@tonic-gate 	case F_GETLK:
14357c478bd9Sstevel@tonic-gate 	case F_SETLK:
14367c478bd9Sstevel@tonic-gate 	case F_SETLKW:
14377c478bd9Sstevel@tonic-gate 		break;
14387c478bd9Sstevel@tonic-gate 	case F_SETFL:
14397c478bd9Sstevel@tonic-gate 	case F_GETFL:
14407c478bd9Sstevel@tonic-gate 	case F_GETFD:
14417c478bd9Sstevel@tonic-gate 		break;
14427c478bd9Sstevel@tonic-gate 	default:
14437c478bd9Sstevel@tonic-gate 		e = (au_event_t)AUE_NULL;
14447c478bd9Sstevel@tonic-gate 		break;
14457c478bd9Sstevel@tonic-gate 	}
14467c478bd9Sstevel@tonic-gate 	return ((au_event_t)e);
14477c478bd9Sstevel@tonic-gate }
14487c478bd9Sstevel@tonic-gate 
14497c478bd9Sstevel@tonic-gate /* null function for now */
14507c478bd9Sstevel@tonic-gate static au_event_t
14517c478bd9Sstevel@tonic-gate aui_execve(au_event_t e)
14527c478bd9Sstevel@tonic-gate {
14537c478bd9Sstevel@tonic-gate 	return (e);
14547c478bd9Sstevel@tonic-gate }
14557c478bd9Sstevel@tonic-gate 
14567c478bd9Sstevel@tonic-gate /*ARGSUSED*/
14577c478bd9Sstevel@tonic-gate static void
14587c478bd9Sstevel@tonic-gate aus_fcntl(struct t_audit_data *tad)
14597c478bd9Sstevel@tonic-gate {
14607c478bd9Sstevel@tonic-gate 	klwp_t *clwp = ttolwp(curthread);
146151b433b7SMarek Pospisil 	uint32_t cmd, fd, flags;
14627c478bd9Sstevel@tonic-gate 	struct file  *fp;
14637c478bd9Sstevel@tonic-gate 	struct vnode *vp;
14647c478bd9Sstevel@tonic-gate 	struct f_audit_data *fad;
14657c478bd9Sstevel@tonic-gate 
14667c478bd9Sstevel@tonic-gate 	struct a {
14677c478bd9Sstevel@tonic-gate 		long	fd;
14687c478bd9Sstevel@tonic-gate 		long	cmd;
14697c478bd9Sstevel@tonic-gate 		long	arg;
14707c478bd9Sstevel@tonic-gate 	} *uap = (struct a *)clwp->lwp_ap;
14717c478bd9Sstevel@tonic-gate 
147251b433b7SMarek Pospisil 	cmd	= (uint32_t)uap->cmd;
147351b433b7SMarek Pospisil 	fd	= (uint32_t)uap->fd;
147451b433b7SMarek Pospisil 	flags	= (uint32_t)uap->arg;
14757c478bd9Sstevel@tonic-gate 
14767c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_arg32(2, "cmd", cmd));
14777c478bd9Sstevel@tonic-gate 
147851b433b7SMarek Pospisil 	if (cmd == F_SETFL)
147951b433b7SMarek Pospisil 		au_uwrite(au_to_arg32(3, "flags", flags));
148051b433b7SMarek Pospisil 
14817c478bd9Sstevel@tonic-gate 		/*
14827c478bd9Sstevel@tonic-gate 		 * convert file pointer to file descriptor
14837c478bd9Sstevel@tonic-gate 		 *   Note: fd ref count incremented here.
14847c478bd9Sstevel@tonic-gate 		 */
14857c478bd9Sstevel@tonic-gate 	if ((fp = getf(fd)) == NULL)
14867c478bd9Sstevel@tonic-gate 		return;
14877c478bd9Sstevel@tonic-gate 
14887c478bd9Sstevel@tonic-gate 	/* get path from file struct here */
14897c478bd9Sstevel@tonic-gate 	fad = F2A(fp);
14907c478bd9Sstevel@tonic-gate 	if (fad->fad_aupath != NULL) {
14917c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_path(fad->fad_aupath));
14927c478bd9Sstevel@tonic-gate 	} else {
14937c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32(1, "no path: fd", fd));
14947c478bd9Sstevel@tonic-gate 	}
14957c478bd9Sstevel@tonic-gate 
14967c478bd9Sstevel@tonic-gate 	vp = fp->f_vnode;
14977c478bd9Sstevel@tonic-gate 	audit_attributes(vp);
14987c478bd9Sstevel@tonic-gate 
14997c478bd9Sstevel@tonic-gate 	/* decrement file descriptor reference count */
15007c478bd9Sstevel@tonic-gate 	releasef(fd);
15017c478bd9Sstevel@tonic-gate }
15027c478bd9Sstevel@tonic-gate 
15037c478bd9Sstevel@tonic-gate /*ARGSUSED*/
15047c478bd9Sstevel@tonic-gate static void
15057c478bd9Sstevel@tonic-gate aus_kill(struct t_audit_data *tad)
15067c478bd9Sstevel@tonic-gate {
15077c478bd9Sstevel@tonic-gate 	klwp_t *clwp = ttolwp(curthread);
15087c478bd9Sstevel@tonic-gate 	struct proc *p;
15097c478bd9Sstevel@tonic-gate 	uint32_t signo;
15107c478bd9Sstevel@tonic-gate 	uid_t uid, ruid;
15117c478bd9Sstevel@tonic-gate 	gid_t gid, rgid;
15127c478bd9Sstevel@tonic-gate 	pid_t pid;
15137c478bd9Sstevel@tonic-gate 	const auditinfo_addr_t *ainfo;
15147c478bd9Sstevel@tonic-gate 	cred_t *cr;
15157c478bd9Sstevel@tonic-gate 
15167c478bd9Sstevel@tonic-gate 	struct a {
15177c478bd9Sstevel@tonic-gate 		long	pid;
15187c478bd9Sstevel@tonic-gate 		long	signo;
15197c478bd9Sstevel@tonic-gate 	} *uap = (struct a *)clwp->lwp_ap;
15207c478bd9Sstevel@tonic-gate 
15217c478bd9Sstevel@tonic-gate 	pid   = (pid_t)uap->pid;
15227c478bd9Sstevel@tonic-gate 	signo = (uint32_t)uap->signo;
15237c478bd9Sstevel@tonic-gate 
15247c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_arg32(2, "signal", signo));
15257c478bd9Sstevel@tonic-gate 	if (pid > 0) {
15267c478bd9Sstevel@tonic-gate 		mutex_enter(&pidlock);
15277c478bd9Sstevel@tonic-gate 		if (((p = prfind(pid)) == (struct proc *)0) ||
15287c478bd9Sstevel@tonic-gate 		    (p->p_stat == SIDL)) {
15297c478bd9Sstevel@tonic-gate 			mutex_exit(&pidlock);
15307c478bd9Sstevel@tonic-gate 			au_uwrite(au_to_arg32(1, "process", (uint32_t)pid));
15317c478bd9Sstevel@tonic-gate 			return;
15327c478bd9Sstevel@tonic-gate 		}
15337c478bd9Sstevel@tonic-gate 		mutex_enter(&p->p_lock); /* so process doesn't go away */
15347c478bd9Sstevel@tonic-gate 		mutex_exit(&pidlock);
15357c478bd9Sstevel@tonic-gate 
15367c478bd9Sstevel@tonic-gate 		mutex_enter(&p->p_crlock);
15377c478bd9Sstevel@tonic-gate 		crhold(cr = p->p_cred);
15387c478bd9Sstevel@tonic-gate 		mutex_exit(&p->p_crlock);
15397c478bd9Sstevel@tonic-gate 		mutex_exit(&p->p_lock);
15407c478bd9Sstevel@tonic-gate 
15417c478bd9Sstevel@tonic-gate 		ainfo = crgetauinfo(cr);
15427c478bd9Sstevel@tonic-gate 		if (ainfo == NULL) {
15437c478bd9Sstevel@tonic-gate 			crfree(cr);
15447c478bd9Sstevel@tonic-gate 			au_uwrite(au_to_arg32(1, "process", (uint32_t)pid));
15457c478bd9Sstevel@tonic-gate 			return;
15467c478bd9Sstevel@tonic-gate 		}
15477c478bd9Sstevel@tonic-gate 
15487c478bd9Sstevel@tonic-gate 		uid  = crgetuid(cr);
15497c478bd9Sstevel@tonic-gate 		gid  = crgetgid(cr);
15507c478bd9Sstevel@tonic-gate 		ruid = crgetruid(cr);
15517c478bd9Sstevel@tonic-gate 		rgid = crgetrgid(cr);
15527c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_process(uid, gid, ruid, rgid, pid,
15537c478bd9Sstevel@tonic-gate 		    ainfo->ai_auid, ainfo->ai_asid, &ainfo->ai_termid));
155445916cd2Sjpk 
155545916cd2Sjpk 		if (is_system_labeled())
155645916cd2Sjpk 			au_uwrite(au_to_label(CR_SL(cr)));
155745916cd2Sjpk 
15587c478bd9Sstevel@tonic-gate 		crfree(cr);
15597c478bd9Sstevel@tonic-gate 	}
15607c478bd9Sstevel@tonic-gate 	else
15617c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32(1, "process", (uint32_t)pid));
15627c478bd9Sstevel@tonic-gate }
15637c478bd9Sstevel@tonic-gate 
15647c478bd9Sstevel@tonic-gate /*ARGSUSED*/
15657c478bd9Sstevel@tonic-gate static void
15667c478bd9Sstevel@tonic-gate aus_mkdir(struct t_audit_data *tad)
15677c478bd9Sstevel@tonic-gate {
15687c478bd9Sstevel@tonic-gate 	klwp_t *clwp = ttolwp(curthread);
15697c478bd9Sstevel@tonic-gate 	uint32_t dmode;
15707c478bd9Sstevel@tonic-gate 
15717c478bd9Sstevel@tonic-gate 	struct a {
15727c478bd9Sstevel@tonic-gate 		long	dirnamep;		/* char * */
15737c478bd9Sstevel@tonic-gate 		long	dmode;
15747c478bd9Sstevel@tonic-gate 	} *uap = (struct a *)clwp->lwp_ap;
15757c478bd9Sstevel@tonic-gate 
15767c478bd9Sstevel@tonic-gate 	dmode = (uint32_t)uap->dmode;
15777c478bd9Sstevel@tonic-gate 
15787c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_arg32(2, "mode", dmode));
15797c478bd9Sstevel@tonic-gate }
15807c478bd9Sstevel@tonic-gate 
1581*794f0adbSRoger A. Faulkner /*ARGSUSED*/
1582*794f0adbSRoger A. Faulkner static void
1583*794f0adbSRoger A. Faulkner aus_mkdirat(struct t_audit_data *tad)
1584*794f0adbSRoger A. Faulkner {
1585*794f0adbSRoger A. Faulkner 	klwp_t *clwp = ttolwp(curthread);
1586*794f0adbSRoger A. Faulkner 	uint32_t dmode;
1587*794f0adbSRoger A. Faulkner 
1588*794f0adbSRoger A. Faulkner 	struct a {
1589*794f0adbSRoger A. Faulkner 		long	fd;
1590*794f0adbSRoger A. Faulkner 		long	dirnamep;		/* char * */
1591*794f0adbSRoger A. Faulkner 		long	dmode;
1592*794f0adbSRoger A. Faulkner 	} *uap = (struct a *)clwp->lwp_ap;
1593*794f0adbSRoger A. Faulkner 
1594*794f0adbSRoger A. Faulkner 	dmode = (uint32_t)uap->dmode;
1595*794f0adbSRoger A. Faulkner 
1596*794f0adbSRoger A. Faulkner 	au_uwrite(au_to_arg32(2, "mode", dmode));
1597*794f0adbSRoger A. Faulkner }
1598*794f0adbSRoger A. Faulkner 
15997c478bd9Sstevel@tonic-gate /*ARGSUSED*/
16007c478bd9Sstevel@tonic-gate static void
16017c478bd9Sstevel@tonic-gate aus_mknod(struct t_audit_data *tad)
16027c478bd9Sstevel@tonic-gate {
16037c478bd9Sstevel@tonic-gate 	klwp_t *clwp = ttolwp(curthread);
16047c478bd9Sstevel@tonic-gate 	uint32_t fmode;
16057c478bd9Sstevel@tonic-gate 	dev_t dev;
16067c478bd9Sstevel@tonic-gate 
16077c478bd9Sstevel@tonic-gate 	struct a {
16087c478bd9Sstevel@tonic-gate 		long	pnamep;		/* char * */
16097c478bd9Sstevel@tonic-gate 		long	fmode;
16107c478bd9Sstevel@tonic-gate 		long	dev;
16117c478bd9Sstevel@tonic-gate 	} *uap = (struct a *)clwp->lwp_ap;
16127c478bd9Sstevel@tonic-gate 
16137c478bd9Sstevel@tonic-gate 	fmode = (uint32_t)uap->fmode;
16147c478bd9Sstevel@tonic-gate 	dev   = (dev_t)uap->dev;
16157c478bd9Sstevel@tonic-gate 
16167c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_arg32(2, "mode", fmode));
16177c478bd9Sstevel@tonic-gate #ifdef _LP64
16187c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_arg64(3, "dev", dev));
16197c478bd9Sstevel@tonic-gate #else
16207c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_arg32(3, "dev", dev));
16217c478bd9Sstevel@tonic-gate #endif
16227c478bd9Sstevel@tonic-gate }
16237c478bd9Sstevel@tonic-gate 
16247c478bd9Sstevel@tonic-gate /*ARGSUSED*/
16257c478bd9Sstevel@tonic-gate static void
16267c478bd9Sstevel@tonic-gate auf_mknod(struct t_audit_data *tad, int error, rval_t *rval)
16277c478bd9Sstevel@tonic-gate {
16287c478bd9Sstevel@tonic-gate 	klwp_t *clwp = ttolwp(curthread);
16297c478bd9Sstevel@tonic-gate 	vnode_t	*dvp;
16307c478bd9Sstevel@tonic-gate 	caddr_t pnamep;
16317c478bd9Sstevel@tonic-gate 
16327c478bd9Sstevel@tonic-gate 	struct a {
16337c478bd9Sstevel@tonic-gate 		long	pnamep;		/* char * */
16347c478bd9Sstevel@tonic-gate 		long	fmode;
16357c478bd9Sstevel@tonic-gate 		long	dev;
16367c478bd9Sstevel@tonic-gate 	} *uap = (struct a *)clwp->lwp_ap;
16377c478bd9Sstevel@tonic-gate 
16387c478bd9Sstevel@tonic-gate 	/* no error, then already path token in audit record */
1639*794f0adbSRoger A. Faulkner 	if (error != EPERM && error != EINVAL)
16407c478bd9Sstevel@tonic-gate 		return;
16417c478bd9Sstevel@tonic-gate 
1642*794f0adbSRoger A. Faulkner 	/* do the lookup to force generation of path token */
1643*794f0adbSRoger A. Faulkner 	pnamep = (caddr_t)uap->pnamep;
1644*794f0adbSRoger A. Faulkner 	tad->tad_ctrl |= TAD_NOATTRB;
1645*794f0adbSRoger A. Faulkner 	error = lookupname(pnamep, UIO_USERSPACE, NO_FOLLOW, &dvp, NULLVPP);
1646*794f0adbSRoger A. Faulkner 	if (error == 0)
1647*794f0adbSRoger A. Faulkner 		VN_RELE(dvp);
1648*794f0adbSRoger A. Faulkner }
1649*794f0adbSRoger A. Faulkner 
1650*794f0adbSRoger A. Faulkner /*ARGSUSED*/
1651*794f0adbSRoger A. Faulkner static void
1652*794f0adbSRoger A. Faulkner aus_mknodat(struct t_audit_data *tad)
1653*794f0adbSRoger A. Faulkner {
1654*794f0adbSRoger A. Faulkner 	klwp_t *clwp = ttolwp(curthread);
1655*794f0adbSRoger A. Faulkner 	uint32_t fmode;
1656*794f0adbSRoger A. Faulkner 	dev_t dev;
1657*794f0adbSRoger A. Faulkner 
1658*794f0adbSRoger A. Faulkner 	struct a {
1659*794f0adbSRoger A. Faulkner 		long	fd;
1660*794f0adbSRoger A. Faulkner 		long	pnamep;		/* char * */
1661*794f0adbSRoger A. Faulkner 		long	fmode;
1662*794f0adbSRoger A. Faulkner 		long	dev;
1663*794f0adbSRoger A. Faulkner 	} *uap = (struct a *)clwp->lwp_ap;
1664*794f0adbSRoger A. Faulkner 
1665*794f0adbSRoger A. Faulkner 	fmode = (uint32_t)uap->fmode;
1666*794f0adbSRoger A. Faulkner 	dev   = (dev_t)uap->dev;
1667*794f0adbSRoger A. Faulkner 
1668*794f0adbSRoger A. Faulkner 	au_uwrite(au_to_arg32(2, "mode", fmode));
1669*794f0adbSRoger A. Faulkner #ifdef _LP64
1670*794f0adbSRoger A. Faulkner 	au_uwrite(au_to_arg64(3, "dev", dev));
1671*794f0adbSRoger A. Faulkner #else
1672*794f0adbSRoger A. Faulkner 	au_uwrite(au_to_arg32(3, "dev", dev));
1673*794f0adbSRoger A. Faulkner #endif
1674*794f0adbSRoger A. Faulkner }
1675*794f0adbSRoger A. Faulkner 
1676*794f0adbSRoger A. Faulkner /*ARGSUSED*/
1677*794f0adbSRoger A. Faulkner static void
1678*794f0adbSRoger A. Faulkner auf_mknodat(struct t_audit_data *tad, int error, rval_t *rval)
1679*794f0adbSRoger A. Faulkner {
1680*794f0adbSRoger A. Faulkner 	klwp_t *clwp = ttolwp(curthread);
1681*794f0adbSRoger A. Faulkner 	vnode_t	*startvp;
1682*794f0adbSRoger A. Faulkner 	vnode_t	*dvp;
1683*794f0adbSRoger A. Faulkner 	caddr_t pnamep;
1684*794f0adbSRoger A. Faulkner 	int fd;
1685*794f0adbSRoger A. Faulkner 
1686*794f0adbSRoger A. Faulkner 	struct a {
1687*794f0adbSRoger A. Faulkner 		long	fd;
1688*794f0adbSRoger A. Faulkner 		long	pnamep;		/* char * */
1689*794f0adbSRoger A. Faulkner 		long	fmode;
1690*794f0adbSRoger A. Faulkner 		long	dev;
1691*794f0adbSRoger A. Faulkner 	} *uap = (struct a *)clwp->lwp_ap;
1692*794f0adbSRoger A. Faulkner 
1693*794f0adbSRoger A. Faulkner 	/* no error, then already path token in audit record */
1694*794f0adbSRoger A. Faulkner 	if (error != EPERM && error != EINVAL)
16957c478bd9Sstevel@tonic-gate 		return;
16967c478bd9Sstevel@tonic-gate 
16977c478bd9Sstevel@tonic-gate 	/* do the lookup to force generation of path token */
1698*794f0adbSRoger A. Faulkner 	fd = (int)uap->fd;
16997c478bd9Sstevel@tonic-gate 	pnamep = (caddr_t)uap->pnamep;
1700*794f0adbSRoger A. Faulkner 	if (pnamep == NULL ||
1701*794f0adbSRoger A. Faulkner 	    fgetstartvp(fd, pnamep, &startvp) != 0)
1702*794f0adbSRoger A. Faulkner 		return;
17034a0fa546SMarek Pospisil 	tad->tad_ctrl |= TAD_NOATTRB;
1704*794f0adbSRoger A. Faulkner 	error = lookupnameat(pnamep, UIO_USERSPACE, NO_FOLLOW, &dvp, NULLVPP,
1705*794f0adbSRoger A. Faulkner 	    startvp);
17067c478bd9Sstevel@tonic-gate 	if (error == 0)
17077c478bd9Sstevel@tonic-gate 		VN_RELE(dvp);
1708*794f0adbSRoger A. Faulkner 	if (startvp != NULL)
1709*794f0adbSRoger A. Faulkner 		VN_RELE(startvp);
17107c478bd9Sstevel@tonic-gate }
17117c478bd9Sstevel@tonic-gate 
17127c478bd9Sstevel@tonic-gate /*ARGSUSED*/
17137c478bd9Sstevel@tonic-gate static void
17147c478bd9Sstevel@tonic-gate aus_mount(struct t_audit_data *tad)
17157c478bd9Sstevel@tonic-gate {	/* AUS_START */
17167c478bd9Sstevel@tonic-gate 	klwp_t *clwp = ttolwp(curthread);
17177c478bd9Sstevel@tonic-gate 	uint32_t flags;
17187c478bd9Sstevel@tonic-gate 	uintptr_t u_fstype, dataptr;
17197c478bd9Sstevel@tonic-gate 	STRUCT_DECL(nfs_args, nfsargs);
17207c478bd9Sstevel@tonic-gate 	size_t len;
17217c478bd9Sstevel@tonic-gate 	char *fstype, *hostname;
17227c478bd9Sstevel@tonic-gate 
17237c478bd9Sstevel@tonic-gate 	struct a {
17247c478bd9Sstevel@tonic-gate 		long	spec;		/* char    * */
17257c478bd9Sstevel@tonic-gate 		long	dir;		/* char    * */
17267c478bd9Sstevel@tonic-gate 		long	flags;
17277c478bd9Sstevel@tonic-gate 		long	fstype;		/* char    * */
17287c478bd9Sstevel@tonic-gate 		long	dataptr;	/* char    * */
17297c478bd9Sstevel@tonic-gate 		long	datalen;
17307c478bd9Sstevel@tonic-gate 	} *uap = (struct a *)clwp->lwp_ap;
17317c478bd9Sstevel@tonic-gate 
17327c478bd9Sstevel@tonic-gate 	u_fstype = (uintptr_t)uap->fstype;
17337c478bd9Sstevel@tonic-gate 	flags    = (uint32_t)uap->flags;
17347c478bd9Sstevel@tonic-gate 	dataptr  = (uintptr_t)uap->dataptr;
17357c478bd9Sstevel@tonic-gate 
17367c478bd9Sstevel@tonic-gate 	fstype = kmem_alloc(MAXNAMELEN, KM_SLEEP);
17377c478bd9Sstevel@tonic-gate 	if (copyinstr((caddr_t)u_fstype, (caddr_t)fstype, MAXNAMELEN, &len))
17387c478bd9Sstevel@tonic-gate 		goto mount_free_fstype;
17397c478bd9Sstevel@tonic-gate 
17407c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_arg32(3, "flags", flags));
17417c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_text(fstype));
17427c478bd9Sstevel@tonic-gate 
17437c478bd9Sstevel@tonic-gate 	if (strncmp(fstype, "nfs", 3) == 0) {
17447c478bd9Sstevel@tonic-gate 
17457c478bd9Sstevel@tonic-gate 		STRUCT_INIT(nfsargs, get_udatamodel());
17467c478bd9Sstevel@tonic-gate 		bzero(STRUCT_BUF(nfsargs), STRUCT_SIZE(nfsargs));
17477c478bd9Sstevel@tonic-gate 
17487c478bd9Sstevel@tonic-gate 		if (copyin((caddr_t)dataptr,
17497c478bd9Sstevel@tonic-gate 				STRUCT_BUF(nfsargs),
17507c478bd9Sstevel@tonic-gate 				MIN(uap->datalen, STRUCT_SIZE(nfsargs)))) {
17517c478bd9Sstevel@tonic-gate 			/* DEBUG debug_enter((char *)NULL); */
17527c478bd9Sstevel@tonic-gate 			goto mount_free_fstype;
17537c478bd9Sstevel@tonic-gate 		}
17547c478bd9Sstevel@tonic-gate 		hostname = kmem_alloc(MAXNAMELEN, KM_SLEEP);
17557c478bd9Sstevel@tonic-gate 		if (copyinstr(STRUCT_FGETP(nfsargs, hostname),
17567c478bd9Sstevel@tonic-gate 				(caddr_t)hostname,
17577c478bd9Sstevel@tonic-gate 				MAXNAMELEN, &len)) {
17587c478bd9Sstevel@tonic-gate 			goto mount_free_hostname;
17597c478bd9Sstevel@tonic-gate 		}
17607c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_text(hostname));
17617c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32(3, "internal flags",
17627c478bd9Sstevel@tonic-gate 			(uint_t)STRUCT_FGET(nfsargs, flags)));
17637c478bd9Sstevel@tonic-gate 
17647c478bd9Sstevel@tonic-gate mount_free_hostname:
17657c478bd9Sstevel@tonic-gate 		kmem_free(hostname, MAXNAMELEN);
17667c478bd9Sstevel@tonic-gate 	}
17677c478bd9Sstevel@tonic-gate 
17687c478bd9Sstevel@tonic-gate mount_free_fstype:
17697c478bd9Sstevel@tonic-gate 	kmem_free(fstype, MAXNAMELEN);
17707c478bd9Sstevel@tonic-gate }	/* AUS_MOUNT */
17717c478bd9Sstevel@tonic-gate 
17727c478bd9Sstevel@tonic-gate static void
17737c478bd9Sstevel@tonic-gate aus_umount_path(caddr_t umount_dir)
17747c478bd9Sstevel@tonic-gate {
17757c478bd9Sstevel@tonic-gate 	char			*dir_path;
17767c478bd9Sstevel@tonic-gate 	struct audit_path	*path;
17777c478bd9Sstevel@tonic-gate 	size_t			path_len, dir_len;
17787c478bd9Sstevel@tonic-gate 
17797c478bd9Sstevel@tonic-gate 	/* length alloc'd for two string pointers */
17807c478bd9Sstevel@tonic-gate 	path_len = sizeof (struct audit_path) + sizeof (char *);
17817c478bd9Sstevel@tonic-gate 	path = kmem_alloc(path_len, KM_SLEEP);
17827c478bd9Sstevel@tonic-gate 	dir_path = kmem_alloc(MAXPATHLEN, KM_SLEEP);
17837c478bd9Sstevel@tonic-gate 
17847c478bd9Sstevel@tonic-gate 	if (copyinstr(umount_dir, (caddr_t)dir_path,
17857c478bd9Sstevel@tonic-gate 	    MAXPATHLEN, &dir_len))
17867c478bd9Sstevel@tonic-gate 		goto umount2_free_dir;
17877c478bd9Sstevel@tonic-gate 
17887c478bd9Sstevel@tonic-gate 	/*
17897c478bd9Sstevel@tonic-gate 	 * the audit_path struct assumes that the buffer pointed to
17907c478bd9Sstevel@tonic-gate 	 * by audp_sect[n] contains string 0 immediatedly followed
17917c478bd9Sstevel@tonic-gate 	 * by string 1.
17927c478bd9Sstevel@tonic-gate 	 */
17937c478bd9Sstevel@tonic-gate 	path->audp_sect[0] = dir_path;
17947c478bd9Sstevel@tonic-gate 	path->audp_sect[1] = dir_path + strlen(dir_path) + 1;
17957c478bd9Sstevel@tonic-gate 	path->audp_size = path_len;
17967c478bd9Sstevel@tonic-gate 	path->audp_ref = 1;		/* not used */
17977c478bd9Sstevel@tonic-gate 	path->audp_cnt = 1;		/* one path string */
17987c478bd9Sstevel@tonic-gate 
17997c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_path(path));
18007c478bd9Sstevel@tonic-gate 
18017c478bd9Sstevel@tonic-gate umount2_free_dir:
18027c478bd9Sstevel@tonic-gate 	kmem_free(dir_path, MAXPATHLEN);
18037c478bd9Sstevel@tonic-gate 	kmem_free(path, path_len);
18047c478bd9Sstevel@tonic-gate }
18057c478bd9Sstevel@tonic-gate 
18067c478bd9Sstevel@tonic-gate /*ARGSUSED*/
18077c478bd9Sstevel@tonic-gate static void
18087c478bd9Sstevel@tonic-gate aus_umount2(struct t_audit_data *tad)
18097c478bd9Sstevel@tonic-gate {
18107c478bd9Sstevel@tonic-gate 	klwp_t			*clwp = ttolwp(curthread);
18117c478bd9Sstevel@tonic-gate 	struct a {
18127c478bd9Sstevel@tonic-gate 		long	dir;		/* char    * */
18137c478bd9Sstevel@tonic-gate 		long	flags;
18147c478bd9Sstevel@tonic-gate 	} *uap = (struct a *)clwp->lwp_ap;
18157c478bd9Sstevel@tonic-gate 
18167c478bd9Sstevel@tonic-gate 	aus_umount_path((caddr_t)uap->dir);
18177c478bd9Sstevel@tonic-gate 
18187c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_arg32(2, "flags", (uint32_t)uap->flags));
18197c478bd9Sstevel@tonic-gate }
18207c478bd9Sstevel@tonic-gate 
18217c478bd9Sstevel@tonic-gate static void
18227c478bd9Sstevel@tonic-gate aus_msgsys(struct t_audit_data *tad)
18237c478bd9Sstevel@tonic-gate {
18247c478bd9Sstevel@tonic-gate 	klwp_t *clwp = ttolwp(curthread);
18257c478bd9Sstevel@tonic-gate 	uint32_t msgid;
18267c478bd9Sstevel@tonic-gate 
18277c478bd9Sstevel@tonic-gate 	struct b {
18287c478bd9Sstevel@tonic-gate 		long	msgid;
18297c478bd9Sstevel@tonic-gate 		long	cmd;
18307c478bd9Sstevel@tonic-gate 		long	buf;		/* struct msqid_ds * */
18317c478bd9Sstevel@tonic-gate 	} *uap1 = (struct b *)&clwp->lwp_ap[1];
18327c478bd9Sstevel@tonic-gate 
18337c478bd9Sstevel@tonic-gate 	msgid = (uint32_t)uap1->msgid;
18347c478bd9Sstevel@tonic-gate 
18357c478bd9Sstevel@tonic-gate 
18367c478bd9Sstevel@tonic-gate 	switch (tad->tad_event) {
18377c478bd9Sstevel@tonic-gate 	case AUE_MSGGET:		/* msgget */
18387c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32(1, "msg key", msgid));
18397c478bd9Sstevel@tonic-gate 		break;
18407c478bd9Sstevel@tonic-gate 	case AUE_MSGCTL:		/* msgctl */
18417c478bd9Sstevel@tonic-gate 	case AUE_MSGCTL_RMID:		/* msgctl */
1842f158b2dfSJan Friedel 	case AUE_MSGCTL_SET:		/* msgctl */
18437c478bd9Sstevel@tonic-gate 	case AUE_MSGCTL_STAT:		/* msgctl */
18447c478bd9Sstevel@tonic-gate 	case AUE_MSGRCV:		/* msgrcv */
18457c478bd9Sstevel@tonic-gate 	case AUE_MSGSND:		/* msgsnd */
18467c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32(1, "msg ID", msgid));
18477c478bd9Sstevel@tonic-gate 		break;
18487c478bd9Sstevel@tonic-gate 	}
18497c478bd9Sstevel@tonic-gate }
18507c478bd9Sstevel@tonic-gate 
18517c478bd9Sstevel@tonic-gate /*ARGSUSED*/
18527c478bd9Sstevel@tonic-gate static void
18537c478bd9Sstevel@tonic-gate auf_msgsys(struct t_audit_data *tad, int error, rval_t *rval)
18547c478bd9Sstevel@tonic-gate {
18557c478bd9Sstevel@tonic-gate 	int id;
18567c478bd9Sstevel@tonic-gate 
18577c478bd9Sstevel@tonic-gate 	if (error != 0)
18587c478bd9Sstevel@tonic-gate 		return;
18597c478bd9Sstevel@tonic-gate 	if (tad->tad_event == AUE_MSGGET) {
18607c478bd9Sstevel@tonic-gate 		uint32_t scid;
18617c478bd9Sstevel@tonic-gate 		uint32_t sy_flags;
18627c478bd9Sstevel@tonic-gate 
18637c478bd9Sstevel@tonic-gate 		/* need to determine type of executing binary */
18647c478bd9Sstevel@tonic-gate 		scid = tad->tad_scid;
18657c478bd9Sstevel@tonic-gate #ifdef _SYSCALL32_IMPL
18667c478bd9Sstevel@tonic-gate 		if (lwp_getdatamodel(ttolwp(curthread)) == DATAMODEL_NATIVE)
18677c478bd9Sstevel@tonic-gate 			sy_flags = sysent[scid].sy_flags & SE_RVAL_MASK;
18687c478bd9Sstevel@tonic-gate 		else
18697c478bd9Sstevel@tonic-gate 			sy_flags = sysent32[scid].sy_flags & SE_RVAL_MASK;
18707c478bd9Sstevel@tonic-gate #else
18717c478bd9Sstevel@tonic-gate 		sy_flags = sysent[scid].sy_flags & SE_RVAL_MASK;
18727c478bd9Sstevel@tonic-gate #endif
18737c478bd9Sstevel@tonic-gate 		if (sy_flags == SE_32RVAL1)
18747c478bd9Sstevel@tonic-gate 			id = rval->r_val1;
18757c478bd9Sstevel@tonic-gate 		if (sy_flags == (SE_32RVAL2|SE_32RVAL1))
18767c478bd9Sstevel@tonic-gate 			id = rval->r_val1;
18777c478bd9Sstevel@tonic-gate 		if (sy_flags == SE_64RVAL)
18787c478bd9Sstevel@tonic-gate 			id = (int)rval->r_vals;
18797c478bd9Sstevel@tonic-gate 
18807c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_ipc(AT_IPC_MSG, id));
18817c478bd9Sstevel@tonic-gate 	}
18827c478bd9Sstevel@tonic-gate }
18837c478bd9Sstevel@tonic-gate 
18847c478bd9Sstevel@tonic-gate static void
18857c478bd9Sstevel@tonic-gate aus_semsys(struct t_audit_data *tad)
18867c478bd9Sstevel@tonic-gate {
18877c478bd9Sstevel@tonic-gate 	klwp_t *clwp = ttolwp(curthread);
18887c478bd9Sstevel@tonic-gate 	uint32_t semid;
18897c478bd9Sstevel@tonic-gate 
18907c478bd9Sstevel@tonic-gate 	struct b {		/* ctrl */
18917c478bd9Sstevel@tonic-gate 		long	semid;
18927c478bd9Sstevel@tonic-gate 		long	semnum;
18937c478bd9Sstevel@tonic-gate 		long	cmd;
18947c478bd9Sstevel@tonic-gate 		long	arg;
18957c478bd9Sstevel@tonic-gate 	} *uap1 = (struct b *)&clwp->lwp_ap[1];
18967c478bd9Sstevel@tonic-gate 
18977c478bd9Sstevel@tonic-gate 	semid = (uint32_t)uap1->semid;
18987c478bd9Sstevel@tonic-gate 
18997c478bd9Sstevel@tonic-gate 	switch (tad->tad_event) {
19007c478bd9Sstevel@tonic-gate 	case AUE_SEMCTL_RMID:
19017c478bd9Sstevel@tonic-gate 	case AUE_SEMCTL_STAT:
19027c478bd9Sstevel@tonic-gate 	case AUE_SEMCTL_GETNCNT:
19037c478bd9Sstevel@tonic-gate 	case AUE_SEMCTL_GETPID:
19047c478bd9Sstevel@tonic-gate 	case AUE_SEMCTL_GETVAL:
19057c478bd9Sstevel@tonic-gate 	case AUE_SEMCTL_GETALL:
19067c478bd9Sstevel@tonic-gate 	case AUE_SEMCTL_GETZCNT:
1907f158b2dfSJan Friedel 	case AUE_SEMCTL_SET:
19087c478bd9Sstevel@tonic-gate 	case AUE_SEMCTL_SETVAL:
19097c478bd9Sstevel@tonic-gate 	case AUE_SEMCTL_SETALL:
19107c478bd9Sstevel@tonic-gate 	case AUE_SEMCTL:
19117c478bd9Sstevel@tonic-gate 	case AUE_SEMOP:
19127c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32(1, "sem ID", semid));
19137c478bd9Sstevel@tonic-gate 		break;
19147c478bd9Sstevel@tonic-gate 	case AUE_SEMGET:
19157c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32(1, "sem key", semid));
19167c478bd9Sstevel@tonic-gate 		break;
19177c478bd9Sstevel@tonic-gate 	}
19187c478bd9Sstevel@tonic-gate }
19197c478bd9Sstevel@tonic-gate 
19207c478bd9Sstevel@tonic-gate /*ARGSUSED*/
19217c478bd9Sstevel@tonic-gate static void
19227c478bd9Sstevel@tonic-gate auf_semsys(struct t_audit_data *tad, int error, rval_t *rval)
19237c478bd9Sstevel@tonic-gate {
19247c478bd9Sstevel@tonic-gate 	int id;
19257c478bd9Sstevel@tonic-gate 
19267c478bd9Sstevel@tonic-gate 	if (error != 0)
19277c478bd9Sstevel@tonic-gate 		return;
19287c478bd9Sstevel@tonic-gate 	if (tad->tad_event == AUE_SEMGET) {
19297c478bd9Sstevel@tonic-gate 		uint32_t scid;
19307c478bd9Sstevel@tonic-gate 		uint32_t sy_flags;
19317c478bd9Sstevel@tonic-gate 
19327c478bd9Sstevel@tonic-gate 		/* need to determine type of executing binary */
19337c478bd9Sstevel@tonic-gate 		scid = tad->tad_scid;
19347c478bd9Sstevel@tonic-gate #ifdef _SYSCALL32_IMPL
19357c478bd9Sstevel@tonic-gate 		if (lwp_getdatamodel(ttolwp(curthread)) == DATAMODEL_NATIVE)
19367c478bd9Sstevel@tonic-gate 			sy_flags = sysent[scid].sy_flags & SE_RVAL_MASK;
19377c478bd9Sstevel@tonic-gate 		else
19387c478bd9Sstevel@tonic-gate 			sy_flags = sysent32[scid].sy_flags & SE_RVAL_MASK;
19397c478bd9Sstevel@tonic-gate #else
19407c478bd9Sstevel@tonic-gate 		sy_flags = sysent[scid].sy_flags & SE_RVAL_MASK;
19417c478bd9Sstevel@tonic-gate #endif
19427c478bd9Sstevel@tonic-gate 		if (sy_flags == SE_32RVAL1)
19437c478bd9Sstevel@tonic-gate 			id = rval->r_val1;
19447c478bd9Sstevel@tonic-gate 		if (sy_flags == (SE_32RVAL2|SE_32RVAL1))
19457c478bd9Sstevel@tonic-gate 			id = rval->r_val1;
19467c478bd9Sstevel@tonic-gate 		if (sy_flags == SE_64RVAL)
19477c478bd9Sstevel@tonic-gate 			id = (int)rval->r_vals;
19487c478bd9Sstevel@tonic-gate 
19497c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_ipc(AT_IPC_SEM, id));
19507c478bd9Sstevel@tonic-gate 	}
19517c478bd9Sstevel@tonic-gate }
19527c478bd9Sstevel@tonic-gate 
19537c478bd9Sstevel@tonic-gate /*ARGSUSED*/
19547c478bd9Sstevel@tonic-gate static void
19557c478bd9Sstevel@tonic-gate aus_close(struct t_audit_data *tad)
19567c478bd9Sstevel@tonic-gate {
19577c478bd9Sstevel@tonic-gate 	klwp_t *clwp = ttolwp(curthread);
19587c478bd9Sstevel@tonic-gate 	uint32_t fd;
19597c478bd9Sstevel@tonic-gate 	struct file *fp;
19607c478bd9Sstevel@tonic-gate 	struct f_audit_data *fad;
19617c478bd9Sstevel@tonic-gate 	struct vnode *vp;
19627c478bd9Sstevel@tonic-gate 	struct vattr attr;
19639e9e6ab8Spaulson 	au_kcontext_t	*kctx = GET_KCTX_PZ;
19647c478bd9Sstevel@tonic-gate 
19657c478bd9Sstevel@tonic-gate 	struct a {
19667c478bd9Sstevel@tonic-gate 		long	i;
19677c478bd9Sstevel@tonic-gate 	} *uap = (struct a *)clwp->lwp_ap;
19687c478bd9Sstevel@tonic-gate 
19697c478bd9Sstevel@tonic-gate 	fd = (uint32_t)uap->i;
19707c478bd9Sstevel@tonic-gate 
19717c478bd9Sstevel@tonic-gate 	attr.va_mask = 0;
19727c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_arg32(1, "fd", fd));
19737c478bd9Sstevel@tonic-gate 
19747c478bd9Sstevel@tonic-gate 		/*
19757c478bd9Sstevel@tonic-gate 		 * convert file pointer to file descriptor
19767c478bd9Sstevel@tonic-gate 		 *   Note: fd ref count incremented here.
19777c478bd9Sstevel@tonic-gate 		 */
19787c478bd9Sstevel@tonic-gate 	if ((fp = getf(fd)) == NULL)
19797c478bd9Sstevel@tonic-gate 		return;
19807c478bd9Sstevel@tonic-gate 
19817c478bd9Sstevel@tonic-gate 	fad = F2A(fp);
1982d0fa49b7STony Nguyen 	tad->tad_evmod = (au_emod_t)fad->fad_flags;
19837c478bd9Sstevel@tonic-gate 	if (fad->fad_aupath != NULL) {
19847c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_path(fad->fad_aupath));
19857c478bd9Sstevel@tonic-gate 		if ((vp = fp->f_vnode) != NULL) {
19867c478bd9Sstevel@tonic-gate 			attr.va_mask = AT_ALL;
1987da6c28aaSamw 			if (VOP_GETATTR(vp, &attr, 0, CRED(), NULL) == 0) {
19887c478bd9Sstevel@tonic-gate 				/*
19897c478bd9Sstevel@tonic-gate 				 * When write was not used and the file can be
19907c478bd9Sstevel@tonic-gate 				 * considered public, skip the audit.
19917c478bd9Sstevel@tonic-gate 				 */
19927c478bd9Sstevel@tonic-gate 				if (((fp->f_flag & FWRITE) == 0) &&
19934a0fa546SMarek Pospisil 				    object_is_public(&attr)) {
19947c478bd9Sstevel@tonic-gate 					tad->tad_flag = 0;
19957c478bd9Sstevel@tonic-gate 					tad->tad_evmod = 0;
19967c478bd9Sstevel@tonic-gate 					/* free any residual audit data */
1997005d3febSMarek Pospisil 					au_close(kctx, &(u_ad), 0, 0, 0, NULL);
19987c478bd9Sstevel@tonic-gate 					releasef(fd);
19997c478bd9Sstevel@tonic-gate 					return;
20007c478bd9Sstevel@tonic-gate 				}
200145916cd2Sjpk 				au_uwrite(au_to_attr(&attr));
200245916cd2Sjpk 				audit_sec_attributes(&(u_ad), vp);
20037c478bd9Sstevel@tonic-gate 			}
20047c478bd9Sstevel@tonic-gate 		}
20057c478bd9Sstevel@tonic-gate 	}
20067c478bd9Sstevel@tonic-gate 
20077c478bd9Sstevel@tonic-gate 	/* decrement file descriptor reference count */
20087c478bd9Sstevel@tonic-gate 	releasef(fd);
20097c478bd9Sstevel@tonic-gate }
20107c478bd9Sstevel@tonic-gate 
20117c478bd9Sstevel@tonic-gate /*ARGSUSED*/
20127c478bd9Sstevel@tonic-gate static void
20137c478bd9Sstevel@tonic-gate aus_fstatfs(struct t_audit_data *tad)
20147c478bd9Sstevel@tonic-gate {
20157c478bd9Sstevel@tonic-gate 	klwp_t *clwp = ttolwp(curthread);
20167c478bd9Sstevel@tonic-gate 	uint32_t fd;
20177c478bd9Sstevel@tonic-gate 	struct file  *fp;
20187c478bd9Sstevel@tonic-gate 	struct vnode *vp;
20197c478bd9Sstevel@tonic-gate 	struct f_audit_data *fad;
20207c478bd9Sstevel@tonic-gate 
20217c478bd9Sstevel@tonic-gate 	struct a {
20227c478bd9Sstevel@tonic-gate 		long	fd;
20237c478bd9Sstevel@tonic-gate 		long	buf;		/* struct statfs * */
20247c478bd9Sstevel@tonic-gate 	} *uap = (struct a *)clwp->lwp_ap;
20257c478bd9Sstevel@tonic-gate 
20267c478bd9Sstevel@tonic-gate 	fd = (uint_t)uap->fd;
20277c478bd9Sstevel@tonic-gate 
20287c478bd9Sstevel@tonic-gate 		/*
20297c478bd9Sstevel@tonic-gate 		 * convert file pointer to file descriptor
20307c478bd9Sstevel@tonic-gate 		 *   Note: fd ref count incremented here.
20317c478bd9Sstevel@tonic-gate 		 */
20327c478bd9Sstevel@tonic-gate 	if ((fp = getf(fd)) == NULL)
20337c478bd9Sstevel@tonic-gate 		return;
20347c478bd9Sstevel@tonic-gate 
20357c478bd9Sstevel@tonic-gate 		/* get path from file struct here */
20367c478bd9Sstevel@tonic-gate 	fad = F2A(fp);
20377c478bd9Sstevel@tonic-gate 	if (fad->fad_aupath != NULL) {
20387c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_path(fad->fad_aupath));
20397c478bd9Sstevel@tonic-gate 	} else {
20407c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32(1, "no path: fd", fd));
20417c478bd9Sstevel@tonic-gate 	}
20427c478bd9Sstevel@tonic-gate 
20437c478bd9Sstevel@tonic-gate 	vp = fp->f_vnode;
20447c478bd9Sstevel@tonic-gate 	audit_attributes(vp);
20457c478bd9Sstevel@tonic-gate 
20467c478bd9Sstevel@tonic-gate 	/* decrement file descriptor reference count */
20477c478bd9Sstevel@tonic-gate 	releasef(fd);
20487c478bd9Sstevel@tonic-gate }
20497c478bd9Sstevel@tonic-gate 
20504be8c573SJan Friedel static au_event_t
20514be8c573SJan Friedel aui_setpgrp(au_event_t e)
20524be8c573SJan Friedel {
20534be8c573SJan Friedel 	klwp_t *clwp = ttolwp(curthread);
20544be8c573SJan Friedel 	int flag;
20554be8c573SJan Friedel 
20564be8c573SJan Friedel 	struct a {
20574be8c573SJan Friedel 		long	flag;
20584be8c573SJan Friedel 		long	pid;
20594be8c573SJan Friedel 		long	pgid;
20604be8c573SJan Friedel 	} *uap = (struct a *)clwp->lwp_ap;
20614be8c573SJan Friedel 
20624be8c573SJan Friedel 	flag = (int)uap->flag;
20634be8c573SJan Friedel 
20644be8c573SJan Friedel 
20654be8c573SJan Friedel 	switch (flag) {
20664be8c573SJan Friedel 
20674be8c573SJan Friedel 	case 1:	/* setpgrp() */
20684be8c573SJan Friedel 		e = AUE_SETPGRP;
20694be8c573SJan Friedel 		break;
20704be8c573SJan Friedel 
20714be8c573SJan Friedel 	case 3: /* setsid() */
20724be8c573SJan Friedel 		e = AUE_SETSID;
20734be8c573SJan Friedel 		break;
20744be8c573SJan Friedel 
20754be8c573SJan Friedel 	case 5: /* setpgid() */
20764be8c573SJan Friedel 		e = AUE_SETPGID;
20774be8c573SJan Friedel 		break;
20784be8c573SJan Friedel 
20794be8c573SJan Friedel 	case 0: /* getpgrp()	- not security relevant */
20804be8c573SJan Friedel 	case 2: /* getsid()	- not security relevant */
20814be8c573SJan Friedel 	case 4: /* getpgid() 	- not security relevant */
20824be8c573SJan Friedel 		e = AUE_NULL;
20834be8c573SJan Friedel 		break;
20844be8c573SJan Friedel 
20854be8c573SJan Friedel 	default:
20864be8c573SJan Friedel 		e = AUE_NULL;
20874be8c573SJan Friedel 		break;
20884be8c573SJan Friedel 	}
20894be8c573SJan Friedel 
20904be8c573SJan Friedel 	return (e);
20914be8c573SJan Friedel }
20924be8c573SJan Friedel 
209345a9a7b1SJan Friedel /*ARGSUSED*/
20947c478bd9Sstevel@tonic-gate static void
20957c478bd9Sstevel@tonic-gate aus_setpgrp(struct t_audit_data *tad)
20967c478bd9Sstevel@tonic-gate {
20974be8c573SJan Friedel 	klwp_t		*clwp = ttolwp(curthread);
20984be8c573SJan Friedel 	pid_t		pgid;
20994be8c573SJan Friedel 	struct proc	*p;
21004be8c573SJan Friedel 	uid_t		uid, ruid;
21014be8c573SJan Friedel 	gid_t		gid, rgid;
21024be8c573SJan Friedel 	pid_t		pid;
21034be8c573SJan Friedel 	cred_t		*cr;
21044be8c573SJan Friedel 	int		flag;
21054be8c573SJan Friedel 	const auditinfo_addr_t	*ainfo;
21067c478bd9Sstevel@tonic-gate 
21077c478bd9Sstevel@tonic-gate 	struct a {
21084be8c573SJan Friedel 		long	flag;
21097c478bd9Sstevel@tonic-gate 		long	pid;
21104be8c573SJan Friedel 		long	pgid;
21117c478bd9Sstevel@tonic-gate 	} *uap = (struct a *)clwp->lwp_ap;
21127c478bd9Sstevel@tonic-gate 
21134be8c573SJan Friedel 	flag = (int)uap->flag;
21147c478bd9Sstevel@tonic-gate 	pid  = (pid_t)uap->pid;
21154be8c573SJan Friedel 	pgid = (pid_t)uap->pgid;
21164be8c573SJan Friedel 
21174be8c573SJan Friedel 
21184be8c573SJan Friedel 	switch (flag) {
21194be8c573SJan Friedel 
21204be8c573SJan Friedel 	case 0: /* getpgrp() */
21214be8c573SJan Friedel 	case 1: /* setpgrp() */
21224be8c573SJan Friedel 	case 2: /* getsid() */
21234be8c573SJan Friedel 	case 3: /* setsid() */
21244be8c573SJan Friedel 	case 4: /* getpgid() */
21254be8c573SJan Friedel 		break;
21264be8c573SJan Friedel 
21274be8c573SJan Friedel 	case 5: /* setpgid() */
21287c478bd9Sstevel@tonic-gate 
21297c478bd9Sstevel@tonic-gate 		/* current process? */
21304be8c573SJan Friedel 		if (pid == 0) {
21314be8c573SJan Friedel 			return;
21324be8c573SJan Friedel 		}
21337c478bd9Sstevel@tonic-gate 
21344be8c573SJan Friedel 		mutex_enter(&pidlock);
21354be8c573SJan Friedel 		p = prfind(pid);
21364be8c573SJan Friedel 		if (p == NULL || p->p_as == &kas ||
21374be8c573SJan Friedel 		    p->p_stat == SIDL || p->p_stat == SZOMB) {
21384be8c573SJan Friedel 			mutex_exit(&pidlock);
21394be8c573SJan Friedel 			return;
21404be8c573SJan Friedel 		}
21414be8c573SJan Friedel 		mutex_enter(&p->p_lock);	/* so process doesn't go away */
21427c478bd9Sstevel@tonic-gate 		mutex_exit(&pidlock);
21437c478bd9Sstevel@tonic-gate 
21444be8c573SJan Friedel 		mutex_enter(&p->p_crlock);
21454be8c573SJan Friedel 		crhold(cr = p->p_cred);
21464be8c573SJan Friedel 		mutex_exit(&p->p_crlock);
21474be8c573SJan Friedel 		mutex_exit(&p->p_lock);
21484be8c573SJan Friedel 
21494be8c573SJan Friedel 		ainfo = crgetauinfo(cr);
21504be8c573SJan Friedel 		if (ainfo == NULL) {
21514be8c573SJan Friedel 			crfree(cr);
21524be8c573SJan Friedel 			return;
21534be8c573SJan Friedel 		}
21547c478bd9Sstevel@tonic-gate 
21554be8c573SJan Friedel 		uid  = crgetuid(cr);
21564be8c573SJan Friedel 		gid  = crgetgid(cr);
21574be8c573SJan Friedel 		ruid = crgetruid(cr);
21584be8c573SJan Friedel 		rgid = crgetrgid(cr);
21594be8c573SJan Friedel 		au_uwrite(au_to_process(uid, gid, ruid, rgid, pid,
21604be8c573SJan Friedel 		    ainfo->ai_auid, ainfo->ai_asid, &ainfo->ai_termid));
21617c478bd9Sstevel@tonic-gate 		crfree(cr);
21624be8c573SJan Friedel 		au_uwrite(au_to_arg32(2, "pgid", pgid));
21634be8c573SJan Friedel 		break;
21647c478bd9Sstevel@tonic-gate 
21654be8c573SJan Friedel 	default:
21664be8c573SJan Friedel 		break;
21674be8c573SJan Friedel 	}
21687c478bd9Sstevel@tonic-gate }
21694be8c573SJan Friedel 
21707c478bd9Sstevel@tonic-gate 
21717c478bd9Sstevel@tonic-gate /*ARGSUSED*/
21727c478bd9Sstevel@tonic-gate static void
21737c478bd9Sstevel@tonic-gate aus_setregid(struct t_audit_data *tad)
21747c478bd9Sstevel@tonic-gate {
21757c478bd9Sstevel@tonic-gate 	klwp_t *clwp = ttolwp(curthread);
21767c478bd9Sstevel@tonic-gate 	uint32_t rgid, egid;
21777c478bd9Sstevel@tonic-gate 
21787c478bd9Sstevel@tonic-gate 	struct a {
21797c478bd9Sstevel@tonic-gate 		long	 rgid;
21807c478bd9Sstevel@tonic-gate 		long	 egid;
21817c478bd9Sstevel@tonic-gate 	} *uap = (struct a *)clwp->lwp_ap;
21827c478bd9Sstevel@tonic-gate 
21837c478bd9Sstevel@tonic-gate 	rgid  = (uint32_t)uap->rgid;
21847c478bd9Sstevel@tonic-gate 	egid  = (uint32_t)uap->egid;
21857c478bd9Sstevel@tonic-gate 
21867c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_arg32(1, "rgid", rgid));
21877c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_arg32(2, "egid", egid));
21887c478bd9Sstevel@tonic-gate }
21897c478bd9Sstevel@tonic-gate 
21907c478bd9Sstevel@tonic-gate /*ARGSUSED*/
21917c478bd9Sstevel@tonic-gate static void
21927c478bd9Sstevel@tonic-gate aus_setgid(struct t_audit_data *tad)
21937c478bd9Sstevel@tonic-gate {
21947c478bd9Sstevel@tonic-gate 	klwp_t *clwp = ttolwp(curthread);
21957c478bd9Sstevel@tonic-gate 	uint32_t gid;
21967c478bd9Sstevel@tonic-gate 
21977c478bd9Sstevel@tonic-gate 	struct a {
21987c478bd9Sstevel@tonic-gate 		long	gid;
21997c478bd9Sstevel@tonic-gate 	} *uap = (struct a *)clwp->lwp_ap;
22007c478bd9Sstevel@tonic-gate 
22017c478bd9Sstevel@tonic-gate 	gid = (uint32_t)uap->gid;
22027c478bd9Sstevel@tonic-gate 
22037c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_arg32(1, "gid", gid));
22047c478bd9Sstevel@tonic-gate }
22057c478bd9Sstevel@tonic-gate 
22067c478bd9Sstevel@tonic-gate 
22077c478bd9Sstevel@tonic-gate /*ARGSUSED*/
22087c478bd9Sstevel@tonic-gate static void
22097c478bd9Sstevel@tonic-gate aus_setreuid(struct t_audit_data *tad)
22107c478bd9Sstevel@tonic-gate {
22117c478bd9Sstevel@tonic-gate 	klwp_t *clwp = ttolwp(curthread);
22127c478bd9Sstevel@tonic-gate 	uint32_t ruid, euid;
22137c478bd9Sstevel@tonic-gate 
22147c478bd9Sstevel@tonic-gate 	struct a {
22157c478bd9Sstevel@tonic-gate 		long	ruid;
22167c478bd9Sstevel@tonic-gate 		long	euid;
22177c478bd9Sstevel@tonic-gate 	} *uap = (struct a *)clwp->lwp_ap;
22187c478bd9Sstevel@tonic-gate 
22197c478bd9Sstevel@tonic-gate 	ruid = (uint32_t)uap->ruid;
22207c478bd9Sstevel@tonic-gate 	euid  = (uint32_t)uap->euid;
22217c478bd9Sstevel@tonic-gate 
22227c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_arg32(1, "ruid", ruid));
22237c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_arg32(2, "euid", euid));
22247c478bd9Sstevel@tonic-gate }
22257c478bd9Sstevel@tonic-gate 
22267c478bd9Sstevel@tonic-gate 
22277c478bd9Sstevel@tonic-gate /*ARGSUSED*/
22287c478bd9Sstevel@tonic-gate static void
22297c478bd9Sstevel@tonic-gate aus_setuid(struct t_audit_data *tad)
22307c478bd9Sstevel@tonic-gate {
22317c478bd9Sstevel@tonic-gate 	klwp_t *clwp = ttolwp(curthread);
22327c478bd9Sstevel@tonic-gate 	uint32_t uid;
22337c478bd9Sstevel@tonic-gate 
22347c478bd9Sstevel@tonic-gate 	struct a {
22357c478bd9Sstevel@tonic-gate 		long	uid;
22367c478bd9Sstevel@tonic-gate 	} *uap = (struct a *)clwp->lwp_ap;
22377c478bd9Sstevel@tonic-gate 
22387c478bd9Sstevel@tonic-gate 	uid = (uint32_t)uap->uid;
22397c478bd9Sstevel@tonic-gate 
22407c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_arg32(1, "uid", uid));
22417c478bd9Sstevel@tonic-gate }
22427c478bd9Sstevel@tonic-gate 
22437c478bd9Sstevel@tonic-gate /*ARGSUSED*/
22447c478bd9Sstevel@tonic-gate static void
22457c478bd9Sstevel@tonic-gate aus_shmsys(struct t_audit_data *tad)
22467c478bd9Sstevel@tonic-gate {
22477c478bd9Sstevel@tonic-gate 	klwp_t *clwp = ttolwp(curthread);
22487c478bd9Sstevel@tonic-gate 	uint32_t id, cmd;
22497c478bd9Sstevel@tonic-gate 
22507c478bd9Sstevel@tonic-gate 	struct b {
22517c478bd9Sstevel@tonic-gate 		long	id;
22527c478bd9Sstevel@tonic-gate 		long	cmd;
22537c478bd9Sstevel@tonic-gate 		long	buf;		/* struct shmid_ds * */
22547c478bd9Sstevel@tonic-gate 	} *uap1 = (struct b *)&clwp->lwp_ap[1];
22557c478bd9Sstevel@tonic-gate 
22567c478bd9Sstevel@tonic-gate 	id  = (uint32_t)uap1->id;
22577c478bd9Sstevel@tonic-gate 	cmd = (uint32_t)uap1->cmd;
22587c478bd9Sstevel@tonic-gate 
22597c478bd9Sstevel@tonic-gate 	switch (tad->tad_event) {
22607c478bd9Sstevel@tonic-gate 	case AUE_SHMGET:			/* shmget */
22617c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32(1, "shm key", id));
22627c478bd9Sstevel@tonic-gate 		break;
22637c478bd9Sstevel@tonic-gate 	case AUE_SHMCTL:			/* shmctl */
22647c478bd9Sstevel@tonic-gate 	case AUE_SHMCTL_RMID:			/* shmctl */
22657c478bd9Sstevel@tonic-gate 	case AUE_SHMCTL_STAT:			/* shmctl */
22667c478bd9Sstevel@tonic-gate 	case AUE_SHMCTL_SET:			/* shmctl */
22677c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32(1, "shm ID", id));
22687c478bd9Sstevel@tonic-gate 		break;
22697c478bd9Sstevel@tonic-gate 	case AUE_SHMDT:				/* shmdt */
22707c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32(1, "shm adr", id));
22717c478bd9Sstevel@tonic-gate 		break;
22727c478bd9Sstevel@tonic-gate 	case AUE_SHMAT:				/* shmat */
22737c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32(1, "shm ID", id));
22747c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32(2, "shm adr", cmd));
22757c478bd9Sstevel@tonic-gate 		break;
22767c478bd9Sstevel@tonic-gate 	}
22777c478bd9Sstevel@tonic-gate }
22787c478bd9Sstevel@tonic-gate 
22797c478bd9Sstevel@tonic-gate /*ARGSUSED*/
22807c478bd9Sstevel@tonic-gate static void
22817c478bd9Sstevel@tonic-gate auf_shmsys(struct t_audit_data *tad, int error, rval_t *rval)
22827c478bd9Sstevel@tonic-gate {
22837c478bd9Sstevel@tonic-gate 	int id;
22847c478bd9Sstevel@tonic-gate 
22857c478bd9Sstevel@tonic-gate 	if (error != 0)
22867c478bd9Sstevel@tonic-gate 		return;
22877c478bd9Sstevel@tonic-gate 	if (tad->tad_event == AUE_SHMGET) {
22887c478bd9Sstevel@tonic-gate 		uint32_t scid;
22897c478bd9Sstevel@tonic-gate 		uint32_t sy_flags;
22907c478bd9Sstevel@tonic-gate 
22917c478bd9Sstevel@tonic-gate 		/* need to determine type of executing binary */
22927c478bd9Sstevel@tonic-gate 		scid = tad->tad_scid;
22937c478bd9Sstevel@tonic-gate #ifdef _SYSCALL32_IMPL
22947c478bd9Sstevel@tonic-gate 		if (lwp_getdatamodel(ttolwp(curthread)) == DATAMODEL_NATIVE)
22957c478bd9Sstevel@tonic-gate 			sy_flags = sysent[scid].sy_flags & SE_RVAL_MASK;
22967c478bd9Sstevel@tonic-gate 		else
22977c478bd9Sstevel@tonic-gate 			sy_flags = sysent32[scid].sy_flags & SE_RVAL_MASK;
22987c478bd9Sstevel@tonic-gate #else
22997c478bd9Sstevel@tonic-gate 		sy_flags = sysent[scid].sy_flags & SE_RVAL_MASK;
23007c478bd9Sstevel@tonic-gate #endif
23017c478bd9Sstevel@tonic-gate 		if (sy_flags == SE_32RVAL1)
23027c478bd9Sstevel@tonic-gate 			id = rval->r_val1;
23037c478bd9Sstevel@tonic-gate 		if (sy_flags == (SE_32RVAL2|SE_32RVAL1))
23047c478bd9Sstevel@tonic-gate 			id = rval->r_val1;
23057c478bd9Sstevel@tonic-gate 		if (sy_flags == SE_64RVAL)
23067c478bd9Sstevel@tonic-gate 			id = (int)rval->r_vals;
23077c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_ipc(AT_IPC_SHM, id));
23087c478bd9Sstevel@tonic-gate 	}
23097c478bd9Sstevel@tonic-gate }
23107c478bd9Sstevel@tonic-gate 
23117c478bd9Sstevel@tonic-gate 
23127c478bd9Sstevel@tonic-gate /*ARGSUSED*/
23137c478bd9Sstevel@tonic-gate static void
23147c478bd9Sstevel@tonic-gate aus_ioctl(struct t_audit_data *tad)
23157c478bd9Sstevel@tonic-gate {
23167c478bd9Sstevel@tonic-gate 	klwp_t *clwp = ttolwp(curthread);
23177c478bd9Sstevel@tonic-gate 	struct file *fp;
23187c478bd9Sstevel@tonic-gate 	struct vnode *vp;
23197c478bd9Sstevel@tonic-gate 	struct f_audit_data *fad;
23207c478bd9Sstevel@tonic-gate 	uint32_t fd, cmd;
23217c478bd9Sstevel@tonic-gate 	uintptr_t cmarg;
23227c478bd9Sstevel@tonic-gate 
23237c478bd9Sstevel@tonic-gate 	/* XX64 */
23247c478bd9Sstevel@tonic-gate 	struct a {
23257c478bd9Sstevel@tonic-gate 		long	fd;
23267c478bd9Sstevel@tonic-gate 		long	cmd;
23277c478bd9Sstevel@tonic-gate 		long	cmarg;		/* caddr_t */
23287c478bd9Sstevel@tonic-gate 	} *uap = (struct a *)clwp->lwp_ap;
23297c478bd9Sstevel@tonic-gate 
23307c478bd9Sstevel@tonic-gate 	fd    = (uint32_t)uap->fd;
23317c478bd9Sstevel@tonic-gate 	cmd   = (uint32_t)uap->cmd;
23327c478bd9Sstevel@tonic-gate 	cmarg = (uintptr_t)uap->cmarg;
23337c478bd9Sstevel@tonic-gate 
23347c478bd9Sstevel@tonic-gate 		/*
23357c478bd9Sstevel@tonic-gate 		 * convert file pointer to file descriptor
23367c478bd9Sstevel@tonic-gate 		 *   Note: fd ref count incremented here.
23377c478bd9Sstevel@tonic-gate 		 */
23387c478bd9Sstevel@tonic-gate 	if ((fp = getf(fd)) == NULL) {
23397c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32(1, "fd", fd));
23407c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32(2, "cmd", cmd));
23417c478bd9Sstevel@tonic-gate #ifndef _LP64
23427c478bd9Sstevel@tonic-gate 			au_uwrite(au_to_arg32(3, "arg", (uint32_t)cmarg));
23437c478bd9Sstevel@tonic-gate #else
23447c478bd9Sstevel@tonic-gate 			au_uwrite(au_to_arg64(3, "arg", (uint64_t)cmarg));
23457c478bd9Sstevel@tonic-gate #endif
23467c478bd9Sstevel@tonic-gate 		return;
23477c478bd9Sstevel@tonic-gate 	}
23487c478bd9Sstevel@tonic-gate 
23497c478bd9Sstevel@tonic-gate 	/* get path from file struct here */
23507c478bd9Sstevel@tonic-gate 	fad = F2A(fp);
23517c478bd9Sstevel@tonic-gate 	if (fad->fad_aupath != NULL) {
23527c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_path(fad->fad_aupath));
23537c478bd9Sstevel@tonic-gate 	} else {
23547c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32(1, "no path: fd", fd));
23557c478bd9Sstevel@tonic-gate 	}
23567c478bd9Sstevel@tonic-gate 
23577c478bd9Sstevel@tonic-gate 	vp = fp->f_vnode;
23587c478bd9Sstevel@tonic-gate 	audit_attributes(vp);
23597c478bd9Sstevel@tonic-gate 
23607c478bd9Sstevel@tonic-gate 	/* decrement file descriptor reference count */
23617c478bd9Sstevel@tonic-gate 	releasef(fd);
23627c478bd9Sstevel@tonic-gate 
23637c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_arg32(2, "cmd", cmd));
23647c478bd9Sstevel@tonic-gate #ifndef _LP64
23657c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32(3, "arg", (uint32_t)cmarg));
23667c478bd9Sstevel@tonic-gate #else
23677c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg64(3, "arg", (uint64_t)cmarg));
23687c478bd9Sstevel@tonic-gate #endif
23697c478bd9Sstevel@tonic-gate }
23707c478bd9Sstevel@tonic-gate 
23717c478bd9Sstevel@tonic-gate /*
23727c478bd9Sstevel@tonic-gate  * null function for memcntl for now. We might want to limit memcntl()
23737c478bd9Sstevel@tonic-gate  * auditing to commands: MC_LOCKAS, MC_LOCK, MC_UNLOCKAS, MC_UNLOCK which
23747c478bd9Sstevel@tonic-gate  * require privileges.
23757c478bd9Sstevel@tonic-gate  */
23767c478bd9Sstevel@tonic-gate static au_event_t
23777c478bd9Sstevel@tonic-gate aui_memcntl(au_event_t e)
23787c478bd9Sstevel@tonic-gate {
23797c478bd9Sstevel@tonic-gate 	return (e);
23807c478bd9Sstevel@tonic-gate }
23817c478bd9Sstevel@tonic-gate 
23827c478bd9Sstevel@tonic-gate /*ARGSUSED*/
23837c478bd9Sstevel@tonic-gate static au_event_t
23847c478bd9Sstevel@tonic-gate aui_privsys(au_event_t e)
23857c478bd9Sstevel@tonic-gate {
23867c478bd9Sstevel@tonic-gate 	klwp_t *clwp = ttolwp(curthread);
23877c478bd9Sstevel@tonic-gate 
23887c478bd9Sstevel@tonic-gate 	struct a {
23897c478bd9Sstevel@tonic-gate 		long	opcode;
23907c478bd9Sstevel@tonic-gate 	} *uap = (struct a *)clwp->lwp_ap;
23917c478bd9Sstevel@tonic-gate 
23927c478bd9Sstevel@tonic-gate 	switch (uap->opcode) {
23937c478bd9Sstevel@tonic-gate 	case PRIVSYS_SETPPRIV:
23947c478bd9Sstevel@tonic-gate 		return (AUE_SETPPRIV);
23957c478bd9Sstevel@tonic-gate 	default:
23967c478bd9Sstevel@tonic-gate 		return (AUE_NULL);
23977c478bd9Sstevel@tonic-gate 	}
23987c478bd9Sstevel@tonic-gate }
23997c478bd9Sstevel@tonic-gate 
24007c478bd9Sstevel@tonic-gate /*ARGSUSED*/
24017c478bd9Sstevel@tonic-gate static void
24027c478bd9Sstevel@tonic-gate aus_memcntl(struct t_audit_data *tad)
24037c478bd9Sstevel@tonic-gate {
24047c478bd9Sstevel@tonic-gate 	klwp_t *clwp = ttolwp(curthread);
24057c478bd9Sstevel@tonic-gate 
24067c478bd9Sstevel@tonic-gate 	struct a {
24077c478bd9Sstevel@tonic-gate 		long	addr;
24087c478bd9Sstevel@tonic-gate 		long	len;
24097c478bd9Sstevel@tonic-gate 		long	cmd;
24107c478bd9Sstevel@tonic-gate 		long	arg;
24117c478bd9Sstevel@tonic-gate 		long	attr;
24127c478bd9Sstevel@tonic-gate 		long	mask;
24137c478bd9Sstevel@tonic-gate 	} *uap = (struct a *)clwp->lwp_ap;
24147c478bd9Sstevel@tonic-gate 
24157c478bd9Sstevel@tonic-gate #ifdef _LP64
24167c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_arg64(1, "base", (uint64_t)uap->addr));
24177c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_arg64(2, "len", (uint64_t)uap->len));
24187c478bd9Sstevel@tonic-gate #else
24197c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_arg32(1, "base", (uint32_t)uap->addr));
24207c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_arg32(2, "len", (uint32_t)uap->len));
24217c478bd9Sstevel@tonic-gate #endif
24227c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_arg32(3, "cmd", (uint_t)uap->cmd));
24237c478bd9Sstevel@tonic-gate #ifdef _LP64
24247c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_arg64(4, "arg", (uint64_t)uap->arg));
24257c478bd9Sstevel@tonic-gate #else
24267c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_arg32(4, "arg", (uint32_t)uap->arg));
24277c478bd9Sstevel@tonic-gate #endif
24287c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_arg32(5, "attr", (uint_t)uap->attr));
24297c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_arg32(6, "mask", (uint_t)uap->mask));
24307c478bd9Sstevel@tonic-gate }
24317c478bd9Sstevel@tonic-gate 
24327c478bd9Sstevel@tonic-gate /*ARGSUSED*/
24337c478bd9Sstevel@tonic-gate static void
24347c478bd9Sstevel@tonic-gate aus_mmap(struct t_audit_data *tad)
24357c478bd9Sstevel@tonic-gate {
24367c478bd9Sstevel@tonic-gate 	klwp_t *clwp = ttolwp(curthread);
24377c478bd9Sstevel@tonic-gate 	struct file *fp;
24387c478bd9Sstevel@tonic-gate 	struct f_audit_data *fad;
24397c478bd9Sstevel@tonic-gate 	struct vnode *vp;
24407c478bd9Sstevel@tonic-gate 	uint32_t fd;
24417c478bd9Sstevel@tonic-gate 
24427c478bd9Sstevel@tonic-gate 	struct a {
24437c478bd9Sstevel@tonic-gate 		long	addr;
24447c478bd9Sstevel@tonic-gate 		long	len;
24457c478bd9Sstevel@tonic-gate 		long	prot;
24467c478bd9Sstevel@tonic-gate 		long	flags;
24477c478bd9Sstevel@tonic-gate 		long	fd;
24487c478bd9Sstevel@tonic-gate 		long	pos;
24497c478bd9Sstevel@tonic-gate 	} *uap = (struct a *)clwp->lwp_ap;
24507c478bd9Sstevel@tonic-gate 
24517c478bd9Sstevel@tonic-gate 	fd = (uint32_t)uap->fd;
24527c478bd9Sstevel@tonic-gate 
24537c478bd9Sstevel@tonic-gate #ifdef _LP64
24547c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_arg64(1, "addr", (uint64_t)uap->addr));
24557c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_arg64(2, "len", (uint64_t)uap->len));
24567c478bd9Sstevel@tonic-gate #else
24577c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_arg32(1, "addr", (uint32_t)uap->addr));
24587c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_arg32(2, "len", (uint32_t)uap->len));
24597c478bd9Sstevel@tonic-gate #endif
24607c478bd9Sstevel@tonic-gate 
24617c478bd9Sstevel@tonic-gate 	if ((fp = getf(fd)) == NULL) {
24627c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32(5, "fd", (uint32_t)uap->fd));
24637c478bd9Sstevel@tonic-gate 		return;
24647c478bd9Sstevel@tonic-gate 	}
24657c478bd9Sstevel@tonic-gate 
24667c478bd9Sstevel@tonic-gate 	/*
24677c478bd9Sstevel@tonic-gate 	 * Mark in the tad if write access is NOT requested... if
24687c478bd9Sstevel@tonic-gate 	 * this is later detected (in audit_attributes) to be a
24697c478bd9Sstevel@tonic-gate 	 * public object, the mmap event may be discarded.
24707c478bd9Sstevel@tonic-gate 	 */
24717c478bd9Sstevel@tonic-gate 	if (((uap->prot) & PROT_WRITE) == 0) {
24724a0fa546SMarek Pospisil 		tad->tad_ctrl |= TAD_PUBLIC_EV;
24737c478bd9Sstevel@tonic-gate 	}
24747c478bd9Sstevel@tonic-gate 
24757c478bd9Sstevel@tonic-gate 	fad = F2A(fp);
24767c478bd9Sstevel@tonic-gate 	if (fad->fad_aupath != NULL) {
24777c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_path(fad->fad_aupath));
24787c478bd9Sstevel@tonic-gate 	} else {
24797c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32(1, "no path: fd", fd));
24807c478bd9Sstevel@tonic-gate 	}
24817c478bd9Sstevel@tonic-gate 
24827c478bd9Sstevel@tonic-gate 	vp = (struct vnode *)fp->f_vnode;
24837c478bd9Sstevel@tonic-gate 	audit_attributes(vp);
24847c478bd9Sstevel@tonic-gate 
24857c478bd9Sstevel@tonic-gate 	/* mark READ/WRITE since we can't predict access */
24867c478bd9Sstevel@tonic-gate 	if (uap->prot & PROT_READ)
24877c478bd9Sstevel@tonic-gate 		fad->fad_flags |= FAD_READ;
24887c478bd9Sstevel@tonic-gate 	if (uap->prot & PROT_WRITE)
24897c478bd9Sstevel@tonic-gate 		fad->fad_flags |= FAD_WRITE;
24907c478bd9Sstevel@tonic-gate 
24917c478bd9Sstevel@tonic-gate 	/* decrement file descriptor reference count */
24927c478bd9Sstevel@tonic-gate 	releasef(fd);
24937c478bd9Sstevel@tonic-gate 
24947c478bd9Sstevel@tonic-gate }	/* AUS_MMAP */
24957c478bd9Sstevel@tonic-gate 
24967c478bd9Sstevel@tonic-gate 
24977c478bd9Sstevel@tonic-gate 
24987c478bd9Sstevel@tonic-gate 
24997c478bd9Sstevel@tonic-gate /*ARGSUSED*/
25007c478bd9Sstevel@tonic-gate static void
25017c478bd9Sstevel@tonic-gate aus_munmap(struct t_audit_data *tad)
25027c478bd9Sstevel@tonic-gate {
25037c478bd9Sstevel@tonic-gate 	klwp_t *clwp = ttolwp(curthread);
25047c478bd9Sstevel@tonic-gate 
25057c478bd9Sstevel@tonic-gate 	struct a {
25067c478bd9Sstevel@tonic-gate 		long	addr;
25077c478bd9Sstevel@tonic-gate 		long	len;
25087c478bd9Sstevel@tonic-gate 	} *uap = (struct a *)clwp->lwp_ap;
25097c478bd9Sstevel@tonic-gate 
25107c478bd9Sstevel@tonic-gate #ifdef _LP64
25117c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_arg64(1, "addr", (uint64_t)uap->addr));
25127c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_arg64(2, "len", (uint64_t)uap->len));
25137c478bd9Sstevel@tonic-gate #else
25147c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_arg32(1, "addr", (uint32_t)uap->addr));
25157c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_arg32(2, "len", (uint32_t)uap->len));
25167c478bd9Sstevel@tonic-gate #endif
25177c478bd9Sstevel@tonic-gate 
25187c478bd9Sstevel@tonic-gate }	/* AUS_MUNMAP */
25197c478bd9Sstevel@tonic-gate 
25207c478bd9Sstevel@tonic-gate 
25217c478bd9Sstevel@tonic-gate 
25227c478bd9Sstevel@tonic-gate 
25237c478bd9Sstevel@tonic-gate 
25247c478bd9Sstevel@tonic-gate 
25257c478bd9Sstevel@tonic-gate 
25267c478bd9Sstevel@tonic-gate /*ARGSUSED*/
25277c478bd9Sstevel@tonic-gate static void
25287c478bd9Sstevel@tonic-gate aus_priocntlsys(struct t_audit_data *tad)
25297c478bd9Sstevel@tonic-gate {
25307c478bd9Sstevel@tonic-gate 	klwp_t *clwp = ttolwp(curthread);
25317c478bd9Sstevel@tonic-gate 
25327c478bd9Sstevel@tonic-gate 	struct a {
25337c478bd9Sstevel@tonic-gate 		long	pc_version;
25347c478bd9Sstevel@tonic-gate 		long	psp;		/* procset_t */
25357c478bd9Sstevel@tonic-gate 		long	cmd;
25367c478bd9Sstevel@tonic-gate 		long	arg;
25377c478bd9Sstevel@tonic-gate 	} *uap = (struct a *)clwp->lwp_ap;
25387c478bd9Sstevel@tonic-gate 
25397c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_arg32(1, "pc_version", (uint32_t)uap->pc_version));
25407c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_arg32(3, "cmd", (uint32_t)uap->cmd));
25417c478bd9Sstevel@tonic-gate 
25427c478bd9Sstevel@tonic-gate }	/* AUS_PRIOCNTLSYS */
25437c478bd9Sstevel@tonic-gate 
25447c478bd9Sstevel@tonic-gate 
25457c478bd9Sstevel@tonic-gate /*ARGSUSED*/
25467c478bd9Sstevel@tonic-gate static void
25477c478bd9Sstevel@tonic-gate aus_setegid(struct t_audit_data *tad)
25487c478bd9Sstevel@tonic-gate {
25497c478bd9Sstevel@tonic-gate 	klwp_t *clwp = ttolwp(curthread);
25507c478bd9Sstevel@tonic-gate 	uint32_t gid;
25517c478bd9Sstevel@tonic-gate 
25527c478bd9Sstevel@tonic-gate 	struct a {
25537c478bd9Sstevel@tonic-gate 		long	gid;
25547c478bd9Sstevel@tonic-gate 	} *uap = (struct a *)clwp->lwp_ap;
25557c478bd9Sstevel@tonic-gate 
25567c478bd9Sstevel@tonic-gate 	gid = (uint32_t)uap->gid;
25577c478bd9Sstevel@tonic-gate 
25587c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_arg32(1, "gid", gid));
25597c478bd9Sstevel@tonic-gate }	/* AUS_SETEGID */
25607c478bd9Sstevel@tonic-gate 
25617c478bd9Sstevel@tonic-gate 
25627c478bd9Sstevel@tonic-gate 
25637c478bd9Sstevel@tonic-gate 
25647c478bd9Sstevel@tonic-gate /*ARGSUSED*/
25657c478bd9Sstevel@tonic-gate static void
25667c478bd9Sstevel@tonic-gate aus_setgroups(struct t_audit_data *tad)
25677c478bd9Sstevel@tonic-gate {
25687c478bd9Sstevel@tonic-gate 	klwp_t *clwp = ttolwp(curthread);
25697c478bd9Sstevel@tonic-gate 	int i;
25707c478bd9Sstevel@tonic-gate 	int gidsetsize;
25717c478bd9Sstevel@tonic-gate 	uintptr_t gidset;
25727c478bd9Sstevel@tonic-gate 	gid_t *gidlist;
25737c478bd9Sstevel@tonic-gate 
25747c478bd9Sstevel@tonic-gate 	struct a {
25757c478bd9Sstevel@tonic-gate 		long	gidsetsize;
25767c478bd9Sstevel@tonic-gate 		long	gidset;
25777c478bd9Sstevel@tonic-gate 	} *uap = (struct a *)clwp->lwp_ap;
25787c478bd9Sstevel@tonic-gate 
25797c478bd9Sstevel@tonic-gate 	gidsetsize = (uint_t)uap->gidsetsize;
25807c478bd9Sstevel@tonic-gate 	gidset = (uintptr_t)uap->gidset;
25817c478bd9Sstevel@tonic-gate 
25827c478bd9Sstevel@tonic-gate 	if ((gidsetsize > NGROUPS_MAX_DEFAULT) || (gidsetsize < 0))
25837c478bd9Sstevel@tonic-gate 		return;
25847c478bd9Sstevel@tonic-gate 	if (gidsetsize != 0) {
25857c478bd9Sstevel@tonic-gate 		gidlist = kmem_alloc(gidsetsize * sizeof (gid_t),
2586745b2690Stz 		    KM_SLEEP);
25877c478bd9Sstevel@tonic-gate 		if (copyin((caddr_t)gidset, gidlist,
2588745b2690Stz 		    gidsetsize * sizeof (gid_t)) == 0)
25897c478bd9Sstevel@tonic-gate 			for (i = 0; i < gidsetsize; i++)
25907c478bd9Sstevel@tonic-gate 				au_uwrite(au_to_arg32(1, "setgroups",
2591745b2690Stz 				    (uint32_t)gidlist[i]));
25927c478bd9Sstevel@tonic-gate 		kmem_free(gidlist, gidsetsize * sizeof (gid_t));
25937c478bd9Sstevel@tonic-gate 	} else
25947c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32(1, "setgroups", (uint32_t)0));
25957c478bd9Sstevel@tonic-gate 
25967c478bd9Sstevel@tonic-gate }	/* AUS_SETGROUPS */
25977c478bd9Sstevel@tonic-gate 
25987c478bd9Sstevel@tonic-gate 
25997c478bd9Sstevel@tonic-gate 
26007c478bd9Sstevel@tonic-gate 
26017c478bd9Sstevel@tonic-gate 
26027c478bd9Sstevel@tonic-gate /*ARGSUSED*/
26037c478bd9Sstevel@tonic-gate static void
26047c478bd9Sstevel@tonic-gate aus_seteuid(struct t_audit_data *tad)
26057c478bd9Sstevel@tonic-gate {
26067c478bd9Sstevel@tonic-gate 	klwp_t *clwp = ttolwp(curthread);
26077c478bd9Sstevel@tonic-gate 	uint32_t uid;
26087c478bd9Sstevel@tonic-gate 
26097c478bd9Sstevel@tonic-gate 	struct a {
26107c478bd9Sstevel@tonic-gate 		long	uid;
26117c478bd9Sstevel@tonic-gate 	} *uap = (struct a *)clwp->lwp_ap;
26127c478bd9Sstevel@tonic-gate 
26137c478bd9Sstevel@tonic-gate 	uid = (uint32_t)uap->uid;
26147c478bd9Sstevel@tonic-gate 
26157c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_arg32(1, "euid", uid));
26167c478bd9Sstevel@tonic-gate 
26177c478bd9Sstevel@tonic-gate }	/* AUS_SETEUID */
26187c478bd9Sstevel@tonic-gate 
26197c478bd9Sstevel@tonic-gate /*ARGSUSED*/
26207c478bd9Sstevel@tonic-gate static void
26217c478bd9Sstevel@tonic-gate aus_putmsg(struct t_audit_data *tad)
26227c478bd9Sstevel@tonic-gate {
26237c478bd9Sstevel@tonic-gate 	klwp_t *clwp = ttolwp(curthread);
26247c478bd9Sstevel@tonic-gate 	uint32_t fd, pri;
26257c478bd9Sstevel@tonic-gate 	struct file *fp;
26267c478bd9Sstevel@tonic-gate 	struct f_audit_data *fad;
26277c478bd9Sstevel@tonic-gate 
26287c478bd9Sstevel@tonic-gate 	struct a {
26297c478bd9Sstevel@tonic-gate 		long	fdes;
26307c478bd9Sstevel@tonic-gate 		long	ctl;		/* struct strbuf * */
26317c478bd9Sstevel@tonic-gate 		long	data;		/* struct strbuf * */
26327c478bd9Sstevel@tonic-gate 		long	pri;
26337c478bd9Sstevel@tonic-gate 	} *uap = (struct a *)clwp->lwp_ap;
26347c478bd9Sstevel@tonic-gate 
26357c478bd9Sstevel@tonic-gate 	fd  = (uint32_t)uap->fdes;
26367c478bd9Sstevel@tonic-gate 	pri = (uint32_t)uap->pri;
26377c478bd9Sstevel@tonic-gate 
26387c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_arg32(1, "fd", fd));
26397c478bd9Sstevel@tonic-gate 
26407c478bd9Sstevel@tonic-gate 	if ((fp = getf(fd)) != NULL) {
26417c478bd9Sstevel@tonic-gate 		fad = F2A(fp);
26427c478bd9Sstevel@tonic-gate 
26437c478bd9Sstevel@tonic-gate 		fad->fad_flags |= FAD_WRITE;
26447c478bd9Sstevel@tonic-gate 
26457c478bd9Sstevel@tonic-gate 		/* add path name to audit record */
26467c478bd9Sstevel@tonic-gate 		if (fad->fad_aupath != NULL) {
26477c478bd9Sstevel@tonic-gate 			au_uwrite(au_to_path(fad->fad_aupath));
26487c478bd9Sstevel@tonic-gate 		}
26497c478bd9Sstevel@tonic-gate 		audit_attributes(fp->f_vnode);
26507c478bd9Sstevel@tonic-gate 
26517c478bd9Sstevel@tonic-gate 		releasef(fd);
26527c478bd9Sstevel@tonic-gate 	}
26537c478bd9Sstevel@tonic-gate 
26547c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_arg32(4, "pri", pri));
26557c478bd9Sstevel@tonic-gate }
26567c478bd9Sstevel@tonic-gate 
26577c478bd9Sstevel@tonic-gate /*ARGSUSED*/
26587c478bd9Sstevel@tonic-gate static void
26597c478bd9Sstevel@tonic-gate aus_putpmsg(struct t_audit_data *tad)
26607c478bd9Sstevel@tonic-gate {
26617c478bd9Sstevel@tonic-gate 	klwp_t *clwp = ttolwp(curthread);
26627c478bd9Sstevel@tonic-gate 	uint32_t fd, pri, flags;
26637c478bd9Sstevel@tonic-gate 	struct file *fp;
26647c478bd9Sstevel@tonic-gate 	struct f_audit_data *fad;
26657c478bd9Sstevel@tonic-gate 
26667c478bd9Sstevel@tonic-gate 	struct a {
26677c478bd9Sstevel@tonic-gate 		long	fdes;
26687c478bd9Sstevel@tonic-gate 		long	ctl;		/* struct strbuf * */
26697c478bd9Sstevel@tonic-gate 		long	data;		/* struct strbuf * */
26707c478bd9Sstevel@tonic-gate 		long	pri;
26717c478bd9Sstevel@tonic-gate 		long	flags;
26727c478bd9Sstevel@tonic-gate 	} *uap = (struct a *)clwp->lwp_ap;
26737c478bd9Sstevel@tonic-gate 
26747c478bd9Sstevel@tonic-gate 	fd = (uint32_t)uap->fdes;
26757c478bd9Sstevel@tonic-gate 	pri  = (uint32_t)uap->pri;
26767c478bd9Sstevel@tonic-gate 	flags  = (uint32_t)uap->flags;
26777c478bd9Sstevel@tonic-gate 
26787c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_arg32(1, "fd", fd));
26797c478bd9Sstevel@tonic-gate 
26807c478bd9Sstevel@tonic-gate 	if ((fp = getf(fd)) != NULL) {
26817c478bd9Sstevel@tonic-gate 		fad = F2A(fp);
26827c478bd9Sstevel@tonic-gate 
26837c478bd9Sstevel@tonic-gate 		fad->fad_flags |= FAD_WRITE;
26847c478bd9Sstevel@tonic-gate 
26857c478bd9Sstevel@tonic-gate 		/* add path name to audit record */
26867c478bd9Sstevel@tonic-gate 		if (fad->fad_aupath != NULL) {
26877c478bd9Sstevel@tonic-gate 			au_uwrite(au_to_path(fad->fad_aupath));
26887c478bd9Sstevel@tonic-gate 		}
26897c478bd9Sstevel@tonic-gate 		audit_attributes(fp->f_vnode);
26907c478bd9Sstevel@tonic-gate 
26917c478bd9Sstevel@tonic-gate 		releasef(fd);
26927c478bd9Sstevel@tonic-gate 	}
26937c478bd9Sstevel@tonic-gate 
26947c478bd9Sstevel@tonic-gate 
26957c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_arg32(4, "pri", pri));
26967c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_arg32(5, "flags", flags));
26977c478bd9Sstevel@tonic-gate }
26987c478bd9Sstevel@tonic-gate 
26997c478bd9Sstevel@tonic-gate /*ARGSUSED*/
27007c478bd9Sstevel@tonic-gate static void
27017c478bd9Sstevel@tonic-gate aus_getmsg(struct t_audit_data *tad)
27027c478bd9Sstevel@tonic-gate {
27037c478bd9Sstevel@tonic-gate 	klwp_t *clwp = ttolwp(curthread);
27047c478bd9Sstevel@tonic-gate 	uint32_t fd, pri;
27057c478bd9Sstevel@tonic-gate 	struct file *fp;
27067c478bd9Sstevel@tonic-gate 	struct f_audit_data *fad;
27077c478bd9Sstevel@tonic-gate 
27087c478bd9Sstevel@tonic-gate 	struct a {
27097c478bd9Sstevel@tonic-gate 		long	fdes;
27107c478bd9Sstevel@tonic-gate 		long	ctl;		/* struct strbuf * */
27117c478bd9Sstevel@tonic-gate 		long	data;		/* struct strbuf * */
27127c478bd9Sstevel@tonic-gate 		long	pri;
27137c478bd9Sstevel@tonic-gate 	} *uap = (struct a *)clwp->lwp_ap;
27147c478bd9Sstevel@tonic-gate 
27157c478bd9Sstevel@tonic-gate 	fd  = (uint32_t)uap->fdes;
27167c478bd9Sstevel@tonic-gate 	pri = (uint32_t)uap->pri;
27177c478bd9Sstevel@tonic-gate 
27187c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_arg32(1, "fd", fd));
27197c478bd9Sstevel@tonic-gate 
27207c478bd9Sstevel@tonic-gate 	if ((fp = getf(fd)) != NULL) {
27217c478bd9Sstevel@tonic-gate 		fad = F2A(fp);
27227c478bd9Sstevel@tonic-gate 
27237c478bd9Sstevel@tonic-gate 		/*
27247c478bd9Sstevel@tonic-gate 		 * read operation on this object
27257c478bd9Sstevel@tonic-gate 		 */
27267c478bd9Sstevel@tonic-gate 		fad->fad_flags |= FAD_READ;
27277c478bd9Sstevel@tonic-gate 
27287c478bd9Sstevel@tonic-gate 		/* add path name to audit record */
27297c478bd9Sstevel@tonic-gate 		if (fad->fad_aupath != NULL) {
27307c478bd9Sstevel@tonic-gate 			au_uwrite(au_to_path(fad->fad_aupath));
27317c478bd9Sstevel@tonic-gate 		}
27327c478bd9Sstevel@tonic-gate 		audit_attributes(fp->f_vnode);
27337c478bd9Sstevel@tonic-gate 
27347c478bd9Sstevel@tonic-gate 		releasef(fd);
27357c478bd9Sstevel@tonic-gate 	}
27367c478bd9Sstevel@tonic-gate 
27377c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_arg32(4, "pri", pri));
27387c478bd9Sstevel@tonic-gate }
27397c478bd9Sstevel@tonic-gate 
27407c478bd9Sstevel@tonic-gate /*ARGSUSED*/
27417c478bd9Sstevel@tonic-gate static void
27427c478bd9Sstevel@tonic-gate aus_getpmsg(struct t_audit_data *tad)
27437c478bd9Sstevel@tonic-gate {
27447c478bd9Sstevel@tonic-gate 	klwp_t *clwp = ttolwp(curthread);
27457c478bd9Sstevel@tonic-gate 	uint32_t fd;
27467c478bd9Sstevel@tonic-gate 	struct file *fp;
27477c478bd9Sstevel@tonic-gate 	struct f_audit_data *fad;
27487c478bd9Sstevel@tonic-gate 
27497c478bd9Sstevel@tonic-gate 	struct a {
27507c478bd9Sstevel@tonic-gate 		long	fdes;
27517c478bd9Sstevel@tonic-gate 		long	ctl;		/* struct strbuf * */
27527c478bd9Sstevel@tonic-gate 		long	data;		/* struct strbuf * */
27537c478bd9Sstevel@tonic-gate 		long	pri;
27547c478bd9Sstevel@tonic-gate 		long	flags;
27557c478bd9Sstevel@tonic-gate 	} *uap = (struct a *)clwp->lwp_ap;
27567c478bd9Sstevel@tonic-gate 
27577c478bd9Sstevel@tonic-gate 	fd = (uint32_t)uap->fdes;
27587c478bd9Sstevel@tonic-gate 
27597c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_arg32(1, "fd", fd));
27607c478bd9Sstevel@tonic-gate 
27617c478bd9Sstevel@tonic-gate 	if ((fp = getf(fd)) != NULL) {
27627c478bd9Sstevel@tonic-gate 		fad = F2A(fp);
27637c478bd9Sstevel@tonic-gate 
27647c478bd9Sstevel@tonic-gate 		/*
27657c478bd9Sstevel@tonic-gate 		 * read operation on this object
27667c478bd9Sstevel@tonic-gate 		 */
27677c478bd9Sstevel@tonic-gate 		fad->fad_flags |= FAD_READ;
27687c478bd9Sstevel@tonic-gate 
27697c478bd9Sstevel@tonic-gate 		/* add path name to audit record */
27707c478bd9Sstevel@tonic-gate 		if (fad->fad_aupath != NULL) {
27717c478bd9Sstevel@tonic-gate 			au_uwrite(au_to_path(fad->fad_aupath));
27727c478bd9Sstevel@tonic-gate 		}
27737c478bd9Sstevel@tonic-gate 		audit_attributes(fp->f_vnode);
27747c478bd9Sstevel@tonic-gate 
27757c478bd9Sstevel@tonic-gate 		releasef(fd);
27767c478bd9Sstevel@tonic-gate 	}
27777c478bd9Sstevel@tonic-gate }
27787c478bd9Sstevel@tonic-gate 
277961b9bf51Srica static au_event_t
278061b9bf51Srica aui_labelsys(au_event_t e)
278161b9bf51Srica {
278261b9bf51Srica 	klwp_t *clwp = ttolwp(curthread);
278361b9bf51Srica 	uint32_t code;
278461b9bf51Srica 	uint32_t cmd;
278561b9bf51Srica 
278661b9bf51Srica 	struct a {
278761b9bf51Srica 		long	code;
278861b9bf51Srica 		long	cmd;
278961b9bf51Srica 	} *uap = (struct a *)clwp->lwp_ap;
279061b9bf51Srica 
279161b9bf51Srica 	code = (uint32_t)uap->code;
279261b9bf51Srica 	cmd = (uint32_t)uap->cmd;
279361b9bf51Srica 
279461b9bf51Srica 	/* not security relevant if not changing kernel cache */
279561b9bf51Srica 	if (cmd == TNDB_GET)
2796d3e710c8SRic Aleshire 		return (AUE_NULL);
279761b9bf51Srica 
279861b9bf51Srica 	switch (code) {
279961b9bf51Srica 	case TSOL_TNRH:
280061b9bf51Srica 		e = AUE_LABELSYS_TNRH;
280161b9bf51Srica 		break;
280261b9bf51Srica 	case TSOL_TNRHTP:
280361b9bf51Srica 		e = AUE_LABELSYS_TNRHTP;
280461b9bf51Srica 		break;
280561b9bf51Srica 	case TSOL_TNMLP:
280661b9bf51Srica 		e = AUE_LABELSYS_TNMLP;
280761b9bf51Srica 		break;
280861b9bf51Srica 	default:
280961b9bf51Srica 		e = AUE_NULL;
281061b9bf51Srica 		break;
281161b9bf51Srica 	}
281261b9bf51Srica 
281361b9bf51Srica 	return (e);
281461b9bf51Srica 
281561b9bf51Srica }
281661b9bf51Srica 
281761b9bf51Srica static void
281861b9bf51Srica aus_labelsys(struct t_audit_data *tad)
281961b9bf51Srica {
282061b9bf51Srica 	klwp_t *clwp = ttolwp(curthread);
282161b9bf51Srica 	uint32_t cmd;
282261b9bf51Srica 	uintptr_t a2;
282361b9bf51Srica 
282461b9bf51Srica 	struct a {
282561b9bf51Srica 		long	code;
282661b9bf51Srica 		long	cmd;
282761b9bf51Srica 		long	a2;
282861b9bf51Srica 	} *uap = (struct a *)clwp->lwp_ap;
282961b9bf51Srica 
283061b9bf51Srica 	cmd = (uint32_t)uap->cmd;
283161b9bf51Srica 	a2 = (uintptr_t)uap->a2;
283261b9bf51Srica 
283361b9bf51Srica 	switch (tad->tad_event) {
283461b9bf51Srica 	case AUE_LABELSYS_TNRH:
283561b9bf51Srica 	{
283661b9bf51Srica 		tsol_rhent_t	*rhent;
283761b9bf51Srica 		tnaddr_t	*rh_addr;
283861b9bf51Srica 
283961b9bf51Srica 		au_uwrite(au_to_arg32(1, "cmd", cmd));
284061b9bf51Srica 
284161b9bf51Srica 		/* Remaining args don't apply for FLUSH, so skip */
284261b9bf51Srica 		if (cmd == TNDB_FLUSH)
284361b9bf51Srica 			break;
284461b9bf51Srica 
284561b9bf51Srica 		rhent = kmem_alloc(sizeof (tsol_rhent_t), KM_SLEEP);
284661b9bf51Srica 		if (copyin((caddr_t)a2, rhent, sizeof (tsol_rhent_t))) {
284761b9bf51Srica 			kmem_free(rhent, sizeof (tsol_rhent_t));
284861b9bf51Srica 			return;
284961b9bf51Srica 		}
285061b9bf51Srica 
285161b9bf51Srica 		rh_addr = &rhent->rh_address;
285261b9bf51Srica 		if (rh_addr->ta_family == AF_INET) {
285361b9bf51Srica 			struct in_addr	*ipaddr;
285461b9bf51Srica 
285561b9bf51Srica 			ipaddr = &(rh_addr->ta_addr_v4);
285661b9bf51Srica 			au_uwrite(au_to_in_addr(ipaddr));
285761b9bf51Srica 		} else if (rh_addr->ta_family == AF_INET6) {
285861b9bf51Srica 			int32_t		*ipaddr;
285961b9bf51Srica 
286061b9bf51Srica 			ipaddr = (int32_t *)&(rh_addr->ta_addr_v6);
286161b9bf51Srica 			au_uwrite(au_to_in_addr_ex(ipaddr));
286261b9bf51Srica 		}
286361b9bf51Srica 		au_uwrite(au_to_arg32(2, "prefix len", rhent->rh_prefix));
286461b9bf51Srica 
286561b9bf51Srica 		kmem_free(rhent, sizeof (tsol_rhent_t));
286661b9bf51Srica 
286761b9bf51Srica 		break;
286861b9bf51Srica 	}
286961b9bf51Srica 	case AUE_LABELSYS_TNRHTP:
287061b9bf51Srica 	{
287161b9bf51Srica 		tsol_tpent_t	*tpent;
287261b9bf51Srica 
287361b9bf51Srica 		au_uwrite(au_to_arg32(1, "cmd", cmd));
287461b9bf51Srica 
287561b9bf51Srica 		/* Remaining args don't apply for FLUSH, so skip */
287661b9bf51Srica 		if (cmd == TNDB_FLUSH)
287761b9bf51Srica 			break;
287861b9bf51Srica 
287961b9bf51Srica 		tpent = kmem_alloc(sizeof (tsol_tpent_t), KM_SLEEP);
288061b9bf51Srica 		if (copyin((caddr_t)a2, tpent, sizeof (tsol_tpent_t))) {
288161b9bf51Srica 			kmem_free(tpent, sizeof (tsol_tpent_t));
288261b9bf51Srica 			return;
288361b9bf51Srica 		}
288461b9bf51Srica 
2885d3e710c8SRic Aleshire 		/* Make sure that the template name is null-terminated. */
2886d3e710c8SRic Aleshire 		*(tpent->name + TNTNAMSIZ - 1) = '\0';
2887d3e710c8SRic Aleshire 
288861b9bf51Srica 		au_uwrite(au_to_text(tpent->name));
288961b9bf51Srica 		kmem_free(tpent, sizeof (tsol_tpent_t));
289061b9bf51Srica 
289161b9bf51Srica 		break;
289261b9bf51Srica 	}
289361b9bf51Srica 	case AUE_LABELSYS_TNMLP:
289461b9bf51Srica 	{
289561b9bf51Srica 		tsol_mlpent_t	*mlpent;
289661b9bf51Srica 
289761b9bf51Srica 		au_uwrite(au_to_arg32(1, "cmd", cmd));
289861b9bf51Srica 
289961b9bf51Srica 		mlpent = kmem_alloc(sizeof (tsol_mlpent_t), KM_SLEEP);
290061b9bf51Srica 		if (copyin((caddr_t)a2, mlpent, sizeof (tsol_mlpent_t))) {
290161b9bf51Srica 			kmem_free(mlpent, sizeof (tsol_mlpent_t));
290261b9bf51Srica 			return;
290361b9bf51Srica 		}
290461b9bf51Srica 
290561b9bf51Srica 		if (mlpent->tsme_flags & TSOL_MEF_SHARED) {
290661b9bf51Srica 			au_uwrite(au_to_text("shared"));
290761b9bf51Srica 		} else {
290861b9bf51Srica 			zone_t	*zone;
290961b9bf51Srica 
291061b9bf51Srica 			zone = zone_find_by_id(mlpent->tsme_zoneid);
291161b9bf51Srica 			if (zone != NULL) {
291261b9bf51Srica 				au_uwrite(au_to_text(zone->zone_name));
291361b9bf51Srica 				zone_rele(zone);
291461b9bf51Srica 			}
291561b9bf51Srica 		}
291661b9bf51Srica 
291761b9bf51Srica 		/* Remaining args don't apply for FLUSH, so skip */
291861b9bf51Srica 		if (cmd == TNDB_FLUSH) {
291961b9bf51Srica 			kmem_free(mlpent, sizeof (tsol_mlpent_t));
292061b9bf51Srica 			break;
292161b9bf51Srica 		}
292261b9bf51Srica 
292361b9bf51Srica 		au_uwrite(au_to_arg32(2, "proto num",
292461b9bf51Srica 		    (uint32_t)mlpent->tsme_mlp.mlp_ipp));
292561b9bf51Srica 		au_uwrite(au_to_arg32(2, "mlp_port",
292661b9bf51Srica 		    (uint32_t)mlpent->tsme_mlp.mlp_port));
292761b9bf51Srica 
292861b9bf51Srica 		if (mlpent->tsme_mlp.mlp_port_upper != 0)
292961b9bf51Srica 			au_uwrite(au_to_arg32(2, "mlp_port_upper",
293061b9bf51Srica 			    (uint32_t)mlpent->tsme_mlp.mlp_port_upper));
293161b9bf51Srica 
293261b9bf51Srica 		kmem_free(mlpent, sizeof (tsol_mlpent_t));
293361b9bf51Srica 
293461b9bf51Srica 		break;
293561b9bf51Srica 	}
293661b9bf51Srica 	default:
293761b9bf51Srica 		break;
293861b9bf51Srica 	}
293961b9bf51Srica }
294061b9bf51Srica 
294161b9bf51Srica 
29427c478bd9Sstevel@tonic-gate static au_event_t
29437c478bd9Sstevel@tonic-gate aui_auditsys(au_event_t e)
29447c478bd9Sstevel@tonic-gate {
29457c478bd9Sstevel@tonic-gate 	klwp_t *clwp = ttolwp(curthread);
29467c478bd9Sstevel@tonic-gate 	uint32_t code;
29477c478bd9Sstevel@tonic-gate 
29487c478bd9Sstevel@tonic-gate 	struct a {
29497c478bd9Sstevel@tonic-gate 		long	code;
29507c478bd9Sstevel@tonic-gate 		long	a1;
29517c478bd9Sstevel@tonic-gate 		long	a2;
29527c478bd9Sstevel@tonic-gate 		long	a3;
29537c478bd9Sstevel@tonic-gate 		long	a4;
29547c478bd9Sstevel@tonic-gate 		long	a5;
29557c478bd9Sstevel@tonic-gate 		long	a6;
29567c478bd9Sstevel@tonic-gate 		long	a7;
29577c478bd9Sstevel@tonic-gate 	} *uap = (struct a *)clwp->lwp_ap;
29587c478bd9Sstevel@tonic-gate 
29597c478bd9Sstevel@tonic-gate 	code = (uint32_t)uap->code;
29607c478bd9Sstevel@tonic-gate 
29617c478bd9Sstevel@tonic-gate 	switch (code) {
29627c478bd9Sstevel@tonic-gate 
29637c478bd9Sstevel@tonic-gate 	case BSM_GETAUID:
29647c478bd9Sstevel@tonic-gate 		e = AUE_GETAUID;
29657c478bd9Sstevel@tonic-gate 		break;
29667c478bd9Sstevel@tonic-gate 	case BSM_SETAUID:
29677c478bd9Sstevel@tonic-gate 		e = AUE_SETAUID;
29687c478bd9Sstevel@tonic-gate 		break;
29697c478bd9Sstevel@tonic-gate 	case BSM_GETAUDIT:
29707c478bd9Sstevel@tonic-gate 		e = AUE_GETAUDIT;
29717c478bd9Sstevel@tonic-gate 		break;
29727c478bd9Sstevel@tonic-gate 	case BSM_GETAUDIT_ADDR:
29737c478bd9Sstevel@tonic-gate 		e = AUE_GETAUDIT_ADDR;
29747c478bd9Sstevel@tonic-gate 		break;
29757c478bd9Sstevel@tonic-gate 	case BSM_SETAUDIT:
29767c478bd9Sstevel@tonic-gate 		e = AUE_SETAUDIT;
29777c478bd9Sstevel@tonic-gate 		break;
29787c478bd9Sstevel@tonic-gate 	case BSM_SETAUDIT_ADDR:
29797c478bd9Sstevel@tonic-gate 		e = AUE_SETAUDIT_ADDR;
29807c478bd9Sstevel@tonic-gate 		break;
29817c478bd9Sstevel@tonic-gate 	case BSM_AUDIT:
29827c478bd9Sstevel@tonic-gate 		e = AUE_AUDIT;
29837c478bd9Sstevel@tonic-gate 		break;
29847c478bd9Sstevel@tonic-gate 	case BSM_AUDITCTL:
29857c478bd9Sstevel@tonic-gate 		switch ((uint_t)uap->a1) {
29867c478bd9Sstevel@tonic-gate 
29877c478bd9Sstevel@tonic-gate 		case A_GETPOLICY:
29887c478bd9Sstevel@tonic-gate 			e = AUE_AUDITON_GPOLICY;
29897c478bd9Sstevel@tonic-gate 			break;
29907c478bd9Sstevel@tonic-gate 		case A_SETPOLICY:
29917c478bd9Sstevel@tonic-gate 			e = AUE_AUDITON_SPOLICY;
29927c478bd9Sstevel@tonic-gate 			break;
29937c478bd9Sstevel@tonic-gate 		case A_GETKMASK:
29947c478bd9Sstevel@tonic-gate 			e = AUE_AUDITON_GETKMASK;
29957c478bd9Sstevel@tonic-gate 			break;
29967c478bd9Sstevel@tonic-gate 		case A_SETKMASK:
29977c478bd9Sstevel@tonic-gate 			e = AUE_AUDITON_SETKMASK;
29987c478bd9Sstevel@tonic-gate 			break;
29997c478bd9Sstevel@tonic-gate 		case A_GETQCTRL:
30007c478bd9Sstevel@tonic-gate 			e = AUE_AUDITON_GQCTRL;
30017c478bd9Sstevel@tonic-gate 			break;
30027c478bd9Sstevel@tonic-gate 		case A_SETQCTRL:
30037c478bd9Sstevel@tonic-gate 			e = AUE_AUDITON_SQCTRL;
30047c478bd9Sstevel@tonic-gate 			break;
30057c478bd9Sstevel@tonic-gate 		case A_GETCWD:
30067c478bd9Sstevel@tonic-gate 			e = AUE_AUDITON_GETCWD;
30077c478bd9Sstevel@tonic-gate 			break;
30087c478bd9Sstevel@tonic-gate 		case A_GETCAR:
30097c478bd9Sstevel@tonic-gate 			e = AUE_AUDITON_GETCAR;
30107c478bd9Sstevel@tonic-gate 			break;
30117c478bd9Sstevel@tonic-gate 		case A_GETSTAT:
30127c478bd9Sstevel@tonic-gate 			e = AUE_AUDITON_GETSTAT;
30137c478bd9Sstevel@tonic-gate 			break;
30147c478bd9Sstevel@tonic-gate 		case A_SETSTAT:
30157c478bd9Sstevel@tonic-gate 			e = AUE_AUDITON_SETSTAT;
30167c478bd9Sstevel@tonic-gate 			break;
30177c478bd9Sstevel@tonic-gate 		case A_SETUMASK:
30187c478bd9Sstevel@tonic-gate 			e = AUE_AUDITON_SETUMASK;
30197c478bd9Sstevel@tonic-gate 			break;
30207c478bd9Sstevel@tonic-gate 		case A_SETSMASK:
30217c478bd9Sstevel@tonic-gate 			e = AUE_AUDITON_SETSMASK;
30227c478bd9Sstevel@tonic-gate 			break;
30237c478bd9Sstevel@tonic-gate 		case A_GETCOND:
30247c478bd9Sstevel@tonic-gate 			e = AUE_AUDITON_GETCOND;
30257c478bd9Sstevel@tonic-gate 			break;
30267c478bd9Sstevel@tonic-gate 		case A_SETCOND:
30277c478bd9Sstevel@tonic-gate 			e = AUE_AUDITON_SETCOND;
30287c478bd9Sstevel@tonic-gate 			break;
30297c478bd9Sstevel@tonic-gate 		case A_GETCLASS:
30307c478bd9Sstevel@tonic-gate 			e = AUE_AUDITON_GETCLASS;
30317c478bd9Sstevel@tonic-gate 			break;
30327c478bd9Sstevel@tonic-gate 		case A_SETCLASS:
30337c478bd9Sstevel@tonic-gate 			e = AUE_AUDITON_SETCLASS;
30347c478bd9Sstevel@tonic-gate 			break;
30357c478bd9Sstevel@tonic-gate 		default:
30367c478bd9Sstevel@tonic-gate 			e = AUE_NULL;
30377c478bd9Sstevel@tonic-gate 			break;
30387c478bd9Sstevel@tonic-gate 		}
30397c478bd9Sstevel@tonic-gate 		break;
30407c478bd9Sstevel@tonic-gate 	default:
30417c478bd9Sstevel@tonic-gate 		e = AUE_NULL;
30427c478bd9Sstevel@tonic-gate 		break;
30437c478bd9Sstevel@tonic-gate 	}
30447c478bd9Sstevel@tonic-gate 
30457c478bd9Sstevel@tonic-gate 	return (e);
30467c478bd9Sstevel@tonic-gate 
30477c478bd9Sstevel@tonic-gate }	/* AUI_AUDITSYS */
30487c478bd9Sstevel@tonic-gate 
30497c478bd9Sstevel@tonic-gate 
30507c478bd9Sstevel@tonic-gate static void
30517c478bd9Sstevel@tonic-gate aus_auditsys(struct t_audit_data *tad)
30527c478bd9Sstevel@tonic-gate {
30537c478bd9Sstevel@tonic-gate 	klwp_t *clwp = ttolwp(curthread);
30547c478bd9Sstevel@tonic-gate 	uintptr_t a1, a2;
30557c478bd9Sstevel@tonic-gate 	STRUCT_DECL(auditinfo, ainfo);
30567c478bd9Sstevel@tonic-gate 	STRUCT_DECL(auditinfo_addr, ainfo_addr);
30577c478bd9Sstevel@tonic-gate 	au_evclass_map_t event;
30587c478bd9Sstevel@tonic-gate 	au_mask_t mask;
30597c478bd9Sstevel@tonic-gate 	int auditstate, policy;
3060f2fcf18cStz 	au_id_t auid;
30617c478bd9Sstevel@tonic-gate 
30627c478bd9Sstevel@tonic-gate 
30637c478bd9Sstevel@tonic-gate 	struct a {
30647c478bd9Sstevel@tonic-gate 		long	code;
30657c478bd9Sstevel@tonic-gate 		long	a1;
30667c478bd9Sstevel@tonic-gate 		long	a2;
30677c478bd9Sstevel@tonic-gate 		long	a3;
30687c478bd9Sstevel@tonic-gate 		long	a4;
30697c478bd9Sstevel@tonic-gate 		long	a5;
30707c478bd9Sstevel@tonic-gate 		long	a6;
30717c478bd9Sstevel@tonic-gate 		long	a7;
30727c478bd9Sstevel@tonic-gate 	} *uap = (struct a *)clwp->lwp_ap;
30737c478bd9Sstevel@tonic-gate 
30747c478bd9Sstevel@tonic-gate 	a1   = (uintptr_t)uap->a1;
30757c478bd9Sstevel@tonic-gate 	a2   = (uintptr_t)uap->a2;
30767c478bd9Sstevel@tonic-gate 
30777c478bd9Sstevel@tonic-gate 	switch (tad->tad_event) {
30787c478bd9Sstevel@tonic-gate 	case AUE_SETAUID:
3079f2fcf18cStz 		if (copyin((caddr_t)a1, &auid, sizeof (au_id_t)))
3080f2fcf18cStz 				return;
3081f2fcf18cStz 		au_uwrite(au_to_arg32(2, "setauid", auid));
30827c478bd9Sstevel@tonic-gate 		break;
30837c478bd9Sstevel@tonic-gate 	case AUE_SETAUDIT:
30847c478bd9Sstevel@tonic-gate 		STRUCT_INIT(ainfo, get_udatamodel());
30857c478bd9Sstevel@tonic-gate 		if (copyin((caddr_t)a1, STRUCT_BUF(ainfo),
3086745b2690Stz 		    STRUCT_SIZE(ainfo))) {
30877c478bd9Sstevel@tonic-gate 				return;
30887c478bd9Sstevel@tonic-gate 		}
30897c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32((char)1, "setaudit:auid",
3090745b2690Stz 		    (uint32_t)STRUCT_FGET(ainfo, ai_auid)));
30917c478bd9Sstevel@tonic-gate #ifdef _LP64
30927c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg64((char)1, "setaudit:port",
3093745b2690Stz 		    (uint64_t)STRUCT_FGET(ainfo, ai_termid.port)));
30947c478bd9Sstevel@tonic-gate #else
30957c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32((char)1, "setaudit:port",
3096745b2690Stz 		    (uint32_t)STRUCT_FGET(ainfo, ai_termid.port)));
30977c478bd9Sstevel@tonic-gate #endif
30987c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32((char)1, "setaudit:machine",
3099745b2690Stz 		    (uint32_t)STRUCT_FGET(ainfo, ai_termid.machine)));
31007c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32((char)1, "setaudit:as_success",
3101745b2690Stz 		    (uint32_t)STRUCT_FGET(ainfo, ai_mask.as_success)));
31027c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32((char)1, "setaudit:as_failure",
3103745b2690Stz 		    (uint32_t)STRUCT_FGET(ainfo, ai_mask.as_failure)));
31047c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32((char)1, "setaudit:asid",
3105745b2690Stz 		    (uint32_t)STRUCT_FGET(ainfo, ai_asid)));
31067c478bd9Sstevel@tonic-gate 		break;
31077c478bd9Sstevel@tonic-gate 	case AUE_SETAUDIT_ADDR:
31087c478bd9Sstevel@tonic-gate 		STRUCT_INIT(ainfo_addr, get_udatamodel());
31097c478bd9Sstevel@tonic-gate 		if (copyin((caddr_t)a1, STRUCT_BUF(ainfo_addr),
3110745b2690Stz 		    STRUCT_SIZE(ainfo_addr))) {
31117c478bd9Sstevel@tonic-gate 				return;
31127c478bd9Sstevel@tonic-gate 		}
31137c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32((char)1, "auid",
3114745b2690Stz 		    (uint32_t)STRUCT_FGET(ainfo_addr, ai_auid)));
31157c478bd9Sstevel@tonic-gate #ifdef _LP64
31167c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg64((char)1, "port",
3117745b2690Stz 		    (uint64_t)STRUCT_FGET(ainfo_addr, ai_termid.at_port)));
31187c478bd9Sstevel@tonic-gate #else
31197c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32((char)1, "port",
3120745b2690Stz 		    (uint32_t)STRUCT_FGET(ainfo_addr, ai_termid.at_port)));
31217c478bd9Sstevel@tonic-gate #endif
31227c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32((char)1, "type",
3123745b2690Stz 		    (uint32_t)STRUCT_FGET(ainfo_addr, ai_termid.at_type)));
31247c478bd9Sstevel@tonic-gate 		if ((uint32_t)STRUCT_FGET(ainfo_addr, ai_termid.at_type) ==
31257c478bd9Sstevel@tonic-gate 		    AU_IPv4) {
31267c478bd9Sstevel@tonic-gate 			au_uwrite(au_to_in_addr(
3127745b2690Stz 			    (struct in_addr *)STRUCT_FGETP(ainfo_addr,
3128745b2690Stz 			    ai_termid.at_addr)));
31297c478bd9Sstevel@tonic-gate 		} else {
31307c478bd9Sstevel@tonic-gate 			au_uwrite(au_to_in_addr_ex(
3131745b2690Stz 			    (int32_t *)STRUCT_FGETP(ainfo_addr,
3132745b2690Stz 			    ai_termid.at_addr)));
31337c478bd9Sstevel@tonic-gate 		}
31347c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32((char)1, "as_success",
3135745b2690Stz 		    (uint32_t)STRUCT_FGET(ainfo_addr, ai_mask.as_success)));
31367c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32((char)1, "as_failure",
3137745b2690Stz 		    (uint32_t)STRUCT_FGET(ainfo_addr, ai_mask.as_failure)));
31387c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32((char)1, "asid",
3139745b2690Stz 		    (uint32_t)STRUCT_FGET(ainfo_addr, ai_asid)));
31407c478bd9Sstevel@tonic-gate 		break;
31417c478bd9Sstevel@tonic-gate 	case AUE_AUDITON_SETKMASK:
31427c478bd9Sstevel@tonic-gate 		if (copyin((caddr_t)a2, &mask, sizeof (au_mask_t)))
31437c478bd9Sstevel@tonic-gate 				return;
31447c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32(
3145745b2690Stz 		    2, "setkmask:as_success", (uint32_t)mask.as_success));
31467c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32(
3147745b2690Stz 		    2, "setkmask:as_failure", (uint32_t)mask.as_failure));
31487c478bd9Sstevel@tonic-gate 		break;
31497c478bd9Sstevel@tonic-gate 	case AUE_AUDITON_SPOLICY:
31507c478bd9Sstevel@tonic-gate 		if (copyin((caddr_t)a2, &policy, sizeof (int)))
31517c478bd9Sstevel@tonic-gate 			return;
31527c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32(3, "setpolicy", (uint32_t)policy));
31537c478bd9Sstevel@tonic-gate 		break;
31547c478bd9Sstevel@tonic-gate 	case AUE_AUDITON_SQCTRL: {
31557c478bd9Sstevel@tonic-gate 		STRUCT_DECL(au_qctrl, qctrl);
31567c478bd9Sstevel@tonic-gate 		model_t model;
31577c478bd9Sstevel@tonic-gate 
31587c478bd9Sstevel@tonic-gate 		model = get_udatamodel();
31597c478bd9Sstevel@tonic-gate 		STRUCT_INIT(qctrl, model);
31607c478bd9Sstevel@tonic-gate 		if (copyin((caddr_t)a2, STRUCT_BUF(qctrl), STRUCT_SIZE(qctrl)))
31617c478bd9Sstevel@tonic-gate 				return;
31627c478bd9Sstevel@tonic-gate 		if (model == DATAMODEL_ILP32) {
31637c478bd9Sstevel@tonic-gate 			au_uwrite(au_to_arg32(
3164745b2690Stz 			    3, "setqctrl:aq_hiwater",
3165745b2690Stz 			    (uint32_t)STRUCT_FGET(qctrl, aq_hiwater)));
31667c478bd9Sstevel@tonic-gate 			au_uwrite(au_to_arg32(
3167745b2690Stz 			    3, "setqctrl:aq_lowater",
3168745b2690Stz 			    (uint32_t)STRUCT_FGET(qctrl, aq_lowater)));
31697c478bd9Sstevel@tonic-gate 			au_uwrite(au_to_arg32(
3170745b2690Stz 			    3, "setqctrl:aq_bufsz",
3171745b2690Stz 			    (uint32_t)STRUCT_FGET(qctrl, aq_bufsz)));
31727c478bd9Sstevel@tonic-gate 			au_uwrite(au_to_arg32(
3173745b2690Stz 			    3, "setqctrl:aq_delay",
3174745b2690Stz 			    (uint32_t)STRUCT_FGET(qctrl, aq_delay)));
31757c478bd9Sstevel@tonic-gate 		} else {
31767c478bd9Sstevel@tonic-gate 			au_uwrite(au_to_arg64(
3177745b2690Stz 			    3, "setqctrl:aq_hiwater",
3178745b2690Stz 			    (uint64_t)STRUCT_FGET(qctrl, aq_hiwater)));
31797c478bd9Sstevel@tonic-gate 			au_uwrite(au_to_arg64(
3180745b2690Stz 			    3, "setqctrl:aq_lowater",
3181745b2690Stz 			    (uint64_t)STRUCT_FGET(qctrl, aq_lowater)));
31827c478bd9Sstevel@tonic-gate 			au_uwrite(au_to_arg64(
3183745b2690Stz 			    3, "setqctrl:aq_bufsz",
3184745b2690Stz 			    (uint64_t)STRUCT_FGET(qctrl, aq_bufsz)));
31857c478bd9Sstevel@tonic-gate 			au_uwrite(au_to_arg64(
3186745b2690Stz 			    3, "setqctrl:aq_delay",
3187745b2690Stz 			    (uint64_t)STRUCT_FGET(qctrl, aq_delay)));
31887c478bd9Sstevel@tonic-gate 		}
31897c478bd9Sstevel@tonic-gate 		break;
31907c478bd9Sstevel@tonic-gate 	}
31917c478bd9Sstevel@tonic-gate 	case AUE_AUDITON_SETUMASK:
31927c478bd9Sstevel@tonic-gate 		STRUCT_INIT(ainfo, get_udatamodel());
31937c478bd9Sstevel@tonic-gate 		if (copyin((caddr_t)uap->a2, STRUCT_BUF(ainfo),
3194745b2690Stz 		    STRUCT_SIZE(ainfo))) {
3195745b2690Stz 			return;
31967c478bd9Sstevel@tonic-gate 		}
31977c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32(3, "setumask:as_success",
3198745b2690Stz 		    (uint32_t)STRUCT_FGET(ainfo, ai_mask.as_success)));
31997c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32(3, "setumask:as_failure",
3200745b2690Stz 		    (uint32_t)STRUCT_FGET(ainfo, ai_mask.as_failure)));
32017c478bd9Sstevel@tonic-gate 		break;
32027c478bd9Sstevel@tonic-gate 	case AUE_AUDITON_SETSMASK:
32037c478bd9Sstevel@tonic-gate 		STRUCT_INIT(ainfo, get_udatamodel());
32047c478bd9Sstevel@tonic-gate 		if (copyin((caddr_t)uap->a2, STRUCT_BUF(ainfo),
3205745b2690Stz 		    STRUCT_SIZE(ainfo))) {
3206745b2690Stz 			return;
32077c478bd9Sstevel@tonic-gate 		}
32087c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32(3, "setsmask:as_success",
3209745b2690Stz 		    (uint32_t)STRUCT_FGET(ainfo, ai_mask.as_success)));
32107c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32(3, "setsmask:as_failure",
3211745b2690Stz 		    (uint32_t)STRUCT_FGET(ainfo, ai_mask.as_failure)));
32127c478bd9Sstevel@tonic-gate 		break;
32137c478bd9Sstevel@tonic-gate 	case AUE_AUDITON_SETCOND:
32147c478bd9Sstevel@tonic-gate 		if (copyin((caddr_t)a2, &auditstate, sizeof (int)))
32157c478bd9Sstevel@tonic-gate 			return;
32167c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32(3, "setcond", (uint32_t)auditstate));
32177c478bd9Sstevel@tonic-gate 		break;
32187c478bd9Sstevel@tonic-gate 	case AUE_AUDITON_SETCLASS:
32197c478bd9Sstevel@tonic-gate 		if (copyin((caddr_t)a2, &event, sizeof (au_evclass_map_t)))
32207c478bd9Sstevel@tonic-gate 			return;
32217c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32(
3222745b2690Stz 		    2, "setclass:ec_event", (uint32_t)event.ec_number));
32237c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32(
3224745b2690Stz 		    3, "setclass:ec_class", (uint32_t)event.ec_class));
32257c478bd9Sstevel@tonic-gate 		break;
32267c478bd9Sstevel@tonic-gate 	case AUE_GETAUID:
32277c478bd9Sstevel@tonic-gate 	case AUE_GETAUDIT:
32287c478bd9Sstevel@tonic-gate 	case AUE_GETAUDIT_ADDR:
32297c478bd9Sstevel@tonic-gate 	case AUE_AUDIT:
32307c478bd9Sstevel@tonic-gate 	case AUE_AUDITON_GPOLICY:
32317c478bd9Sstevel@tonic-gate 	case AUE_AUDITON_GQCTRL:
32327c478bd9Sstevel@tonic-gate 	case AUE_AUDITON_GETKMASK:
32337c478bd9Sstevel@tonic-gate 	case AUE_AUDITON_GETCWD:
32347c478bd9Sstevel@tonic-gate 	case AUE_AUDITON_GETCAR:
32357c478bd9Sstevel@tonic-gate 	case AUE_AUDITON_GETSTAT:
32367c478bd9Sstevel@tonic-gate 	case AUE_AUDITON_SETSTAT:
32377c478bd9Sstevel@tonic-gate 	case AUE_AUDITON_GETCOND:
32387c478bd9Sstevel@tonic-gate 	case AUE_AUDITON_GETCLASS:
32397c478bd9Sstevel@tonic-gate 		break;
32407c478bd9Sstevel@tonic-gate 	default:
32417c478bd9Sstevel@tonic-gate 		break;
32427c478bd9Sstevel@tonic-gate 	}
32437c478bd9Sstevel@tonic-gate 
32447c478bd9Sstevel@tonic-gate }	/* AUS_AUDITSYS */
32457c478bd9Sstevel@tonic-gate 
32467c478bd9Sstevel@tonic-gate 
32477c478bd9Sstevel@tonic-gate /* only audit privileged operations for systeminfo(2) system call */
32487c478bd9Sstevel@tonic-gate static au_event_t
32497c478bd9Sstevel@tonic-gate aui_sysinfo(au_event_t e)
32507c478bd9Sstevel@tonic-gate {
32517c478bd9Sstevel@tonic-gate 	klwp_t *clwp = ttolwp(curthread);
32527c478bd9Sstevel@tonic-gate 	uint32_t command;
32537c478bd9Sstevel@tonic-gate 
32547c478bd9Sstevel@tonic-gate 	struct a {
32557c478bd9Sstevel@tonic-gate 		long	command;
32567c478bd9Sstevel@tonic-gate 		long	buf;		/* char * */
32577c478bd9Sstevel@tonic-gate 		long	count;
32587c478bd9Sstevel@tonic-gate 	} *uap = (struct a *)clwp->lwp_ap;
32597c478bd9Sstevel@tonic-gate 
32607c478bd9Sstevel@tonic-gate 	command = (uint32_t)uap->command;
32617c478bd9Sstevel@tonic-gate 
32627c478bd9Sstevel@tonic-gate 	switch (command) {
32637c478bd9Sstevel@tonic-gate 	case SI_SET_HOSTNAME:
32647c478bd9Sstevel@tonic-gate 	case SI_SET_SRPC_DOMAIN:
32657c478bd9Sstevel@tonic-gate 		e = (au_event_t)AUE_SYSINFO;
32667c478bd9Sstevel@tonic-gate 		break;
32677c478bd9Sstevel@tonic-gate 	default:
32687c478bd9Sstevel@tonic-gate 		e = (au_event_t)AUE_NULL;
32697c478bd9Sstevel@tonic-gate 		break;
32707c478bd9Sstevel@tonic-gate 	}
32717c478bd9Sstevel@tonic-gate 	return (e);
32727c478bd9Sstevel@tonic-gate }
32737c478bd9Sstevel@tonic-gate 
32747c478bd9Sstevel@tonic-gate /*ARGSUSED*/
32757c478bd9Sstevel@tonic-gate static void
32767c478bd9Sstevel@tonic-gate aus_sysinfo(struct t_audit_data *tad)
32777c478bd9Sstevel@tonic-gate {
32787c478bd9Sstevel@tonic-gate 	klwp_t *clwp = ttolwp(curthread);
32797c478bd9Sstevel@tonic-gate 	uint32_t command;
32807c478bd9Sstevel@tonic-gate 	size_t len, maxlen;
32817c478bd9Sstevel@tonic-gate 	char *name;
32827c478bd9Sstevel@tonic-gate 	uintptr_t buf;
32837c478bd9Sstevel@tonic-gate 
32847c478bd9Sstevel@tonic-gate 	struct a {
32857c478bd9Sstevel@tonic-gate 		long	command;
32867c478bd9Sstevel@tonic-gate 		long	buf;		/* char * */
32877c478bd9Sstevel@tonic-gate 		long	count;
32887c478bd9Sstevel@tonic-gate 	} *uap = (struct a *)clwp->lwp_ap;
32897c478bd9Sstevel@tonic-gate 
32907c478bd9Sstevel@tonic-gate 	command = (uint32_t)uap->command;
32917c478bd9Sstevel@tonic-gate 	buf = (uintptr_t)uap->buf;
32927c478bd9Sstevel@tonic-gate 
32937c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_arg32(1, "cmd", command));
32947c478bd9Sstevel@tonic-gate 
32957c478bd9Sstevel@tonic-gate 	switch (command) {
32967c478bd9Sstevel@tonic-gate 	case SI_SET_HOSTNAME:
32977c478bd9Sstevel@tonic-gate 	{
32987c478bd9Sstevel@tonic-gate 		if (secpolicy_sys_config(CRED(), B_TRUE) != 0)
32997c478bd9Sstevel@tonic-gate 			return;
33007c478bd9Sstevel@tonic-gate 
33017c478bd9Sstevel@tonic-gate 		maxlen = SYS_NMLN;
33027c478bd9Sstevel@tonic-gate 		name = kmem_alloc(maxlen, KM_SLEEP);
33037c478bd9Sstevel@tonic-gate 		if (copyinstr((caddr_t)buf, name, SYS_NMLN, &len))
33047c478bd9Sstevel@tonic-gate 			break;
33057c478bd9Sstevel@tonic-gate 
33067c478bd9Sstevel@tonic-gate 		/*
33077c478bd9Sstevel@tonic-gate 		 * Must be non-NULL string and string
33087c478bd9Sstevel@tonic-gate 		 * must be less than SYS_NMLN chars.
33097c478bd9Sstevel@tonic-gate 		 */
33107c478bd9Sstevel@tonic-gate 		if (len < 2 || (len == SYS_NMLN && name[SYS_NMLN - 1] != '\0'))
33117c478bd9Sstevel@tonic-gate 			break;
33127c478bd9Sstevel@tonic-gate 
33137c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_text(name));
33147c478bd9Sstevel@tonic-gate 		break;
33157c478bd9Sstevel@tonic-gate 	}
33167c478bd9Sstevel@tonic-gate 
33177c478bd9Sstevel@tonic-gate 	case SI_SET_SRPC_DOMAIN:
33187c478bd9Sstevel@tonic-gate 	{
33197c478bd9Sstevel@tonic-gate 		if (secpolicy_sys_config(CRED(), B_TRUE) != 0)
33207c478bd9Sstevel@tonic-gate 			return;
33217c478bd9Sstevel@tonic-gate 
33227c478bd9Sstevel@tonic-gate 		maxlen = SYS_NMLN;
33237c478bd9Sstevel@tonic-gate 		name = kmem_alloc(maxlen, KM_SLEEP);
33247c478bd9Sstevel@tonic-gate 		if (copyinstr((caddr_t)buf, name, SYS_NMLN, &len))
33257c478bd9Sstevel@tonic-gate 			break;
33267c478bd9Sstevel@tonic-gate 
33277c478bd9Sstevel@tonic-gate 		/*
33287c478bd9Sstevel@tonic-gate 		 * If string passed in is longer than length
33297c478bd9Sstevel@tonic-gate 		 * allowed for domain name, fail.
33307c478bd9Sstevel@tonic-gate 		 */
33317c478bd9Sstevel@tonic-gate 		if (len == SYS_NMLN && name[SYS_NMLN - 1] != '\0')
33327c478bd9Sstevel@tonic-gate 			break;
33337c478bd9Sstevel@tonic-gate 
33347c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_text(name));
33357c478bd9Sstevel@tonic-gate 		break;
33367c478bd9Sstevel@tonic-gate 	}
33377c478bd9Sstevel@tonic-gate 
33387c478bd9Sstevel@tonic-gate 	default:
33397c478bd9Sstevel@tonic-gate 		return;
33407c478bd9Sstevel@tonic-gate 	}
33417c478bd9Sstevel@tonic-gate 
33427c478bd9Sstevel@tonic-gate 	kmem_free(name, maxlen);
33437c478bd9Sstevel@tonic-gate }
33447c478bd9Sstevel@tonic-gate 
33457c478bd9Sstevel@tonic-gate static au_event_t
33467c478bd9Sstevel@tonic-gate aui_modctl(au_event_t e)
33477c478bd9Sstevel@tonic-gate {
33487c478bd9Sstevel@tonic-gate 	klwp_t *clwp = ttolwp(curthread);
33497c478bd9Sstevel@tonic-gate 	uint_t cmd;
33507c478bd9Sstevel@tonic-gate 
33517c478bd9Sstevel@tonic-gate 	struct a {
33527c478bd9Sstevel@tonic-gate 		long	cmd;
33537c478bd9Sstevel@tonic-gate 	} *uap = (struct a *)clwp->lwp_ap;
33547c478bd9Sstevel@tonic-gate 
33557c478bd9Sstevel@tonic-gate 	cmd = (uint_t)uap->cmd;
33567c478bd9Sstevel@tonic-gate 
33577c478bd9Sstevel@tonic-gate 	switch (cmd) {
33587c478bd9Sstevel@tonic-gate 	case MODLOAD:
33597c478bd9Sstevel@tonic-gate 		e = AUE_MODLOAD;
33607c478bd9Sstevel@tonic-gate 		break;
33617c478bd9Sstevel@tonic-gate 	case MODUNLOAD:
33627c478bd9Sstevel@tonic-gate 		e = AUE_MODUNLOAD;
33637c478bd9Sstevel@tonic-gate 		break;
33647c478bd9Sstevel@tonic-gate 	case MODADDMAJBIND:
33657c478bd9Sstevel@tonic-gate 		e = AUE_MODADDMAJ;
33667c478bd9Sstevel@tonic-gate 		break;
33677c478bd9Sstevel@tonic-gate 	case MODSETDEVPOLICY:
33687c478bd9Sstevel@tonic-gate 		e = AUE_MODDEVPLCY;
33697c478bd9Sstevel@tonic-gate 		break;
33707c478bd9Sstevel@tonic-gate 	case MODALLOCPRIV:
33717c478bd9Sstevel@tonic-gate 		e = AUE_MODADDPRIV;
33727c478bd9Sstevel@tonic-gate 		break;
33737c478bd9Sstevel@tonic-gate 	default:
33747c478bd9Sstevel@tonic-gate 		e = AUE_NULL;
33757c478bd9Sstevel@tonic-gate 		break;
33767c478bd9Sstevel@tonic-gate 	}
33777c478bd9Sstevel@tonic-gate 	return (e);
33787c478bd9Sstevel@tonic-gate }
33797c478bd9Sstevel@tonic-gate 
33807c478bd9Sstevel@tonic-gate 
33817c478bd9Sstevel@tonic-gate /*ARGSUSED*/
33827c478bd9Sstevel@tonic-gate static void
33837c478bd9Sstevel@tonic-gate aus_modctl(struct t_audit_data *tad)
33847c478bd9Sstevel@tonic-gate {
33857c478bd9Sstevel@tonic-gate 	klwp_t *clwp = ttolwp(curthread);
33867c478bd9Sstevel@tonic-gate 	void *a	= clwp->lwp_ap;
33877c478bd9Sstevel@tonic-gate 	uint_t use_path;
33887c478bd9Sstevel@tonic-gate 
33897c478bd9Sstevel@tonic-gate 	switch (tad->tad_event) {
33907c478bd9Sstevel@tonic-gate 	case AUE_MODLOAD: {
33917c478bd9Sstevel@tonic-gate 		typedef struct {
33927c478bd9Sstevel@tonic-gate 			long	cmd;
33937c478bd9Sstevel@tonic-gate 			long	use_path;
33947c478bd9Sstevel@tonic-gate 			long	filename;		/* char * */
33957c478bd9Sstevel@tonic-gate 		} modloada_t;
33967c478bd9Sstevel@tonic-gate 
33977c478bd9Sstevel@tonic-gate 		char *filenamep;
33987c478bd9Sstevel@tonic-gate 		uintptr_t fname;
33997c478bd9Sstevel@tonic-gate 		extern char *default_path;
34007c478bd9Sstevel@tonic-gate 
34017c478bd9Sstevel@tonic-gate 		fname = (uintptr_t)((modloada_t *)a)->filename;
34027c478bd9Sstevel@tonic-gate 		use_path = (uint_t)((modloada_t *)a)->use_path;
34037c478bd9Sstevel@tonic-gate 
34047c478bd9Sstevel@tonic-gate 			/* space to hold path */
34057c478bd9Sstevel@tonic-gate 		filenamep = kmem_alloc(MOD_MAXPATH, KM_SLEEP);
34067c478bd9Sstevel@tonic-gate 			/* get string */
34077c478bd9Sstevel@tonic-gate 		if (copyinstr((caddr_t)fname, filenamep, MOD_MAXPATH, 0)) {
34087c478bd9Sstevel@tonic-gate 				/* free allocated path */
34097c478bd9Sstevel@tonic-gate 			kmem_free(filenamep, MOD_MAXPATH);
34107c478bd9Sstevel@tonic-gate 			return;
34117c478bd9Sstevel@tonic-gate 		}
34127c478bd9Sstevel@tonic-gate 			/* ensure it's null terminated */
34137c478bd9Sstevel@tonic-gate 		filenamep[MOD_MAXPATH - 1] = 0;
34147c478bd9Sstevel@tonic-gate 
34157c478bd9Sstevel@tonic-gate 		if (use_path)
34167c478bd9Sstevel@tonic-gate 			au_uwrite(au_to_text(default_path));
34177c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_text(filenamep));
34187c478bd9Sstevel@tonic-gate 
34197c478bd9Sstevel@tonic-gate 			/* release temporary memory */
34207c478bd9Sstevel@tonic-gate 		kmem_free(filenamep, MOD_MAXPATH);
34217c478bd9Sstevel@tonic-gate 		break;
34227c478bd9Sstevel@tonic-gate 	}
34237c478bd9Sstevel@tonic-gate 	case AUE_MODUNLOAD: {
34247c478bd9Sstevel@tonic-gate 		typedef struct {
34257c478bd9Sstevel@tonic-gate 			long	cmd;
34267c478bd9Sstevel@tonic-gate 			long	id;
34277c478bd9Sstevel@tonic-gate 		} modunloada_t;
34287c478bd9Sstevel@tonic-gate 
34297c478bd9Sstevel@tonic-gate 		uint32_t id = (uint32_t)((modunloada_t *)a)->id;
34307c478bd9Sstevel@tonic-gate 
34317c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32(1, "id", id));
34327c478bd9Sstevel@tonic-gate 		break;
34337c478bd9Sstevel@tonic-gate 	}
34347c478bd9Sstevel@tonic-gate 	case AUE_MODADDMAJ: {
34357c478bd9Sstevel@tonic-gate 		STRUCT_DECL(modconfig, mc);
34367c478bd9Sstevel@tonic-gate 		typedef struct {
34377c478bd9Sstevel@tonic-gate 			long	cmd;
34387c478bd9Sstevel@tonic-gate 			long	subcmd;
34397c478bd9Sstevel@tonic-gate 			long	data;		/* int * */
34407c478bd9Sstevel@tonic-gate 		} modconfiga_t;
34417c478bd9Sstevel@tonic-gate 
34427c478bd9Sstevel@tonic-gate 		STRUCT_DECL(aliases, alias);
34437c478bd9Sstevel@tonic-gate 		caddr_t ap;
34447c478bd9Sstevel@tonic-gate 		int i, num_aliases;
34457c478bd9Sstevel@tonic-gate 		char *drvname, *mc_drvname;
34467c478bd9Sstevel@tonic-gate 		char *name;
34477c478bd9Sstevel@tonic-gate 		extern char *ddi_major_to_name(major_t);
34487c478bd9Sstevel@tonic-gate 		model_t model;
34497c478bd9Sstevel@tonic-gate 
34507c478bd9Sstevel@tonic-gate 		uintptr_t data = (uintptr_t)((modconfiga_t *)a)->data;
34517c478bd9Sstevel@tonic-gate 
34527c478bd9Sstevel@tonic-gate 		model = get_udatamodel();
34537c478bd9Sstevel@tonic-gate 		STRUCT_INIT(mc, model);
34547c478bd9Sstevel@tonic-gate 			/* sanitize buffer */
34557c478bd9Sstevel@tonic-gate 		bzero((caddr_t)STRUCT_BUF(mc), STRUCT_SIZE(mc));
34567c478bd9Sstevel@tonic-gate 			/* get user arguments */
34577c478bd9Sstevel@tonic-gate 		if (copyin((caddr_t)data, (caddr_t)STRUCT_BUF(mc),
3458745b2690Stz 		    STRUCT_SIZE(mc)) != 0)
34597c478bd9Sstevel@tonic-gate 			return;
34607c478bd9Sstevel@tonic-gate 
34617c478bd9Sstevel@tonic-gate 		mc_drvname = STRUCT_FGET(mc, drvname);
34627c478bd9Sstevel@tonic-gate 		if ((drvname = ddi_major_to_name(
3463745b2690Stz 		    (major_t)STRUCT_FGET(mc, major))) != NULL &&
3464745b2690Stz 		    strncmp(drvname, mc_drvname, MAXMODCONFNAME) != 0) {
34657c478bd9Sstevel@tonic-gate 				/* safety */
34667c478bd9Sstevel@tonic-gate 			if (mc_drvname[0] != '\0') {
34677c478bd9Sstevel@tonic-gate 				mc_drvname[MAXMODCONFNAME-1] = '\0';
34687c478bd9Sstevel@tonic-gate 				au_uwrite(au_to_text(mc_drvname));
34697c478bd9Sstevel@tonic-gate 			}
34707c478bd9Sstevel@tonic-gate 				/* drvname != NULL from test above */
34717c478bd9Sstevel@tonic-gate 			au_uwrite(au_to_text(drvname));
34727c478bd9Sstevel@tonic-gate 			return;
34737c478bd9Sstevel@tonic-gate 		}
34747c478bd9Sstevel@tonic-gate 
34757c478bd9Sstevel@tonic-gate 		if (mc_drvname[0] != '\0') {
34767c478bd9Sstevel@tonic-gate 				/* safety */
34777c478bd9Sstevel@tonic-gate 			mc_drvname[MAXMODCONFNAME-1] = '\0';
34787c478bd9Sstevel@tonic-gate 			au_uwrite(au_to_text(mc_drvname));
34797c478bd9Sstevel@tonic-gate 		} else
34807c478bd9Sstevel@tonic-gate 			au_uwrite(au_to_text("no drvname"));
34817c478bd9Sstevel@tonic-gate 
34827c478bd9Sstevel@tonic-gate 		num_aliases = STRUCT_FGET(mc, num_aliases);
34837c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32(5, "", (uint32_t)num_aliases));
34847c478bd9Sstevel@tonic-gate 		ap = (caddr_t)STRUCT_FGETP(mc, ap);
34857c478bd9Sstevel@tonic-gate 		name = kmem_alloc(MAXMODCONFNAME, KM_SLEEP);
34867c478bd9Sstevel@tonic-gate 		STRUCT_INIT(alias, model);
34877c478bd9Sstevel@tonic-gate 		for (i = 0; i < num_aliases; i++) {
34887c478bd9Sstevel@tonic-gate 			bzero((caddr_t)STRUCT_BUF(alias),
3489745b2690Stz 			    STRUCT_SIZE(alias));
34907c478bd9Sstevel@tonic-gate 			if (copyin((caddr_t)ap, (caddr_t)STRUCT_BUF(alias),
3491745b2690Stz 			    STRUCT_SIZE(alias)) != 0)
34927c478bd9Sstevel@tonic-gate 				break;
34937c478bd9Sstevel@tonic-gate 			if (copyinstr(STRUCT_FGETP(alias, a_name), name,
34947c478bd9Sstevel@tonic-gate 			    MAXMODCONFNAME, NULL) != 0) {
34957c478bd9Sstevel@tonic-gate 				break;
34967c478bd9Sstevel@tonic-gate 			}
34977c478bd9Sstevel@tonic-gate 
34987c478bd9Sstevel@tonic-gate 			au_uwrite(au_to_text(name));
34997c478bd9Sstevel@tonic-gate 			ap = (caddr_t)STRUCT_FGETP(alias, a_next);
35007c478bd9Sstevel@tonic-gate 		}
35017c478bd9Sstevel@tonic-gate 		kmem_free(name, MAXMODCONFNAME);
35027c478bd9Sstevel@tonic-gate 		break;
35037c478bd9Sstevel@tonic-gate 	}
35047c478bd9Sstevel@tonic-gate 	default:
35057c478bd9Sstevel@tonic-gate 		break;
35067c478bd9Sstevel@tonic-gate 	}
35077c478bd9Sstevel@tonic-gate }
35087c478bd9Sstevel@tonic-gate 
35097c478bd9Sstevel@tonic-gate 
35107c478bd9Sstevel@tonic-gate /*ARGSUSED*/
35117c478bd9Sstevel@tonic-gate static void
35127c478bd9Sstevel@tonic-gate auf_accept(
35137c478bd9Sstevel@tonic-gate 	struct t_audit_data *tad,
35147c478bd9Sstevel@tonic-gate 	int	error,
35157c478bd9Sstevel@tonic-gate 	rval_t	*rval)
35167c478bd9Sstevel@tonic-gate {
35177c478bd9Sstevel@tonic-gate 	uint32_t scid;
35187c478bd9Sstevel@tonic-gate 	uint32_t sy_flags;
35197c478bd9Sstevel@tonic-gate 	int fd;
35207c478bd9Sstevel@tonic-gate 	struct sonode *so;
35217c478bd9Sstevel@tonic-gate 	char so_laddr[sizeof (struct sockaddr_in6)];
35227c478bd9Sstevel@tonic-gate 	char so_faddr[sizeof (struct sockaddr_in6)];
35237c478bd9Sstevel@tonic-gate 	int err;
35247c478bd9Sstevel@tonic-gate 	short so_family, so_type;
35257c478bd9Sstevel@tonic-gate 	int add_sock_token = 0;
35267c478bd9Sstevel@tonic-gate 
35277c478bd9Sstevel@tonic-gate 	/* need to determine type of executing binary */
35287c478bd9Sstevel@tonic-gate 	scid = tad->tad_scid;
35297c478bd9Sstevel@tonic-gate #ifdef _SYSCALL32_IMPL
35307c478bd9Sstevel@tonic-gate 	if (lwp_getdatamodel(ttolwp(curthread)) == DATAMODEL_NATIVE)
35317c478bd9Sstevel@tonic-gate 		sy_flags = sysent[scid].sy_flags & SE_RVAL_MASK;
35327c478bd9Sstevel@tonic-gate 	else
35337c478bd9Sstevel@tonic-gate 		sy_flags = sysent32[scid].sy_flags & SE_RVAL_MASK;
35347c478bd9Sstevel@tonic-gate #else
35357c478bd9Sstevel@tonic-gate 	sy_flags = sysent[scid].sy_flags & SE_RVAL_MASK;
35367c478bd9Sstevel@tonic-gate #endif
35377c478bd9Sstevel@tonic-gate 	if (sy_flags == SE_32RVAL1)
35387c478bd9Sstevel@tonic-gate 		fd = rval->r_val1;
35397c478bd9Sstevel@tonic-gate 	if (sy_flags == (SE_32RVAL2|SE_32RVAL1))
35407c478bd9Sstevel@tonic-gate 		fd = rval->r_val1;
35417c478bd9Sstevel@tonic-gate 	if (sy_flags == SE_64RVAL)
35427c478bd9Sstevel@tonic-gate 		fd = (int)rval->r_vals;
35437c478bd9Sstevel@tonic-gate 
35447c478bd9Sstevel@tonic-gate 	if (error) {
35457c478bd9Sstevel@tonic-gate 		/* can't trust socket contents. Just return */
35467c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32(1, "so", (uint32_t)fd));
35477c478bd9Sstevel@tonic-gate 		return;
35487c478bd9Sstevel@tonic-gate 	}
35497c478bd9Sstevel@tonic-gate 
3550745b2690Stz 	if ((so = getsonode(fd, &err, NULL)) == NULL) {
35517c478bd9Sstevel@tonic-gate 		/*
35527c478bd9Sstevel@tonic-gate 		 * not security relevant if doing a accept from non socket
35537c478bd9Sstevel@tonic-gate 		 * so no extra tokens. Should probably turn off audit record
35547c478bd9Sstevel@tonic-gate 		 * generation here.
35557c478bd9Sstevel@tonic-gate 		 */
35567c478bd9Sstevel@tonic-gate 		return;
35577c478bd9Sstevel@tonic-gate 	}
35587c478bd9Sstevel@tonic-gate 
35597c478bd9Sstevel@tonic-gate 	so_family = so->so_family;
35607c478bd9Sstevel@tonic-gate 	so_type   = so->so_type;
35617c478bd9Sstevel@tonic-gate 
35627c478bd9Sstevel@tonic-gate 	switch (so_family) {
35637c478bd9Sstevel@tonic-gate 	case AF_INET:
35647c478bd9Sstevel@tonic-gate 	case AF_INET6:
35657c478bd9Sstevel@tonic-gate 		/*
35667c478bd9Sstevel@tonic-gate 		 * XXX - what about other socket types for AF_INET (e.g. DGRAM)
35677c478bd9Sstevel@tonic-gate 		 */
35687c478bd9Sstevel@tonic-gate 		if (so->so_type == SOCK_STREAM) {
35690f1702c5SYu Xiangning 			socklen_t len;
35707c478bd9Sstevel@tonic-gate 
35717c478bd9Sstevel@tonic-gate 			bzero((void *)so_laddr, sizeof (so_laddr));
35727c478bd9Sstevel@tonic-gate 			bzero((void *)so_faddr, sizeof (so_faddr));
35737c478bd9Sstevel@tonic-gate 
35740f1702c5SYu Xiangning 			len = sizeof (so_laddr);
35750f1702c5SYu Xiangning 			(void) socket_getsockname(so,
35760f1702c5SYu Xiangning 			    (struct sockaddr *)so_laddr, &len, CRED());
35770f1702c5SYu Xiangning 			len = sizeof (so_faddr);
35780f1702c5SYu Xiangning 			(void) socket_getpeername(so,
35790f1702c5SYu Xiangning 			    (struct sockaddr *)so_faddr, &len, B_FALSE, CRED());
35807c478bd9Sstevel@tonic-gate 
35817c478bd9Sstevel@tonic-gate 			add_sock_token = 1;
35827c478bd9Sstevel@tonic-gate 		}
35837c478bd9Sstevel@tonic-gate 		break;
35847c478bd9Sstevel@tonic-gate 
35857c478bd9Sstevel@tonic-gate 	default:
35867c478bd9Sstevel@tonic-gate 		/* AF_UNIX, AF_ROUTE, AF_KEY do not support accept */
35877c478bd9Sstevel@tonic-gate 		break;
35887c478bd9Sstevel@tonic-gate 	}
35897c478bd9Sstevel@tonic-gate 
35907c478bd9Sstevel@tonic-gate 	releasef(fd);
35917c478bd9Sstevel@tonic-gate 
35927c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_arg32(1, "so", (uint32_t)fd));
35937c478bd9Sstevel@tonic-gate 
35947c478bd9Sstevel@tonic-gate 	if (add_sock_token == 0) {
35957c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32(0, "family", (uint32_t)(so_family)));
35967c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32(0, "type", (uint32_t)(so_type)));
35977c478bd9Sstevel@tonic-gate 		return;
35987c478bd9Sstevel@tonic-gate 	}
35997c478bd9Sstevel@tonic-gate 
36007c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_socket_ex(so_family, so_type, so_laddr, so_faddr));
36017c478bd9Sstevel@tonic-gate 
36027c478bd9Sstevel@tonic-gate }
36037c478bd9Sstevel@tonic-gate 
36047c478bd9Sstevel@tonic-gate /*ARGSUSED*/
36057c478bd9Sstevel@tonic-gate static void
36067c478bd9Sstevel@tonic-gate auf_bind(struct t_audit_data *tad, int error, rval_t *rvp)
36077c478bd9Sstevel@tonic-gate {
36087c478bd9Sstevel@tonic-gate 	struct a {
36097c478bd9Sstevel@tonic-gate 		long	fd;
36107c478bd9Sstevel@tonic-gate 		long	addr;
36117c478bd9Sstevel@tonic-gate 		long	len;
36127c478bd9Sstevel@tonic-gate 	} *uap = (struct a *)ttolwp(curthread)->lwp_ap;
36137c478bd9Sstevel@tonic-gate 
36147c478bd9Sstevel@tonic-gate 	struct sonode *so;
36157c478bd9Sstevel@tonic-gate 	char so_laddr[sizeof (struct sockaddr_in6)];
36167c478bd9Sstevel@tonic-gate 	char so_faddr[sizeof (struct sockaddr_in6)];
36177c478bd9Sstevel@tonic-gate 	int err, fd;
36180f1702c5SYu Xiangning 	socklen_t len;
36197c478bd9Sstevel@tonic-gate 	short so_family, so_type;
36207c478bd9Sstevel@tonic-gate 	int add_sock_token = 0;
36217c478bd9Sstevel@tonic-gate 
36227c478bd9Sstevel@tonic-gate 	fd = (int)uap->fd;
36237c478bd9Sstevel@tonic-gate 
36247c478bd9Sstevel@tonic-gate 	/*
36257c478bd9Sstevel@tonic-gate 	 * bind failed, then nothing extra to add to audit record.
36267c478bd9Sstevel@tonic-gate 	 */
36277c478bd9Sstevel@tonic-gate 	if (error) {
36287c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32(1, "so", (uint32_t)fd));
36297c478bd9Sstevel@tonic-gate 		/* XXX may want to add failed address some day */
36307c478bd9Sstevel@tonic-gate 		return;
36317c478bd9Sstevel@tonic-gate 	}
36327c478bd9Sstevel@tonic-gate 
3633745b2690Stz 	if ((so = getsonode(fd, &err, NULL)) == NULL) {
36347c478bd9Sstevel@tonic-gate 		/*
36357c478bd9Sstevel@tonic-gate 		 * not security relevant if doing a bind from non socket
36367c478bd9Sstevel@tonic-gate 		 * so no extra tokens. Should probably turn off audit record
36377c478bd9Sstevel@tonic-gate 		 * generation here.
36387c478bd9Sstevel@tonic-gate 		 */
36397c478bd9Sstevel@tonic-gate 		return;
36407c478bd9Sstevel@tonic-gate 	}
36417c478bd9Sstevel@tonic-gate 
36427c478bd9Sstevel@tonic-gate 	so_family = so->so_family;
36437c478bd9Sstevel@tonic-gate 	so_type   = so->so_type;
36447c478bd9Sstevel@tonic-gate 
36457c478bd9Sstevel@tonic-gate 	switch (so_family) {
36467c478bd9Sstevel@tonic-gate 	case AF_INET:
36477c478bd9Sstevel@tonic-gate 	case AF_INET6:
36487c478bd9Sstevel@tonic-gate 
36497c478bd9Sstevel@tonic-gate 		bzero(so_faddr, sizeof (so_faddr));
36500f1702c5SYu Xiangning 		len = sizeof (so_faddr);
36517c478bd9Sstevel@tonic-gate 
36520f1702c5SYu Xiangning 		(void) socket_getpeername(so,
36530f1702c5SYu Xiangning 		    (struct sockaddr *)so_faddr, &len, B_FALSE, CRED());
36547c478bd9Sstevel@tonic-gate 		add_sock_token = 1;
36557c478bd9Sstevel@tonic-gate 
36567c478bd9Sstevel@tonic-gate 		break;
36577c478bd9Sstevel@tonic-gate 
36587c478bd9Sstevel@tonic-gate 	case AF_UNIX:
36597c478bd9Sstevel@tonic-gate 		/* token added by lookup */
36607c478bd9Sstevel@tonic-gate 		break;
36617c478bd9Sstevel@tonic-gate 	default:
36627c478bd9Sstevel@tonic-gate 		/* AF_ROUTE, AF_KEY do not support accept */
36637c478bd9Sstevel@tonic-gate 		break;
36647c478bd9Sstevel@tonic-gate 	}
36657c478bd9Sstevel@tonic-gate 
36667c478bd9Sstevel@tonic-gate 	releasef(fd);
36677c478bd9Sstevel@tonic-gate 
36687c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_arg32(1, "so", (uint32_t)fd));
36697c478bd9Sstevel@tonic-gate 
36707c478bd9Sstevel@tonic-gate 	if (add_sock_token == 0) {
36717c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32(1, "family", (uint32_t)(so_family)));
36727c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32(1, "type", (uint32_t)(so_type)));
36737c478bd9Sstevel@tonic-gate 		return;
36747c478bd9Sstevel@tonic-gate 	}
36757c478bd9Sstevel@tonic-gate 
36767c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_socket_ex(so_family, so_type, so_laddr, so_faddr));
36777c478bd9Sstevel@tonic-gate 
36787c478bd9Sstevel@tonic-gate }
36797c478bd9Sstevel@tonic-gate 
36807c478bd9Sstevel@tonic-gate /*ARGSUSED*/
36817c478bd9Sstevel@tonic-gate static void
36827c478bd9Sstevel@tonic-gate auf_connect(struct t_audit_data *tad, int error, rval_t *rval)
36837c478bd9Sstevel@tonic-gate {
36847c478bd9Sstevel@tonic-gate 	struct a {
36857c478bd9Sstevel@tonic-gate 		long	fd;
36867c478bd9Sstevel@tonic-gate 		long	addr;
36877c478bd9Sstevel@tonic-gate 		long	len;
36887c478bd9Sstevel@tonic-gate 	} *uap = (struct a *)ttolwp(curthread)->lwp_ap;
36897c478bd9Sstevel@tonic-gate 
36907c478bd9Sstevel@tonic-gate 	struct sonode *so;
36917c478bd9Sstevel@tonic-gate 	char so_laddr[sizeof (struct sockaddr_in6)];
36927c478bd9Sstevel@tonic-gate 	char so_faddr[sizeof (struct sockaddr_in6)];
36937c478bd9Sstevel@tonic-gate 	int err, fd;
36940f1702c5SYu Xiangning 	socklen_t len;
36957c478bd9Sstevel@tonic-gate 	short so_family, so_type;
36967c478bd9Sstevel@tonic-gate 	int add_sock_token = 0;
36977c478bd9Sstevel@tonic-gate 
36987c478bd9Sstevel@tonic-gate 	fd = (int)uap->fd;
36997c478bd9Sstevel@tonic-gate 
37007c478bd9Sstevel@tonic-gate 
3701745b2690Stz 	if ((so = getsonode(fd, &err, NULL)) == NULL) {
37027c478bd9Sstevel@tonic-gate 		/*
37037c478bd9Sstevel@tonic-gate 		 * not security relevant if doing a connect from non socket
37047c478bd9Sstevel@tonic-gate 		 * so no extra tokens. Should probably turn off audit record
37057c478bd9Sstevel@tonic-gate 		 * generation here.
37067c478bd9Sstevel@tonic-gate 		 */
37077c478bd9Sstevel@tonic-gate 		return;
37087c478bd9Sstevel@tonic-gate 	}
37097c478bd9Sstevel@tonic-gate 
37107c478bd9Sstevel@tonic-gate 	so_family = so->so_family;
37117c478bd9Sstevel@tonic-gate 	so_type   = so->so_type;
37127c478bd9Sstevel@tonic-gate 
37137c478bd9Sstevel@tonic-gate 	switch (so_family) {
37147c478bd9Sstevel@tonic-gate 	case AF_INET:
37157c478bd9Sstevel@tonic-gate 	case AF_INET6:
37167c478bd9Sstevel@tonic-gate 
37177c478bd9Sstevel@tonic-gate 		bzero(so_laddr, sizeof (so_laddr));
37187c478bd9Sstevel@tonic-gate 		bzero(so_faddr, sizeof (so_faddr));
37197c478bd9Sstevel@tonic-gate 
37200f1702c5SYu Xiangning 		len = sizeof (so_laddr);
37210f1702c5SYu Xiangning 		(void) socket_getsockname(so, (struct sockaddr *)so_laddr,
37220f1702c5SYu Xiangning 		    &len, CRED());
37237c478bd9Sstevel@tonic-gate 		if (error) {
37247c478bd9Sstevel@tonic-gate 			if (uap->addr == NULL)
37257c478bd9Sstevel@tonic-gate 				break;
37267c478bd9Sstevel@tonic-gate 			if (uap->len <= 0)
37277c478bd9Sstevel@tonic-gate 				break;
37287c478bd9Sstevel@tonic-gate 			len = min(uap->len, sizeof (so_faddr));
37297c478bd9Sstevel@tonic-gate 			if (copyin((caddr_t)(uap->addr), so_faddr, len) != 0)
37307c478bd9Sstevel@tonic-gate 				break;
37317c478bd9Sstevel@tonic-gate #ifdef NOTYET
37327c478bd9Sstevel@tonic-gate 			au_uwrite(au_to_data(AUP_HEX, AUR_CHAR, len, so_faddr));
37337c478bd9Sstevel@tonic-gate #endif
37347c478bd9Sstevel@tonic-gate 		} else {
37357c478bd9Sstevel@tonic-gate 			/* sanity check on length */
37360f1702c5SYu Xiangning 			len = sizeof (so_faddr);
37370f1702c5SYu Xiangning 			(void) socket_getpeername(so,
37380f1702c5SYu Xiangning 			    (struct sockaddr *)so_faddr, &len, B_FALSE, CRED());
37397c478bd9Sstevel@tonic-gate 		}
37407c478bd9Sstevel@tonic-gate 
37417c478bd9Sstevel@tonic-gate 		add_sock_token = 1;
37427c478bd9Sstevel@tonic-gate 
37437c478bd9Sstevel@tonic-gate 		break;
37447c478bd9Sstevel@tonic-gate 
37457c478bd9Sstevel@tonic-gate 	case AF_UNIX:
37467c478bd9Sstevel@tonic-gate 		/* does a lookup on name */
37477c478bd9Sstevel@tonic-gate 		break;
37487c478bd9Sstevel@tonic-gate 
37497c478bd9Sstevel@tonic-gate 	default:
37507c478bd9Sstevel@tonic-gate 		/* AF_ROUTE, AF_KEY do not support accept */
37517c478bd9Sstevel@tonic-gate 		break;
37527c478bd9Sstevel@tonic-gate 	}
37537c478bd9Sstevel@tonic-gate 
37547c478bd9Sstevel@tonic-gate 	releasef(fd);
37557c478bd9Sstevel@tonic-gate 
37567c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_arg32(1, "so", (uint32_t)fd));
37577c478bd9Sstevel@tonic-gate 
37587c478bd9Sstevel@tonic-gate 	if (add_sock_token == 0) {
37597c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32(1, "family", (uint32_t)(so_family)));
37607c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32(1, "type", (uint32_t)(so_type)));
37617c478bd9Sstevel@tonic-gate 		return;
37627c478bd9Sstevel@tonic-gate 	}
37637c478bd9Sstevel@tonic-gate 
37647c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_socket_ex(so_family, so_type, so_laddr, so_faddr));
37657c478bd9Sstevel@tonic-gate 
37667c478bd9Sstevel@tonic-gate }
37677c478bd9Sstevel@tonic-gate 
37687c478bd9Sstevel@tonic-gate /*ARGSUSED*/
37697c478bd9Sstevel@tonic-gate static void
37707c478bd9Sstevel@tonic-gate aus_shutdown(struct t_audit_data *tad)
37717c478bd9Sstevel@tonic-gate {
37727c478bd9Sstevel@tonic-gate 	struct a {
37737c478bd9Sstevel@tonic-gate 		long	fd;
37747c478bd9Sstevel@tonic-gate 		long	how;
37757c478bd9Sstevel@tonic-gate 	} *uap = (struct a *)ttolwp(curthread)->lwp_ap;
37767c478bd9Sstevel@tonic-gate 
37777c478bd9Sstevel@tonic-gate 	struct sonode *so;
37787c478bd9Sstevel@tonic-gate 	char so_laddr[sizeof (struct sockaddr_in6)];
37797c478bd9Sstevel@tonic-gate 	char so_faddr[sizeof (struct sockaddr_in6)];
37807c478bd9Sstevel@tonic-gate 	int err, fd;
37810f1702c5SYu Xiangning 	socklen_t len;
37827c478bd9Sstevel@tonic-gate 	short so_family, so_type;
37837c478bd9Sstevel@tonic-gate 	int add_sock_token = 0;
37847c478bd9Sstevel@tonic-gate 	file_t *fp;				/* unix domain sockets */
37857c478bd9Sstevel@tonic-gate 	struct f_audit_data *fad;		/* unix domain sockets */
37867c478bd9Sstevel@tonic-gate 
37877c478bd9Sstevel@tonic-gate 	fd = (int)uap->fd;
37887c478bd9Sstevel@tonic-gate 
3789745b2690Stz 	if ((so = getsonode(fd, &err, &fp)) == NULL) {
37907c478bd9Sstevel@tonic-gate 		/*
37917c478bd9Sstevel@tonic-gate 		 * not security relevant if doing a shutdown using non socket
37927c478bd9Sstevel@tonic-gate 		 * so no extra tokens. Should probably turn off audit record
37937c478bd9Sstevel@tonic-gate 		 * generation here.
37947c478bd9Sstevel@tonic-gate 		 */
37957c478bd9Sstevel@tonic-gate 		return;
37967c478bd9Sstevel@tonic-gate 	}
37977c478bd9Sstevel@tonic-gate 
37987c478bd9Sstevel@tonic-gate 	so_family = so->so_family;
37997c478bd9Sstevel@tonic-gate 	so_type   = so->so_type;
38007c478bd9Sstevel@tonic-gate 
38017c478bd9Sstevel@tonic-gate 	switch (so_family) {
38027c478bd9Sstevel@tonic-gate 	case AF_INET:
38037c478bd9Sstevel@tonic-gate 	case AF_INET6:
38047c478bd9Sstevel@tonic-gate 
38057c478bd9Sstevel@tonic-gate 		bzero(so_laddr, sizeof (so_laddr));
38067c478bd9Sstevel@tonic-gate 		bzero(so_faddr, sizeof (so_faddr));
38077c478bd9Sstevel@tonic-gate 
38080f1702c5SYu Xiangning 		len = sizeof (so_laddr);
38090f1702c5SYu Xiangning 		(void) socket_getsockname(so,
38100f1702c5SYu Xiangning 		    (struct sockaddr *)so_laddr, &len, CRED());
38110f1702c5SYu Xiangning 		len = sizeof (so_faddr);
38120f1702c5SYu Xiangning 		(void) socket_getpeername(so,
38130f1702c5SYu Xiangning 		    (struct sockaddr *)so_faddr, &len, B_FALSE, CRED());
38147c478bd9Sstevel@tonic-gate 
38157c478bd9Sstevel@tonic-gate 		add_sock_token = 1;
38167c478bd9Sstevel@tonic-gate 
38177c478bd9Sstevel@tonic-gate 		break;
38187c478bd9Sstevel@tonic-gate 
38197c478bd9Sstevel@tonic-gate 	case AF_UNIX:
38207c478bd9Sstevel@tonic-gate 
38217c478bd9Sstevel@tonic-gate 		/* get path from file struct here */
38227c478bd9Sstevel@tonic-gate 		fad = F2A(fp);
38237c478bd9Sstevel@tonic-gate 		ASSERT(fad);
38247c478bd9Sstevel@tonic-gate 
38257c478bd9Sstevel@tonic-gate 		if (fad->fad_aupath != NULL) {
38267c478bd9Sstevel@tonic-gate 			au_uwrite(au_to_path(fad->fad_aupath));
38277c478bd9Sstevel@tonic-gate 		} else {
38287c478bd9Sstevel@tonic-gate 			au_uwrite(au_to_arg32(1, "no path: fd", fd));
38297c478bd9Sstevel@tonic-gate 		}
38307c478bd9Sstevel@tonic-gate 
38317c478bd9Sstevel@tonic-gate 		audit_attributes(fp->f_vnode);
38327c478bd9Sstevel@tonic-gate 
38337c478bd9Sstevel@tonic-gate 		break;
38347c478bd9Sstevel@tonic-gate 
38357c478bd9Sstevel@tonic-gate 	default:
38367c478bd9Sstevel@tonic-gate 		/*
38377c478bd9Sstevel@tonic-gate 		 * AF_KEY and AF_ROUTE support shutdown. No socket token
38387c478bd9Sstevel@tonic-gate 		 * added.
38397c478bd9Sstevel@tonic-gate 		 */
38407c478bd9Sstevel@tonic-gate 		break;
38417c478bd9Sstevel@tonic-gate 	}
38427c478bd9Sstevel@tonic-gate 
38437c478bd9Sstevel@tonic-gate 	releasef(fd);
38447c478bd9Sstevel@tonic-gate 
38457c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_arg32(1, "so", (uint32_t)fd));
38467c478bd9Sstevel@tonic-gate 
38477c478bd9Sstevel@tonic-gate 	if (add_sock_token == 0) {
38487c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32(1, "family", (uint32_t)(so_family)));
38497c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32(1, "type", (uint32_t)(so_type)));
38507c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32(2, "how", (uint32_t)(uap->how)));
38517c478bd9Sstevel@tonic-gate 		return;
38527c478bd9Sstevel@tonic-gate 	}
38537c478bd9Sstevel@tonic-gate 
38547c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_arg32(2, "how", (uint32_t)(uap->how)));
38557c478bd9Sstevel@tonic-gate 
38567c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_socket_ex(so_family, so_type, so_laddr, so_faddr));
38577c478bd9Sstevel@tonic-gate 
38587c478bd9Sstevel@tonic-gate }
38597c478bd9Sstevel@tonic-gate 
38607c478bd9Sstevel@tonic-gate /*ARGSUSED*/
38617c478bd9Sstevel@tonic-gate static void
38627c478bd9Sstevel@tonic-gate auf_setsockopt(struct t_audit_data *tad, int error, rval_t *rval)
38637c478bd9Sstevel@tonic-gate {
38647c478bd9Sstevel@tonic-gate 	struct a {
38657c478bd9Sstevel@tonic-gate 		long	fd;
38667c478bd9Sstevel@tonic-gate 		long	level;
38677c478bd9Sstevel@tonic-gate 		long	optname;
38687c478bd9Sstevel@tonic-gate 		long	*optval;
38697c478bd9Sstevel@tonic-gate 		long	optlen;
38707c478bd9Sstevel@tonic-gate 	} *uap = (struct a *)ttolwp(curthread)->lwp_ap;
38717c478bd9Sstevel@tonic-gate 
38727c478bd9Sstevel@tonic-gate 	struct sonode	*so;
38737c478bd9Sstevel@tonic-gate 	char so_laddr[sizeof (struct sockaddr_in6)];
38747c478bd9Sstevel@tonic-gate 	char so_faddr[sizeof (struct sockaddr_in6)];
38757c478bd9Sstevel@tonic-gate 	char		val[AU_BUFSIZE];
38767c478bd9Sstevel@tonic-gate 	int		err, fd;
38770f1702c5SYu Xiangning 	socklen_t	len;
38787c478bd9Sstevel@tonic-gate 	short so_family, so_type;
38797c478bd9Sstevel@tonic-gate 	int		add_sock_token = 0;
38807c478bd9Sstevel@tonic-gate 	file_t *fp;				/* unix domain sockets */
38817c478bd9Sstevel@tonic-gate 	struct f_audit_data *fad;		/* unix domain sockets */
38827c478bd9Sstevel@tonic-gate 
38837c478bd9Sstevel@tonic-gate 	fd = (int)uap->fd;
38847c478bd9Sstevel@tonic-gate 
38857c478bd9Sstevel@tonic-gate 	if (error) {
38867c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32(1, "so", (uint32_t)fd));
38877c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32(2, "level", (uint32_t)uap->level));
38887c478bd9Sstevel@tonic-gate 		/* XXX may want to include other arguments */
38897c478bd9Sstevel@tonic-gate 		return;
38907c478bd9Sstevel@tonic-gate 	}
38917c478bd9Sstevel@tonic-gate 
3892745b2690Stz 	if ((so = getsonode(fd, &err, &fp)) == NULL) {
38937c478bd9Sstevel@tonic-gate 		/*
38947c478bd9Sstevel@tonic-gate 		 * not security relevant if doing a setsockopt from non socket
38957c478bd9Sstevel@tonic-gate 		 * so no extra tokens. Should probably turn off audit record
38967c478bd9Sstevel@tonic-gate 		 * generation here.
38977c478bd9Sstevel@tonic-gate 		 */
38987c478bd9Sstevel@tonic-gate 		return;
38997c478bd9Sstevel@tonic-gate 	}
39007c478bd9Sstevel@tonic-gate 
39017c478bd9Sstevel@tonic-gate 	so_family = so->so_family;
39027c478bd9Sstevel@tonic-gate 	so_type   = so->so_type;
39037c478bd9Sstevel@tonic-gate 
39047c478bd9Sstevel@tonic-gate 	switch (so_family) {
39057c478bd9Sstevel@tonic-gate 	case AF_INET:
39067c478bd9Sstevel@tonic-gate 	case AF_INET6:
39077c478bd9Sstevel@tonic-gate 		bzero((void *)so_laddr, sizeof (so_laddr));
39087c478bd9Sstevel@tonic-gate 		bzero((void *)so_faddr, sizeof (so_faddr));
39097c478bd9Sstevel@tonic-gate 
39107c478bd9Sstevel@tonic-gate 		/* get local and foreign addresses */
39110f1702c5SYu Xiangning 		len = sizeof (so_laddr);
39120f1702c5SYu Xiangning 		(void) socket_getsockname(so, (struct sockaddr *)so_laddr,
39130f1702c5SYu Xiangning 		    &len, CRED());
39140f1702c5SYu Xiangning 		len = sizeof (so_faddr);
39150f1702c5SYu Xiangning 		(void) socket_getpeername(so, (struct sockaddr *)so_faddr,
39160f1702c5SYu Xiangning 		    &len, B_FALSE, CRED());
39177c478bd9Sstevel@tonic-gate 
39187c478bd9Sstevel@tonic-gate 		add_sock_token = 1;
39197c478bd9Sstevel@tonic-gate 
39207c478bd9Sstevel@tonic-gate 		break;
39217c478bd9Sstevel@tonic-gate 
39227c478bd9Sstevel@tonic-gate 	case AF_UNIX:
39237c478bd9Sstevel@tonic-gate 
39247c478bd9Sstevel@tonic-gate 		/* get path from file struct here */
39257c478bd9Sstevel@tonic-gate 		fad = F2A(fp);
39267c478bd9Sstevel@tonic-gate 		ASSERT(fad);
39277c478bd9Sstevel@tonic-gate 
39287c478bd9Sstevel@tonic-gate 		if (fad->fad_aupath != NULL) {
39297c478bd9Sstevel@tonic-gate 			au_uwrite(au_to_path(fad->fad_aupath));
39307c478bd9Sstevel@tonic-gate 		} else {
39317c478bd9Sstevel@tonic-gate 			au_uwrite(au_to_arg32(1, "no path: fd", fd));
39327c478bd9Sstevel@tonic-gate 		}
39337c478bd9Sstevel@tonic-gate 
39347c478bd9Sstevel@tonic-gate 		audit_attributes(fp->f_vnode);
39357c478bd9Sstevel@tonic-gate 
39367c478bd9Sstevel@tonic-gate 		break;
39377c478bd9Sstevel@tonic-gate 
39387c478bd9Sstevel@tonic-gate 	default:
39397c478bd9Sstevel@tonic-gate 		/*
39407c478bd9Sstevel@tonic-gate 		 * AF_KEY and AF_ROUTE support setsockopt. No socket token
39417c478bd9Sstevel@tonic-gate 		 * added.
39427c478bd9Sstevel@tonic-gate 		 */
39437c478bd9Sstevel@tonic-gate 		break;
39447c478bd9Sstevel@tonic-gate 	}
39457c478bd9Sstevel@tonic-gate 
39467c478bd9Sstevel@tonic-gate 	releasef(fd);
39477c478bd9Sstevel@tonic-gate 
39487c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_arg32(1, "so", (uint32_t)fd));
39497c478bd9Sstevel@tonic-gate 
39507c478bd9Sstevel@tonic-gate 	if (add_sock_token == 0) {
39517c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32(1, "family", (uint32_t)(so_family)));
39527c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32(1, "type", (uint32_t)(so_type)));
39537c478bd9Sstevel@tonic-gate 	}
39547c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_arg32(2, "level", (uint32_t)(uap->level)));
39557c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_arg32(3, "optname", (uint32_t)(uap->optname)));
39567c478bd9Sstevel@tonic-gate 
39577c478bd9Sstevel@tonic-gate 	bzero(val, sizeof (val));
39587c478bd9Sstevel@tonic-gate 	len = min(uap->optlen, sizeof (val));
39597c478bd9Sstevel@tonic-gate 	if ((len > 0) &&
39607c478bd9Sstevel@tonic-gate 	    (copyin((caddr_t)(uap->optval), (caddr_t)val, len) == 0)) {
39617c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32(5, "optlen", (uint32_t)(uap->optlen)));
39627c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_data(AUP_HEX, AUR_BYTE, len, val));
39637c478bd9Sstevel@tonic-gate 	}
39647c478bd9Sstevel@tonic-gate 
39657c478bd9Sstevel@tonic-gate 	if (add_sock_token == 0)
39667c478bd9Sstevel@tonic-gate 		return;
39677c478bd9Sstevel@tonic-gate 
39687c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_socket_ex(so_family, so_type, so_laddr, so_faddr));
39697c478bd9Sstevel@tonic-gate 
39707c478bd9Sstevel@tonic-gate }
39717c478bd9Sstevel@tonic-gate 
39727c478bd9Sstevel@tonic-gate /*ARGSUSED*/
39737c478bd9Sstevel@tonic-gate static void
39747c478bd9Sstevel@tonic-gate aus_sockconfig(tad)
39757c478bd9Sstevel@tonic-gate 	struct t_audit_data *tad;
39767c478bd9Sstevel@tonic-gate {
39777c478bd9Sstevel@tonic-gate 	struct a {
39783e95bd4aSAnders Persson 		long	cmd;
39793e95bd4aSAnders Persson 		long	arg1;
39803e95bd4aSAnders Persson 		long	arg2;
39813e95bd4aSAnders Persson 		long	arg3;
39823e95bd4aSAnders Persson 		long	arg4;
39837c478bd9Sstevel@tonic-gate 	} *uap = (struct a *)ttolwp(curthread)->lwp_ap;
39847c478bd9Sstevel@tonic-gate 
39853e95bd4aSAnders Persson 	char	*buf;
39863e95bd4aSAnders Persson 	int	buflen;
39877c478bd9Sstevel@tonic-gate 	size_t	size;
39887c478bd9Sstevel@tonic-gate 
39893e95bd4aSAnders Persson 	au_uwrite(au_to_arg32(1, "cmd", (uint_t)uap->cmd));
39903e95bd4aSAnders Persson 	switch (uap->cmd) {
39913e95bd4aSAnders Persson 	case SOCKCONFIG_ADD_SOCK:
39923e95bd4aSAnders Persson 	case SOCKCONFIG_REMOVE_SOCK:
39933e95bd4aSAnders Persson 		au_uwrite(au_to_arg32(2, "domain", (uint32_t)uap->arg1));
39943e95bd4aSAnders Persson 		au_uwrite(au_to_arg32(3, "type", (uint32_t)uap->arg2));
39953e95bd4aSAnders Persson 		au_uwrite(au_to_arg32(4, "protocol", (uint32_t)uap->arg3));
39967c478bd9Sstevel@tonic-gate 
39973e95bd4aSAnders Persson 		if (uap->arg4 == 0) {
39983e95bd4aSAnders Persson 			au_uwrite(au_to_arg32(5, "devpath", (uint32_t)0));
39993e95bd4aSAnders Persson 		} else {
40003e95bd4aSAnders Persson 			buflen = MAXPATHLEN + 1;
40013e95bd4aSAnders Persson 			buf = kmem_alloc(buflen, KM_SLEEP);
40023e95bd4aSAnders Persson 			if (copyinstr((caddr_t)uap->arg4, buf, buflen,
40033e95bd4aSAnders Persson 			    &size)) {
40043e95bd4aSAnders Persson 				kmem_free(buf, buflen);
40053e95bd4aSAnders Persson 				return;
40063e95bd4aSAnders Persson 			}
40077c478bd9Sstevel@tonic-gate 
40083e95bd4aSAnders Persson 			if (size > MAXPATHLEN) {
40093e95bd4aSAnders Persson 				kmem_free(buf, buflen);
40103e95bd4aSAnders Persson 				return;
40113e95bd4aSAnders Persson 			}
40123e95bd4aSAnders Persson 
40133e95bd4aSAnders Persson 			au_uwrite(au_to_text(buf));
40143e95bd4aSAnders Persson 			kmem_free(buf, buflen);
40157c478bd9Sstevel@tonic-gate 		}
40163e95bd4aSAnders Persson 		break;
40173e95bd4aSAnders Persson 	case SOCKCONFIG_ADD_FILTER:
40183e95bd4aSAnders Persson 	case SOCKCONFIG_REMOVE_FILTER:
40193e95bd4aSAnders Persson 		buflen = FILNAME_MAX;
40203e95bd4aSAnders Persson 		buf = kmem_alloc(buflen, KM_SLEEP);
40217c478bd9Sstevel@tonic-gate 
40223e95bd4aSAnders Persson 		if (copyinstr((caddr_t)uap->arg1, buf, buflen, &size)) {
40233e95bd4aSAnders Persson 			kmem_free(buf, buflen);
40247c478bd9Sstevel@tonic-gate 			return;
40257c478bd9Sstevel@tonic-gate 		}
40267c478bd9Sstevel@tonic-gate 
40273e95bd4aSAnders Persson 		au_uwrite(au_to_text(buf));
40283e95bd4aSAnders Persson 		kmem_free(buf, buflen);
40293e95bd4aSAnders Persson 		break;
40303e95bd4aSAnders Persson 	default:
40313e95bd4aSAnders Persson 		break;
40327c478bd9Sstevel@tonic-gate 	}
40337c478bd9Sstevel@tonic-gate }
40347c478bd9Sstevel@tonic-gate 
40357c478bd9Sstevel@tonic-gate /*
40367c478bd9Sstevel@tonic-gate  * only audit recvmsg when the system call represents the creation of a new
40377c478bd9Sstevel@tonic-gate  * circuit. This effectively occurs for all UDP packets and may occur for
40387c478bd9Sstevel@tonic-gate  * special TCP situations where the local host has not set a local address
40397c478bd9Sstevel@tonic-gate  * in the socket structure.
40407c478bd9Sstevel@tonic-gate  */
40417c478bd9Sstevel@tonic-gate /*ARGSUSED*/
40427c478bd9Sstevel@tonic-gate static void
40437c478bd9Sstevel@tonic-gate auf_recvmsg(
40447c478bd9Sstevel@tonic-gate 	struct t_audit_data *tad,
40457c478bd9Sstevel@tonic-gate 	int error,
40467c478bd9Sstevel@tonic-gate 	rval_t *rvp)
40477c478bd9Sstevel@tonic-gate {
40487c478bd9Sstevel@tonic-gate 	struct a {
40497c478bd9Sstevel@tonic-gate 		long	fd;
40507c478bd9Sstevel@tonic-gate 		long	msg;	/* struct msghdr */
40517c478bd9Sstevel@tonic-gate 		long	flags;
40527c478bd9Sstevel@tonic-gate 	} *uap = (struct a *)ttolwp(curthread)->lwp_ap;
40537c478bd9Sstevel@tonic-gate 
40547c478bd9Sstevel@tonic-gate 	struct sonode	*so;
40557c478bd9Sstevel@tonic-gate 	STRUCT_DECL(msghdr, msg);
40567c478bd9Sstevel@tonic-gate 	caddr_t msg_name;
40577c478bd9Sstevel@tonic-gate 	socklen_t msg_namelen;
40587c478bd9Sstevel@tonic-gate 	int fd;
40597c478bd9Sstevel@tonic-gate 	int err;
40607c478bd9Sstevel@tonic-gate 	char so_laddr[sizeof (struct sockaddr_in6)];
40617c478bd9Sstevel@tonic-gate 	char so_faddr[sizeof (struct sockaddr_in6)];
40620f1702c5SYu Xiangning 	socklen_t len;
40637c478bd9Sstevel@tonic-gate 	file_t *fp;				/* unix domain sockets */
40647c478bd9Sstevel@tonic-gate 	struct f_audit_data *fad;		/* unix domain sockets */
40657c478bd9Sstevel@tonic-gate 	short so_family, so_type;
40667c478bd9Sstevel@tonic-gate 	int add_sock_token = 0;
40679e9e6ab8Spaulson 	au_kcontext_t	*kctx = GET_KCTX_PZ;
40687c478bd9Sstevel@tonic-gate 
40697c478bd9Sstevel@tonic-gate 	fd = (int)uap->fd;
40707c478bd9Sstevel@tonic-gate 
40717c478bd9Sstevel@tonic-gate 	/* bail if an error */
40727c478bd9Sstevel@tonic-gate 	if (error) {
40737c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32(1, "so", (uint32_t)fd));
40747c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32(3, "flags", (uint32_t)(uap->flags)));
40757c478bd9Sstevel@tonic-gate 		return;
40767c478bd9Sstevel@tonic-gate 	}
40777c478bd9Sstevel@tonic-gate 
4078745b2690Stz 	if ((so = getsonode(fd, &err, &fp)) == NULL) {
40797c478bd9Sstevel@tonic-gate 		/*
40807c478bd9Sstevel@tonic-gate 		 * not security relevant if doing a recvmsg from non socket
40817c478bd9Sstevel@tonic-gate 		 * so no extra tokens. Should probably turn off audit record
40827c478bd9Sstevel@tonic-gate 		 * generation here.
40837c478bd9Sstevel@tonic-gate 		 */
40847c478bd9Sstevel@tonic-gate 		return;
40857c478bd9Sstevel@tonic-gate 	}
40867c478bd9Sstevel@tonic-gate 
40877c478bd9Sstevel@tonic-gate 	so_family = so->so_family;
40887c478bd9Sstevel@tonic-gate 	so_type   = so->so_type;
40897c478bd9Sstevel@tonic-gate 
40907c478bd9Sstevel@tonic-gate 	/*
40917c478bd9Sstevel@tonic-gate 	 * only putout SOCKET_EX token if INET/INET6 family.
40927c478bd9Sstevel@tonic-gate 	 * XXX - what do we do about other families?
40937c478bd9Sstevel@tonic-gate 	 */
40947c478bd9Sstevel@tonic-gate 
40957c478bd9Sstevel@tonic-gate 	switch (so_family) {
40967c478bd9Sstevel@tonic-gate 	case AF_INET:
40977c478bd9Sstevel@tonic-gate 	case AF_INET6:
40987c478bd9Sstevel@tonic-gate 
40997c478bd9Sstevel@tonic-gate 		/*
41007c478bd9Sstevel@tonic-gate 		 * if datagram type socket, then just use what is in
41017c478bd9Sstevel@tonic-gate 		 * socket structure for local address.
41027c478bd9Sstevel@tonic-gate 		 * XXX - what do we do for other types?
41037c478bd9Sstevel@tonic-gate 		 */
41047c478bd9Sstevel@tonic-gate 		if ((so->so_type == SOCK_DGRAM) ||
41057c478bd9Sstevel@tonic-gate 		    (so->so_type == SOCK_RAW)) {
41067c478bd9Sstevel@tonic-gate 			add_sock_token = 1;
41077c478bd9Sstevel@tonic-gate 
41087c478bd9Sstevel@tonic-gate 			bzero((void *)so_laddr, sizeof (so_laddr));
41097c478bd9Sstevel@tonic-gate 			bzero((void *)so_faddr, sizeof (so_faddr));
41107c478bd9Sstevel@tonic-gate 
41117c478bd9Sstevel@tonic-gate 			/* get local address */
41120f1702c5SYu Xiangning 			len = sizeof (so_laddr);
41130f1702c5SYu Xiangning 			(void) socket_getsockname(so,
41140f1702c5SYu Xiangning 			    (struct sockaddr *)so_laddr, &len, CRED());
41157c478bd9Sstevel@tonic-gate 
41167c478bd9Sstevel@tonic-gate 			/* get peer address */
41177c478bd9Sstevel@tonic-gate 			STRUCT_INIT(msg, get_udatamodel());
41187c478bd9Sstevel@tonic-gate 
41197c478bd9Sstevel@tonic-gate 			if (copyin((caddr_t)(uap->msg),
41207c478bd9Sstevel@tonic-gate 			    (caddr_t)STRUCT_BUF(msg), STRUCT_SIZE(msg)) != 0) {
41217c478bd9Sstevel@tonic-gate 				break;
41227c478bd9Sstevel@tonic-gate 			}
41237c478bd9Sstevel@tonic-gate 			msg_name = (caddr_t)STRUCT_FGETP(msg, msg_name);
41247c478bd9Sstevel@tonic-gate 			if (msg_name == NULL) {
41257c478bd9Sstevel@tonic-gate 				break;
41267c478bd9Sstevel@tonic-gate 			}
41277c478bd9Sstevel@tonic-gate 
41287c478bd9Sstevel@tonic-gate 			/* length is value from recvmsg - sanity check */
41297c478bd9Sstevel@tonic-gate 			msg_namelen = (socklen_t)STRUCT_FGET(msg, msg_namelen);
41307c478bd9Sstevel@tonic-gate 			if (msg_namelen == 0) {
41317c478bd9Sstevel@tonic-gate 				break;
41327c478bd9Sstevel@tonic-gate 			}
41337c478bd9Sstevel@tonic-gate 			if (copyin(msg_name, so_faddr,
41347c478bd9Sstevel@tonic-gate 			    sizeof (so_faddr)) != 0) {
41357c478bd9Sstevel@tonic-gate 				break;
41367c478bd9Sstevel@tonic-gate 			}
41377c478bd9Sstevel@tonic-gate 
41387c478bd9Sstevel@tonic-gate 		} else if (so->so_type == SOCK_STREAM) {
41397c478bd9Sstevel@tonic-gate 
41407c478bd9Sstevel@tonic-gate 			/* get path from file struct here */
41417c478bd9Sstevel@tonic-gate 			fad = F2A(fp);
41427c478bd9Sstevel@tonic-gate 			ASSERT(fad);
41437c478bd9Sstevel@tonic-gate 
41447c478bd9Sstevel@tonic-gate 			/*
41457c478bd9Sstevel@tonic-gate 			 * already processed this file for read attempt
41467c478bd9Sstevel@tonic-gate 			 */
41477c478bd9Sstevel@tonic-gate 			if (fad->fad_flags & FAD_READ) {
41487c478bd9Sstevel@tonic-gate 				/* don't want to audit every recvmsg attempt */
41497c478bd9Sstevel@tonic-gate 				tad->tad_flag = 0;
41507c478bd9Sstevel@tonic-gate 				/* free any residual audit data */
4151005d3febSMarek Pospisil 				au_close(kctx, &(u_ad), 0, 0, 0, NULL);
41527c478bd9Sstevel@tonic-gate 				releasef(fd);
41537c478bd9Sstevel@tonic-gate 				return;
41547c478bd9Sstevel@tonic-gate 			}
41557c478bd9Sstevel@tonic-gate 			/*
41567c478bd9Sstevel@tonic-gate 			 * mark things so we know what happened and don't
41577c478bd9Sstevel@tonic-gate 			 * repeat things
41587c478bd9Sstevel@tonic-gate 			 */
41597c478bd9Sstevel@tonic-gate 			fad->fad_flags |= FAD_READ;
41607c478bd9Sstevel@tonic-gate 
41617c478bd9Sstevel@tonic-gate 			bzero((void *)so_laddr, sizeof (so_laddr));
41627c478bd9Sstevel@tonic-gate 			bzero((void *)so_faddr, sizeof (so_faddr));
41637c478bd9Sstevel@tonic-gate 
41640f1702c5SYu Xiangning 			/* get local and foreign addresses */
41650f1702c5SYu Xiangning 			len = sizeof (so_laddr);
41660f1702c5SYu Xiangning 			(void) socket_getsockname(so,
41670f1702c5SYu Xiangning 			    (struct sockaddr *)so_laddr, &len, CRED());
41680f1702c5SYu Xiangning 			len = sizeof (so_faddr);
41690f1702c5SYu Xiangning 			(void) socket_getpeername(so,
41700f1702c5SYu Xiangning 			    (struct sockaddr *)so_faddr, &len, B_FALSE, CRED());
41717c478bd9Sstevel@tonic-gate 
41727c478bd9Sstevel@tonic-gate 			add_sock_token = 1;
41737c478bd9Sstevel@tonic-gate 		}
41747c478bd9Sstevel@tonic-gate 
41757c478bd9Sstevel@tonic-gate 		/* XXX - what about SOCK_RDM/SOCK_SEQPACKET ??? */
41767c478bd9Sstevel@tonic-gate 
41777c478bd9Sstevel@tonic-gate 		break;
41787c478bd9Sstevel@tonic-gate 
41797c478bd9Sstevel@tonic-gate 	case AF_UNIX:
41807c478bd9Sstevel@tonic-gate 		/*
41817c478bd9Sstevel@tonic-gate 		 * first check if this is first time through. Too much
41827c478bd9Sstevel@tonic-gate 		 * duplicate code to put this in an aui_ routine.
41837c478bd9Sstevel@tonic-gate 		 */
41847c478bd9Sstevel@tonic-gate 
41857c478bd9Sstevel@tonic-gate 		/* get path from file struct here */
41867c478bd9Sstevel@tonic-gate 		fad = F2A(fp);
41877c478bd9Sstevel@tonic-gate 		ASSERT(fad);
41887c478bd9Sstevel@tonic-gate 
41897c478bd9Sstevel@tonic-gate 		/*
41907c478bd9Sstevel@tonic-gate 		 * already processed this file for read attempt
41917c478bd9Sstevel@tonic-gate 		 */
41927c478bd9Sstevel@tonic-gate 		if (fad->fad_flags & FAD_READ) {
41937c478bd9Sstevel@tonic-gate 			releasef(fd);
41947c478bd9Sstevel@tonic-gate 			/* don't want to audit every recvmsg attempt */
41957c478bd9Sstevel@tonic-gate 			tad->tad_flag = 0;
41967c478bd9Sstevel@tonic-gate 			/* free any residual audit data */
4197005d3febSMarek Pospisil 			au_close(kctx, &(u_ad), 0, 0, 0, NULL);
41987c478bd9Sstevel@tonic-gate 			return;
41997c478bd9Sstevel@tonic-gate 		}
42007c478bd9Sstevel@tonic-gate 		/*
42017c478bd9Sstevel@tonic-gate 		 * mark things so we know what happened and don't
42027c478bd9Sstevel@tonic-gate 		 * repeat things
42037c478bd9Sstevel@tonic-gate 		 */
42047c478bd9Sstevel@tonic-gate 		fad->fad_flags |= FAD_READ;
42057c478bd9Sstevel@tonic-gate 
42067c478bd9Sstevel@tonic-gate 		if (fad->fad_aupath != NULL) {
42077c478bd9Sstevel@tonic-gate 			au_uwrite(au_to_path(fad->fad_aupath));
42087c478bd9Sstevel@tonic-gate 		} else {
42097c478bd9Sstevel@tonic-gate 			au_uwrite(au_to_arg32(1, "no path: fd", fd));
42107c478bd9Sstevel@tonic-gate 		}
42117c478bd9Sstevel@tonic-gate 
42127c478bd9Sstevel@tonic-gate 		audit_attributes(fp->f_vnode);
42137c478bd9Sstevel@tonic-gate 
42147c478bd9Sstevel@tonic-gate 		releasef(fd);
42157c478bd9Sstevel@tonic-gate 
42167c478bd9Sstevel@tonic-gate 		return;
42177c478bd9Sstevel@tonic-gate 
42187c478bd9Sstevel@tonic-gate 	default:
42197c478bd9Sstevel@tonic-gate 		break;
42207c478bd9Sstevel@tonic-gate 
42217c478bd9Sstevel@tonic-gate 	}
42227c478bd9Sstevel@tonic-gate 
42237c478bd9Sstevel@tonic-gate 	releasef(fd);
42247c478bd9Sstevel@tonic-gate 
42257c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_arg32(1, "so", (uint32_t)fd));
42267c478bd9Sstevel@tonic-gate 
42277c478bd9Sstevel@tonic-gate 	if (add_sock_token == 0) {
42287c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32(1, "family", (uint32_t)so_family));
42297c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32(1, "type", (uint32_t)so_type));
42307c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32(3, "flags", (uint32_t)(uap->flags)));
42317c478bd9Sstevel@tonic-gate 		return;
42327c478bd9Sstevel@tonic-gate 	}
42337c478bd9Sstevel@tonic-gate 
42347c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_arg32(3, "flags", (uint32_t)(uap->flags)));
42357c478bd9Sstevel@tonic-gate 
42367c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_socket_ex(so_family, so_type, so_laddr, so_faddr));
42377c478bd9Sstevel@tonic-gate 
42387c478bd9Sstevel@tonic-gate }
42397c478bd9Sstevel@tonic-gate 
42407c478bd9Sstevel@tonic-gate /*ARGSUSED*/
42417c478bd9Sstevel@tonic-gate static void
42427c478bd9Sstevel@tonic-gate auf_recvfrom(
42437c478bd9Sstevel@tonic-gate 	struct t_audit_data *tad,
42447c478bd9Sstevel@tonic-gate 	int error,
42457c478bd9Sstevel@tonic-gate 	rval_t *rvp)
42467c478bd9Sstevel@tonic-gate {
42477c478bd9Sstevel@tonic-gate 
42487c478bd9Sstevel@tonic-gate 	struct a {
42497c478bd9Sstevel@tonic-gate 		long	fd;
42507c478bd9Sstevel@tonic-gate 		long	msg;	/* char */
42517c478bd9Sstevel@tonic-gate 		long	len;
42527c478bd9Sstevel@tonic-gate 		long	flags;
42537c478bd9Sstevel@tonic-gate 		long	from;	/* struct sockaddr */
42547c478bd9Sstevel@tonic-gate 		long	fromlen;
42557c478bd9Sstevel@tonic-gate 	} *uap = (struct a *)ttolwp(curthread)->lwp_ap;
42567c478bd9Sstevel@tonic-gate 
42577c478bd9Sstevel@tonic-gate 	socklen_t	fromlen;
42587c478bd9Sstevel@tonic-gate 	struct sonode	*so;
42597c478bd9Sstevel@tonic-gate 	char so_laddr[sizeof (struct sockaddr_in6)];
42607c478bd9Sstevel@tonic-gate 	char so_faddr[sizeof (struct sockaddr_in6)];
42617c478bd9Sstevel@tonic-gate 	int		fd;
42627c478bd9Sstevel@tonic-gate 	short so_family, so_type;
42637c478bd9Sstevel@tonic-gate 	int add_sock_token = 0;
42640f1702c5SYu Xiangning 	socklen_t len;
42657c478bd9Sstevel@tonic-gate 	int err;
42667c478bd9Sstevel@tonic-gate 	struct file *fp;
42677c478bd9Sstevel@tonic-gate 	struct f_audit_data *fad;		/* unix domain sockets */
42689e9e6ab8Spaulson 	au_kcontext_t	*kctx = GET_KCTX_PZ;
42697c478bd9Sstevel@tonic-gate 
42707c478bd9Sstevel@tonic-gate 	fd = (int)uap->fd;
42717c478bd9Sstevel@tonic-gate 
42727c478bd9Sstevel@tonic-gate 	/* bail if an error */
42737c478bd9Sstevel@tonic-gate 	if (error) {
42747c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32(1, "so", (uint32_t)fd));
42757c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32(3, "flags", (uint32_t)(uap->flags)));
42767c478bd9Sstevel@tonic-gate 		return;
42777c478bd9Sstevel@tonic-gate 	}
42787c478bd9Sstevel@tonic-gate 
4279745b2690Stz 	if ((so = getsonode(fd, &err, &fp)) == NULL) {
42807c478bd9Sstevel@tonic-gate 		/*
42817c478bd9Sstevel@tonic-gate 		 * not security relevant if doing a recvmsg from non socket
42827c478bd9Sstevel@tonic-gate 		 * so no extra tokens. Should probably turn off audit record
42837c478bd9Sstevel@tonic-gate 		 * generation here.
42847c478bd9Sstevel@tonic-gate 		 */
42857c478bd9Sstevel@tonic-gate 		return;
42867c478bd9Sstevel@tonic-gate 	}
42877c478bd9Sstevel@tonic-gate 
42887c478bd9Sstevel@tonic-gate 	so_family = so->so_family;
42897c478bd9Sstevel@tonic-gate 	so_type   = so->so_type;
42907c478bd9Sstevel@tonic-gate 
42917c478bd9Sstevel@tonic-gate 	/*
42927c478bd9Sstevel@tonic-gate 	 * only putout SOCKET_EX token if INET/INET6 family.
42937c478bd9Sstevel@tonic-gate 	 * XXX - what do we do about other families?
42947c478bd9Sstevel@tonic-gate 	 */
42957c478bd9Sstevel@tonic-gate 
42967c478bd9Sstevel@tonic-gate 	switch (so_family) {
42977c478bd9Sstevel@tonic-gate 	case AF_INET:
42987c478bd9Sstevel@tonic-gate 	case AF_INET6:
42997c478bd9Sstevel@tonic-gate 
43007c478bd9Sstevel@tonic-gate 		/*
43017c478bd9Sstevel@tonic-gate 		 * if datagram type socket, then just use what is in
43027c478bd9Sstevel@tonic-gate 		 * socket structure for local address.
43037c478bd9Sstevel@tonic-gate 		 * XXX - what do we do for other types?
43047c478bd9Sstevel@tonic-gate 		 */
43057c478bd9Sstevel@tonic-gate 		if ((so->so_type == SOCK_DGRAM) ||
43067c478bd9Sstevel@tonic-gate 		    (so->so_type == SOCK_RAW)) {
43077c478bd9Sstevel@tonic-gate 			add_sock_token = 1;
43087c478bd9Sstevel@tonic-gate 
43097c478bd9Sstevel@tonic-gate 			/* get local address */
43100f1702c5SYu Xiangning 			len = sizeof (so_laddr);
43110f1702c5SYu Xiangning 			(void) socket_getsockname(so,
43120f1702c5SYu Xiangning 			    (struct sockaddr *)so_laddr, &len, CRED());
43137c478bd9Sstevel@tonic-gate 
43147c478bd9Sstevel@tonic-gate 			/* get peer address */
43157c478bd9Sstevel@tonic-gate 			bzero((void *)so_faddr, sizeof (so_faddr));
43167c478bd9Sstevel@tonic-gate 
43177c478bd9Sstevel@tonic-gate 			/* sanity check */
43187c478bd9Sstevel@tonic-gate 			if (uap->from == NULL)
43197c478bd9Sstevel@tonic-gate 				break;
43207c478bd9Sstevel@tonic-gate 
43217c478bd9Sstevel@tonic-gate 			/* sanity checks */
43227c478bd9Sstevel@tonic-gate 			if (uap->fromlen == 0)
43237c478bd9Sstevel@tonic-gate 				break;
43247c478bd9Sstevel@tonic-gate 
43257c478bd9Sstevel@tonic-gate 			if (copyin((caddr_t)(uap->fromlen), (caddr_t)&fromlen,
43267c478bd9Sstevel@tonic-gate 			    sizeof (fromlen)) != 0)
43277c478bd9Sstevel@tonic-gate 				break;
43287c478bd9Sstevel@tonic-gate 
43297c478bd9Sstevel@tonic-gate 			if (fromlen == 0)
43307c478bd9Sstevel@tonic-gate 				break;
43317c478bd9Sstevel@tonic-gate 
43327c478bd9Sstevel@tonic-gate 			/* enforce maximum size */
43337c478bd9Sstevel@tonic-gate 			if (fromlen > sizeof (so_faddr))
43347c478bd9Sstevel@tonic-gate 				fromlen = sizeof (so_faddr);
43357c478bd9Sstevel@tonic-gate 
43367c478bd9Sstevel@tonic-gate 			if (copyin((caddr_t)(uap->from), so_faddr,
43377c478bd9Sstevel@tonic-gate 			    fromlen) != 0)
43387c478bd9Sstevel@tonic-gate 				break;
43397c478bd9Sstevel@tonic-gate 
43407c478bd9Sstevel@tonic-gate 		} else if (so->so_type == SOCK_STREAM) {
43417c478bd9Sstevel@tonic-gate 
43427c478bd9Sstevel@tonic-gate 			/* get path from file struct here */
43437c478bd9Sstevel@tonic-gate 			fad = F2A(fp);
43447c478bd9Sstevel@tonic-gate 			ASSERT(fad);
43457c478bd9Sstevel@tonic-gate 
43467c478bd9Sstevel@tonic-gate 			/*
43477c478bd9Sstevel@tonic-gate 			 * already processed this file for read attempt
43487c478bd9Sstevel@tonic-gate 			 */
43497c478bd9Sstevel@tonic-gate 			if (fad->fad_flags & FAD_READ) {
43507c478bd9Sstevel@tonic-gate 				/* don't want to audit every recvfrom attempt */
43517c478bd9Sstevel@tonic-gate 				tad->tad_flag = 0;
43527c478bd9Sstevel@tonic-gate 				/* free any residual audit data */
4353005d3febSMarek Pospisil 				au_close(kctx, &(u_ad), 0, 0, 0, NULL);
43547c478bd9Sstevel@tonic-gate 				releasef(fd);
43557c478bd9Sstevel@tonic-gate 				return;
43567c478bd9Sstevel@tonic-gate 			}
43577c478bd9Sstevel@tonic-gate 			/*
43587c478bd9Sstevel@tonic-gate 			 * mark things so we know what happened and don't
43597c478bd9Sstevel@tonic-gate 			 * repeat things
43607c478bd9Sstevel@tonic-gate 			 */
43617c478bd9Sstevel@tonic-gate 			fad->fad_flags |= FAD_READ;
43627c478bd9Sstevel@tonic-gate 
43637c478bd9Sstevel@tonic-gate 			bzero((void *)so_laddr, sizeof (so_laddr));
43647c478bd9Sstevel@tonic-gate 			bzero((void *)so_faddr, sizeof (so_faddr));
43657c478bd9Sstevel@tonic-gate 
43660f1702c5SYu Xiangning 			/* get local and foreign addresses */
43670f1702c5SYu Xiangning 			len = sizeof (so_laddr);
43680f1702c5SYu Xiangning 			(void) socket_getsockname(so,
43690f1702c5SYu Xiangning 			    (struct sockaddr *)so_laddr, &len, CRED());
43700f1702c5SYu Xiangning 			len = sizeof (so_faddr);
43710f1702c5SYu Xiangning 			(void) socket_getpeername(so,
43720f1702c5SYu Xiangning 			    (struct sockaddr *)so_faddr, &len, B_FALSE, CRED());
43737c478bd9Sstevel@tonic-gate 
43747c478bd9Sstevel@tonic-gate 			add_sock_token = 1;
43757c478bd9Sstevel@tonic-gate 		}
43767c478bd9Sstevel@tonic-gate 
43777c478bd9Sstevel@tonic-gate 		/* XXX - what about SOCK_RDM/SOCK_SEQPACKET ??? */
43787c478bd9Sstevel@tonic-gate 
43797c478bd9Sstevel@tonic-gate 		break;
43807c478bd9Sstevel@tonic-gate 
43817c478bd9Sstevel@tonic-gate 	case AF_UNIX:
43827c478bd9Sstevel@tonic-gate 		/*
43837c478bd9Sstevel@tonic-gate 		 * first check if this is first time through. Too much
43847c478bd9Sstevel@tonic-gate 		 * duplicate code to put this in an aui_ routine.
43857c478bd9Sstevel@tonic-gate 		 */
43867c478bd9Sstevel@tonic-gate 
43877c478bd9Sstevel@tonic-gate 		/* get path from file struct here */
43887c478bd9Sstevel@tonic-gate 		fad = F2A(fp);
43897c478bd9Sstevel@tonic-gate 		ASSERT(fad);
43907c478bd9Sstevel@tonic-gate 
43917c478bd9Sstevel@tonic-gate 		/*
43927c478bd9Sstevel@tonic-gate 		 * already processed this file for read attempt
43937c478bd9Sstevel@tonic-gate 		 */
43947c478bd9Sstevel@tonic-gate 		if (fad->fad_flags & FAD_READ) {
43957c478bd9Sstevel@tonic-gate 			/* don't want to audit every recvfrom attempt */
43967c478bd9Sstevel@tonic-gate 			tad->tad_flag = 0;
43977c478bd9Sstevel@tonic-gate 			/* free any residual audit data */
4398005d3febSMarek Pospisil 			au_close(kctx, &(u_ad), 0, 0, 0, NULL);
43997c478bd9Sstevel@tonic-gate 			releasef(fd);
44007c478bd9Sstevel@tonic-gate 			return;
44017c478bd9Sstevel@tonic-gate 		}
44027c478bd9Sstevel@tonic-gate 		/*
44037c478bd9Sstevel@tonic-gate 		 * mark things so we know what happened and don't
44047c478bd9Sstevel@tonic-gate 		 * repeat things
44057c478bd9Sstevel@tonic-gate 		 */
44067c478bd9Sstevel@tonic-gate 		fad->fad_flags |= FAD_READ;
44077c478bd9Sstevel@tonic-gate 
44087c478bd9Sstevel@tonic-gate 		if (fad->fad_aupath != NULL) {
44097c478bd9Sstevel@tonic-gate 			au_uwrite(au_to_path(fad->fad_aupath));
44107c478bd9Sstevel@tonic-gate 		} else {
44117c478bd9Sstevel@tonic-gate 			au_uwrite(au_to_arg32(1, "no path: fd", fd));
44127c478bd9Sstevel@tonic-gate 		}
44137c478bd9Sstevel@tonic-gate 
44147c478bd9Sstevel@tonic-gate 		audit_attributes(fp->f_vnode);
44157c478bd9Sstevel@tonic-gate 
44167c478bd9Sstevel@tonic-gate 		releasef(fd);
44177c478bd9Sstevel@tonic-gate 
44187c478bd9Sstevel@tonic-gate 		return;
44197c478bd9Sstevel@tonic-gate 
44207c478bd9Sstevel@tonic-gate 	default:
44217c478bd9Sstevel@tonic-gate 		break;
44227c478bd9Sstevel@tonic-gate 
44237c478bd9Sstevel@tonic-gate 	}
44247c478bd9Sstevel@tonic-gate 
44257c478bd9Sstevel@tonic-gate 	releasef(fd);
44267c478bd9Sstevel@tonic-gate 
44277c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_arg32(1, "so", (uint32_t)fd));
44287c478bd9Sstevel@tonic-gate 
44297c478bd9Sstevel@tonic-gate 	if (add_sock_token == 0) {
44307c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32(1, "family", (uint32_t)so_family));
44317c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32(1, "type", (uint32_t)so_type));
44327c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32(3, "flags", (uint32_t)(uap->flags)));
44337c478bd9Sstevel@tonic-gate 		return;
44347c478bd9Sstevel@tonic-gate 	}
44357c478bd9Sstevel@tonic-gate 
44367c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_arg32(3, "flags", (uint32_t)(uap->flags)));
44377c478bd9Sstevel@tonic-gate 
44387c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_socket_ex(so_family, so_type, so_laddr, so_faddr));
44397c478bd9Sstevel@tonic-gate }
44407c478bd9Sstevel@tonic-gate 
44417c478bd9Sstevel@tonic-gate /*ARGSUSED*/
44427c478bd9Sstevel@tonic-gate static void
44437c478bd9Sstevel@tonic-gate auf_sendmsg(struct t_audit_data *tad, int error, rval_t *rval)
44447c478bd9Sstevel@tonic-gate {
44457c478bd9Sstevel@tonic-gate 	struct a {
44467c478bd9Sstevel@tonic-gate 		long	fd;
44477c478bd9Sstevel@tonic-gate 		long	msg;	/* struct msghdr */
44487c478bd9Sstevel@tonic-gate 		long	flags;
44497c478bd9Sstevel@tonic-gate 	} *uap = (struct a *)ttolwp(curthread)->lwp_ap;
44507c478bd9Sstevel@tonic-gate 
44517c478bd9Sstevel@tonic-gate 	struct sonode	*so;
44527c478bd9Sstevel@tonic-gate 	char so_laddr[sizeof (struct sockaddr_in6)];
44537c478bd9Sstevel@tonic-gate 	char so_faddr[sizeof (struct sockaddr_in6)];
44547c478bd9Sstevel@tonic-gate 	int		err;
44557c478bd9Sstevel@tonic-gate 	int		fd;
44567c478bd9Sstevel@tonic-gate 	short so_family, so_type;
44577c478bd9Sstevel@tonic-gate 	int		add_sock_token = 0;
44580f1702c5SYu Xiangning 	socklen_t	len;
44597c478bd9Sstevel@tonic-gate 	struct file	*fp;
44607c478bd9Sstevel@tonic-gate 	struct f_audit_data *fad;
44617c478bd9Sstevel@tonic-gate 	caddr_t		msg_name;
44627c478bd9Sstevel@tonic-gate 	socklen_t	msg_namelen;
44637c478bd9Sstevel@tonic-gate 	STRUCT_DECL(msghdr, msg);
44649e9e6ab8Spaulson 	au_kcontext_t	*kctx = GET_KCTX_PZ;
44657c478bd9Sstevel@tonic-gate 
44667c478bd9Sstevel@tonic-gate 	fd = (int)uap->fd;
44677c478bd9Sstevel@tonic-gate 
44687c478bd9Sstevel@tonic-gate 	/* bail if an error */
44697c478bd9Sstevel@tonic-gate 	if (error) {
44707c478bd9Sstevel@tonic-gate 		/* XXX include destination address from system call arguments */
44717c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32(1, "so", (uint32_t)fd));
44727c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32(3, "flags", (uint32_t)(uap->flags)));
44737c478bd9Sstevel@tonic-gate 		return;
44747c478bd9Sstevel@tonic-gate 	}
44757c478bd9Sstevel@tonic-gate 
4476745b2690Stz 	if ((so = getsonode(fd, &err, &fp)) == NULL) {
44777c478bd9Sstevel@tonic-gate 		/*
44787c478bd9Sstevel@tonic-gate 		 * not security relevant if doing a sendmsg from non socket
44797c478bd9Sstevel@tonic-gate 		 * so no extra tokens. Should probably turn off audit record
44807c478bd9Sstevel@tonic-gate 		 * generation here.
44817c478bd9Sstevel@tonic-gate 		 */
44827c478bd9Sstevel@tonic-gate 		return;
44837c478bd9Sstevel@tonic-gate 	}
44847c478bd9Sstevel@tonic-gate 
44857c478bd9Sstevel@tonic-gate 	so_family = so->so_family;
44867c478bd9Sstevel@tonic-gate 	so_type   = so->so_type;
44877c478bd9Sstevel@tonic-gate 
44887c478bd9Sstevel@tonic-gate 	switch (so_family) {
44897c478bd9Sstevel@tonic-gate 	case AF_INET:
44907c478bd9Sstevel@tonic-gate 	case AF_INET6:
44917c478bd9Sstevel@tonic-gate 		/*
44927c478bd9Sstevel@tonic-gate 		 * if datagram type socket, then just use what is in
44937c478bd9Sstevel@tonic-gate 		 * socket structure for local address.
44947c478bd9Sstevel@tonic-gate 		 * XXX - what do we do for other types?
44957c478bd9Sstevel@tonic-gate 		 */
44967c478bd9Sstevel@tonic-gate 		if ((so->so_type == SOCK_DGRAM) ||
44977c478bd9Sstevel@tonic-gate 		    (so->so_type == SOCK_RAW)) {
44987c478bd9Sstevel@tonic-gate 
44997c478bd9Sstevel@tonic-gate 			bzero((void *)so_laddr, sizeof (so_laddr));
45007c478bd9Sstevel@tonic-gate 			bzero((void *)so_faddr, sizeof (so_faddr));
45017c478bd9Sstevel@tonic-gate 
45027c478bd9Sstevel@tonic-gate 			/* get local address */
45030f1702c5SYu Xiangning 			len = sizeof (so_laddr);
45040f1702c5SYu Xiangning 			(void) socket_getsockname(so,
45050f1702c5SYu Xiangning 			    (struct sockaddr *)so_laddr, &len, CRED());
45067c478bd9Sstevel@tonic-gate 
45077c478bd9Sstevel@tonic-gate 			/* get peer address */
45087c478bd9Sstevel@tonic-gate 			STRUCT_INIT(msg, get_udatamodel());
45097c478bd9Sstevel@tonic-gate 
45107c478bd9Sstevel@tonic-gate 			if (copyin((caddr_t)(uap->msg),
45117c478bd9Sstevel@tonic-gate 			    (caddr_t)STRUCT_BUF(msg), STRUCT_SIZE(msg)) != 0) {
45127c478bd9Sstevel@tonic-gate 				break;
45137c478bd9Sstevel@tonic-gate 			}
45147c478bd9Sstevel@tonic-gate 			msg_name = (caddr_t)STRUCT_FGETP(msg, msg_name);
45157c478bd9Sstevel@tonic-gate 			if (msg_name == NULL)
45167c478bd9Sstevel@tonic-gate 				break;
45177c478bd9Sstevel@tonic-gate 
45187c478bd9Sstevel@tonic-gate 			msg_namelen = (socklen_t)STRUCT_FGET(msg, msg_namelen);
45197c478bd9Sstevel@tonic-gate 			/* length is value from recvmsg - sanity check */
45207c478bd9Sstevel@tonic-gate 			if (msg_namelen == 0)
45217c478bd9Sstevel@tonic-gate 				break;
45227c478bd9Sstevel@tonic-gate 
45237c478bd9Sstevel@tonic-gate 			if (copyin(msg_name, so_faddr,
45247c478bd9Sstevel@tonic-gate 			    sizeof (so_faddr)) != 0)
45257c478bd9Sstevel@tonic-gate 				break;
45267c478bd9Sstevel@tonic-gate 
45277c478bd9Sstevel@tonic-gate 			add_sock_token = 1;
45287c478bd9Sstevel@tonic-gate 
45297c478bd9Sstevel@tonic-gate 		} else if (so->so_type == SOCK_STREAM) {
45307c478bd9Sstevel@tonic-gate 
45317c478bd9Sstevel@tonic-gate 			/* get path from file struct here */
45327c478bd9Sstevel@tonic-gate 			fad = F2A(fp);
45337c478bd9Sstevel@tonic-gate 			ASSERT(fad);
45347c478bd9Sstevel@tonic-gate 
45357c478bd9Sstevel@tonic-gate 			/*
45367c478bd9Sstevel@tonic-gate 			 * already processed this file for write attempt
45377c478bd9Sstevel@tonic-gate 			 */
45387c478bd9Sstevel@tonic-gate 			if (fad->fad_flags & FAD_WRITE) {
45397c478bd9Sstevel@tonic-gate 				releasef(fd);
45407c478bd9Sstevel@tonic-gate 				/* don't want to audit every sendmsg attempt */
45417c478bd9Sstevel@tonic-gate 				tad->tad_flag = 0;
45427c478bd9Sstevel@tonic-gate 				/* free any residual audit data */
4543005d3febSMarek Pospisil 				au_close(kctx, &(u_ad), 0, 0, 0, NULL);
45447c478bd9Sstevel@tonic-gate 				return;
45457c478bd9Sstevel@tonic-gate 			}
45467c478bd9Sstevel@tonic-gate 
45477c478bd9Sstevel@tonic-gate 			/*
45487c478bd9Sstevel@tonic-gate 			 * mark things so we know what happened and don't
45497c478bd9Sstevel@tonic-gate 			 * repeat things
45507c478bd9Sstevel@tonic-gate 			 */
45517c478bd9Sstevel@tonic-gate 			fad->fad_flags |= FAD_WRITE;
45527c478bd9Sstevel@tonic-gate 
45537c478bd9Sstevel@tonic-gate 			bzero((void *)so_laddr, sizeof (so_laddr));
45547c478bd9Sstevel@tonic-gate 			bzero((void *)so_faddr, sizeof (so_faddr));
45557c478bd9Sstevel@tonic-gate 
45560f1702c5SYu Xiangning 			/* get local and foreign addresses */
45570f1702c5SYu Xiangning 			len = sizeof (so_laddr);
45580f1702c5SYu Xiangning 			(void) socket_getsockname(so,
45590f1702c5SYu Xiangning 			    (struct sockaddr *)so_laddr, &len, CRED());
45600f1702c5SYu Xiangning 			len = sizeof (so_faddr);
45610f1702c5SYu Xiangning 			(void) socket_getpeername(so,
45620f1702c5SYu Xiangning 			    (struct sockaddr *)so_faddr, &len, B_FALSE, CRED());
45637c478bd9Sstevel@tonic-gate 
45647c478bd9Sstevel@tonic-gate 			add_sock_token = 1;
45657c478bd9Sstevel@tonic-gate 		}
45667c478bd9Sstevel@tonic-gate 
45677c478bd9Sstevel@tonic-gate 		/* XXX - what about SOCK_RAW/SOCK_RDM/SOCK_SEQPACKET ??? */
45687c478bd9Sstevel@tonic-gate 
45697c478bd9Sstevel@tonic-gate 		break;
45707c478bd9Sstevel@tonic-gate 
45717c478bd9Sstevel@tonic-gate 	case AF_UNIX:
45727c478bd9Sstevel@tonic-gate 		/*
45737c478bd9Sstevel@tonic-gate 		 * first check if this is first time through. Too much
45747c478bd9Sstevel@tonic-gate 		 * duplicate code to put this in an aui_ routine.
45757c478bd9Sstevel@tonic-gate 		 */
45767c478bd9Sstevel@tonic-gate 
45777c478bd9Sstevel@tonic-gate 		/* get path from file struct here */
45787c478bd9Sstevel@tonic-gate 		fad = F2A(fp);
45797c478bd9Sstevel@tonic-gate 		ASSERT(fad);
45807c478bd9Sstevel@tonic-gate 
45817c478bd9Sstevel@tonic-gate 		/*
45827c478bd9Sstevel@tonic-gate 		 * already processed this file for write attempt
45837c478bd9Sstevel@tonic-gate 		 */
45847c478bd9Sstevel@tonic-gate 		if (fad->fad_flags & FAD_WRITE) {
45857c478bd9Sstevel@tonic-gate 			releasef(fd);
45867c478bd9Sstevel@tonic-gate 			/* don't want to audit every sendmsg attempt */
45877c478bd9Sstevel@tonic-gate 			tad->tad_flag = 0;
45887c478bd9Sstevel@tonic-gate 			/* free any residual audit data */
4589005d3febSMarek Pospisil 			au_close(kctx, &(u_ad), 0, 0, 0, NULL);
45907c478bd9Sstevel@tonic-gate 			return;
45917c478bd9Sstevel@tonic-gate 		}
45927c478bd9Sstevel@tonic-gate 		/*
45937c478bd9Sstevel@tonic-gate 		 * mark things so we know what happened and don't
45947c478bd9Sstevel@tonic-gate 		 * repeat things
45957c478bd9Sstevel@tonic-gate 		 */
45967c478bd9Sstevel@tonic-gate 		fad->fad_flags |= FAD_WRITE;
45977c478bd9Sstevel@tonic-gate 
45987c478bd9Sstevel@tonic-gate 		if (fad->fad_aupath != NULL) {
45997c478bd9Sstevel@tonic-gate 			au_uwrite(au_to_path(fad->fad_aupath));
46007c478bd9Sstevel@tonic-gate 		} else {
46017c478bd9Sstevel@tonic-gate 			au_uwrite(au_to_arg32(1, "no path: fd", fd));
46027c478bd9Sstevel@tonic-gate 		}
46037c478bd9Sstevel@tonic-gate 
46047c478bd9Sstevel@tonic-gate 		audit_attributes(fp->f_vnode);
46057c478bd9Sstevel@tonic-gate 
46067c478bd9Sstevel@tonic-gate 		releasef(fd);
46077c478bd9Sstevel@tonic-gate 
46087c478bd9Sstevel@tonic-gate 		return;
46097c478bd9Sstevel@tonic-gate 
46107c478bd9Sstevel@tonic-gate 	default:
46117c478bd9Sstevel@tonic-gate 		break;
46127c478bd9Sstevel@tonic-gate 	}
46137c478bd9Sstevel@tonic-gate 
46147c478bd9Sstevel@tonic-gate 	releasef(fd);
46157c478bd9Sstevel@tonic-gate 
46167c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_arg32(1, "so", (uint32_t)fd));
46177c478bd9Sstevel@tonic-gate 
46187c478bd9Sstevel@tonic-gate 	if (add_sock_token == 0) {
46197c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32(1, "family", (uint32_t)so_family));
46207c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32(1, "type", (uint32_t)so_type));
46217c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32(3, "flags", (uint32_t)(uap->flags)));
46227c478bd9Sstevel@tonic-gate 		return;
46237c478bd9Sstevel@tonic-gate 	}
46247c478bd9Sstevel@tonic-gate 
46257c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_arg32(3, "flags", (uint32_t)(uap->flags)));
46267c478bd9Sstevel@tonic-gate 
46277c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_socket_ex(so_family, so_type, so_laddr, so_faddr));
46287c478bd9Sstevel@tonic-gate }
46297c478bd9Sstevel@tonic-gate 
46307c478bd9Sstevel@tonic-gate /*ARGSUSED*/
46317c478bd9Sstevel@tonic-gate static void
46327c478bd9Sstevel@tonic-gate auf_sendto(struct t_audit_data *tad, int error, rval_t *rval)
46337c478bd9Sstevel@tonic-gate {
46347c478bd9Sstevel@tonic-gate 	struct a {
46357c478bd9Sstevel@tonic-gate 		long	fd;
46367c478bd9Sstevel@tonic-gate 		long	msg;	/* char */
46377c478bd9Sstevel@tonic-gate 		long	len;
46387c478bd9Sstevel@tonic-gate 		long	flags;
46397c478bd9Sstevel@tonic-gate 		long	to;	/* struct sockaddr */
46407c478bd9Sstevel@tonic-gate 		long	tolen;
46417c478bd9Sstevel@tonic-gate 	} *uap = (struct a *)ttolwp(curthread)->lwp_ap;
46427c478bd9Sstevel@tonic-gate 
46437c478bd9Sstevel@tonic-gate 	struct sonode	*so;
46447c478bd9Sstevel@tonic-gate 	char so_laddr[sizeof (struct sockaddr_in6)];
46457c478bd9Sstevel@tonic-gate 	char so_faddr[sizeof (struct sockaddr_in6)];
46467c478bd9Sstevel@tonic-gate 	socklen_t	tolen;
46477c478bd9Sstevel@tonic-gate 	int		err;
46487c478bd9Sstevel@tonic-gate 	int		fd;
46490f1702c5SYu Xiangning 	socklen_t	len;
46507c478bd9Sstevel@tonic-gate 	short so_family, so_type;
46517c478bd9Sstevel@tonic-gate 	int		add_sock_token = 0;
46527c478bd9Sstevel@tonic-gate 	struct file	*fp;
46537c478bd9Sstevel@tonic-gate 	struct f_audit_data *fad;
46549e9e6ab8Spaulson 	au_kcontext_t	*kctx = GET_KCTX_PZ;
46557c478bd9Sstevel@tonic-gate 
46567c478bd9Sstevel@tonic-gate 	fd = (int)uap->fd;
46577c478bd9Sstevel@tonic-gate 
46587c478bd9Sstevel@tonic-gate 	/* bail if an error */
46597c478bd9Sstevel@tonic-gate 	if (error) {
46607c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32(1, "so", (uint32_t)fd));
46617c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32(3, "flags", (uint32_t)(uap->flags)));
46627c478bd9Sstevel@tonic-gate 		/* XXX include destination address from system call arguments */
46637c478bd9Sstevel@tonic-gate 		return;
46647c478bd9Sstevel@tonic-gate 	}
46657c478bd9Sstevel@tonic-gate 
4666745b2690Stz 	if ((so = getsonode(fd, &err, &fp)) == NULL) {
46677c478bd9Sstevel@tonic-gate 		/*
46687c478bd9Sstevel@tonic-gate 		 * not security relevant if doing a sendto using non socket
46697c478bd9Sstevel@tonic-gate 		 * so no extra tokens. Should probably turn off audit record
46707c478bd9Sstevel@tonic-gate 		 * generation here.
46717c478bd9Sstevel@tonic-gate 		 */
46727c478bd9Sstevel@tonic-gate 		return;
46737c478bd9Sstevel@tonic-gate 	}
46747c478bd9Sstevel@tonic-gate 
46757c478bd9Sstevel@tonic-gate 	so_family = so->so_family;
46767c478bd9Sstevel@tonic-gate 	so_type   = so->so_type;
46777c478bd9Sstevel@tonic-gate 
46787c478bd9Sstevel@tonic-gate 	/*
46797c478bd9Sstevel@tonic-gate 	 * only putout SOCKET_EX token if INET/INET6 family.
46807c478bd9Sstevel@tonic-gate 	 * XXX - what do we do about other families?
46817c478bd9Sstevel@tonic-gate 	 */
46827c478bd9Sstevel@tonic-gate 
46837c478bd9Sstevel@tonic-gate 	switch (so_family) {
46847c478bd9Sstevel@tonic-gate 	case AF_INET:
46857c478bd9Sstevel@tonic-gate 	case AF_INET6:
46867c478bd9Sstevel@tonic-gate 
46877c478bd9Sstevel@tonic-gate 		/*
46887c478bd9Sstevel@tonic-gate 		 * if datagram type socket, then just use what is in
46897c478bd9Sstevel@tonic-gate 		 * socket structure for local address.
46907c478bd9Sstevel@tonic-gate 		 * XXX - what do we do for other types?
46917c478bd9Sstevel@tonic-gate 		 */
46927c478bd9Sstevel@tonic-gate 		if ((so->so_type == SOCK_DGRAM) ||
46937c478bd9Sstevel@tonic-gate 		    (so->so_type == SOCK_RAW)) {
46947c478bd9Sstevel@tonic-gate 
46957c478bd9Sstevel@tonic-gate 			bzero((void *)so_laddr, sizeof (so_laddr));
46967c478bd9Sstevel@tonic-gate 			bzero((void *)so_faddr, sizeof (so_faddr));
46977c478bd9Sstevel@tonic-gate 
46987c478bd9Sstevel@tonic-gate 			/* get local address */
46990f1702c5SYu Xiangning 			len = sizeof (so_laddr);
47000f1702c5SYu Xiangning 			(void) socket_getsockname(so,
47010f1702c5SYu Xiangning 			    (struct sockaddr *)so_laddr, &len, CRED());
47027c478bd9Sstevel@tonic-gate 
47037c478bd9Sstevel@tonic-gate 			/* get peer address */
47047c478bd9Sstevel@tonic-gate 
47057c478bd9Sstevel@tonic-gate 			/* sanity check */
47067c478bd9Sstevel@tonic-gate 			if (uap->to == NULL)
47077c478bd9Sstevel@tonic-gate 				break;
47087c478bd9Sstevel@tonic-gate 
47097c478bd9Sstevel@tonic-gate 			/* sanity checks */
47107c478bd9Sstevel@tonic-gate 			if (uap->tolen == 0)
47117c478bd9Sstevel@tonic-gate 				break;
47127c478bd9Sstevel@tonic-gate 
47137c478bd9Sstevel@tonic-gate 			tolen = (socklen_t)uap->tolen;
47147c478bd9Sstevel@tonic-gate 
47157c478bd9Sstevel@tonic-gate 			/* enforce maximum size */
47167c478bd9Sstevel@tonic-gate 			if (tolen > sizeof (so_faddr))
47177c478bd9Sstevel@tonic-gate 				tolen = sizeof (so_faddr);
47187c478bd9Sstevel@tonic-gate 
47197c478bd9Sstevel@tonic-gate 			if (copyin((caddr_t)(uap->to), so_faddr, tolen) != 0)
47207c478bd9Sstevel@tonic-gate 				break;
47217c478bd9Sstevel@tonic-gate 
47227c478bd9Sstevel@tonic-gate 			add_sock_token = 1;
47237c478bd9Sstevel@tonic-gate 		} else {
47247c478bd9Sstevel@tonic-gate 			/*
47257c478bd9Sstevel@tonic-gate 			 * check if this is first time through.
47267c478bd9Sstevel@tonic-gate 			 */
47277c478bd9Sstevel@tonic-gate 
47287c478bd9Sstevel@tonic-gate 			/* get path from file struct here */
47297c478bd9Sstevel@tonic-gate 			fad = F2A(fp);
47307c478bd9Sstevel@tonic-gate 			ASSERT(fad);
47317c478bd9Sstevel@tonic-gate 
47327c478bd9Sstevel@tonic-gate 			/*
47337c478bd9Sstevel@tonic-gate 			 * already processed this file for write attempt
47347c478bd9Sstevel@tonic-gate 			 */
47357c478bd9Sstevel@tonic-gate 			if (fad->fad_flags & FAD_WRITE) {
47367c478bd9Sstevel@tonic-gate 				/* don't want to audit every sendto attempt */
47377c478bd9Sstevel@tonic-gate 				tad->tad_flag = 0;
47387c478bd9Sstevel@tonic-gate 				/* free any residual audit data */
4739005d3febSMarek Pospisil 				au_close(kctx, &(u_ad), 0, 0, 0, NULL);
47407c478bd9Sstevel@tonic-gate 				releasef(fd);
47417c478bd9Sstevel@tonic-gate 				return;
47427c478bd9Sstevel@tonic-gate 			}
47437c478bd9Sstevel@tonic-gate 			/*
47447c478bd9Sstevel@tonic-gate 			 * mark things so we know what happened and don't
47457c478bd9Sstevel@tonic-gate 			 * repeat things
47467c478bd9Sstevel@tonic-gate 			 */
47477c478bd9Sstevel@tonic-gate 			fad->fad_flags |= FAD_WRITE;
47487c478bd9Sstevel@tonic-gate 
47497c478bd9Sstevel@tonic-gate 			bzero((void *)so_laddr, sizeof (so_laddr));
47507c478bd9Sstevel@tonic-gate 			bzero((void *)so_faddr, sizeof (so_faddr));
47517c478bd9Sstevel@tonic-gate 
47520f1702c5SYu Xiangning 			/* get local and foreign addresses */
47530f1702c5SYu Xiangning 			len = sizeof (so_laddr);
47540f1702c5SYu Xiangning 			(void) socket_getsockname(so,
47550f1702c5SYu Xiangning 			    (struct sockaddr *)so_laddr, &len, CRED());
47560f1702c5SYu Xiangning 			len = sizeof (so_faddr);
47570f1702c5SYu Xiangning 			(void) socket_getpeername(so,
47580f1702c5SYu Xiangning 			    (struct sockaddr *)so_faddr, &len, B_FALSE, CRED());
47597c478bd9Sstevel@tonic-gate 
47607c478bd9Sstevel@tonic-gate 			add_sock_token = 1;
47617c478bd9Sstevel@tonic-gate 		}
47627c478bd9Sstevel@tonic-gate 
47637c478bd9Sstevel@tonic-gate 		/* XXX - what about SOCK_RDM/SOCK_SEQPACKET ??? */
47647c478bd9Sstevel@tonic-gate 
47657c478bd9Sstevel@tonic-gate 		break;
47667c478bd9Sstevel@tonic-gate 
47677c478bd9Sstevel@tonic-gate 	case AF_UNIX:
47687c478bd9Sstevel@tonic-gate 		/*
47697c478bd9Sstevel@tonic-gate 		 * first check if this is first time through. Too much
47707c478bd9Sstevel@tonic-gate 		 * duplicate code to put this in an aui_ routine.
47717c478bd9Sstevel@tonic-gate 		 */
47727c478bd9Sstevel@tonic-gate 
47737c478bd9Sstevel@tonic-gate 		/* get path from file struct here */
47747c478bd9Sstevel@tonic-gate 		fad = F2A(fp);
47757c478bd9Sstevel@tonic-gate 		ASSERT(fad);
47767c478bd9Sstevel@tonic-gate 
47777c478bd9Sstevel@tonic-gate 		/*
47787c478bd9Sstevel@tonic-gate 		 * already processed this file for write attempt
47797c478bd9Sstevel@tonic-gate 		 */
47807c478bd9Sstevel@tonic-gate 		if (fad->fad_flags & FAD_WRITE) {
47817c478bd9Sstevel@tonic-gate 			/* don't want to audit every sendto attempt */
47827c478bd9Sstevel@tonic-gate 			tad->tad_flag = 0;
47837c478bd9Sstevel@tonic-gate 			/* free any residual audit data */
4784005d3febSMarek Pospisil 			au_close(kctx, &(u_ad), 0, 0, 0, NULL);
47857c478bd9Sstevel@tonic-gate 			releasef(fd);
47867c478bd9Sstevel@tonic-gate 			return;
47877c478bd9Sstevel@tonic-gate 		}
47887c478bd9Sstevel@tonic-gate 		/*
47897c478bd9Sstevel@tonic-gate 		 * mark things so we know what happened and don't
47907c478bd9Sstevel@tonic-gate 		 * repeat things
47917c478bd9Sstevel@tonic-gate 		 */
47927c478bd9Sstevel@tonic-gate 		fad->fad_flags |= FAD_WRITE;
47937c478bd9Sstevel@tonic-gate 
47947c478bd9Sstevel@tonic-gate 		if (fad->fad_aupath != NULL) {
47957c478bd9Sstevel@tonic-gate 			au_uwrite(au_to_path(fad->fad_aupath));
47967c478bd9Sstevel@tonic-gate 		} else {
47977c478bd9Sstevel@tonic-gate 			au_uwrite(au_to_arg32(1, "no path: fd", fd));
47987c478bd9Sstevel@tonic-gate 		}
47997c478bd9Sstevel@tonic-gate 
48007c478bd9Sstevel@tonic-gate 		audit_attributes(fp->f_vnode);
48017c478bd9Sstevel@tonic-gate 
48027c478bd9Sstevel@tonic-gate 		releasef(fd);
48037c478bd9Sstevel@tonic-gate 
48047c478bd9Sstevel@tonic-gate 		return;
48057c478bd9Sstevel@tonic-gate 
48067c478bd9Sstevel@tonic-gate 	default:
48077c478bd9Sstevel@tonic-gate 		break;
48087c478bd9Sstevel@tonic-gate 
48097c478bd9Sstevel@tonic-gate 	}
48107c478bd9Sstevel@tonic-gate 
48117c478bd9Sstevel@tonic-gate 	releasef(fd);
48127c478bd9Sstevel@tonic-gate 
48137c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_arg32(1, "so", (uint32_t)fd));
48147c478bd9Sstevel@tonic-gate 
48157c478bd9Sstevel@tonic-gate 	if (add_sock_token == 0) {
48167c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32(1, "family", (uint32_t)so_family));
48177c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32(1, "type", (uint32_t)so_type));
48187c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32(3, "flags", (uint32_t)(uap->flags)));
48197c478bd9Sstevel@tonic-gate 		return;
48207c478bd9Sstevel@tonic-gate 	}
48217c478bd9Sstevel@tonic-gate 
48227c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_arg32(3, "flags", (uint32_t)(uap->flags)));
48237c478bd9Sstevel@tonic-gate 
48247c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_socket_ex(so_family, so_type, so_laddr, so_faddr));
48257c478bd9Sstevel@tonic-gate 
48267c478bd9Sstevel@tonic-gate }
48277c478bd9Sstevel@tonic-gate 
48287c478bd9Sstevel@tonic-gate /*
4829da6c28aaSamw  * XXX socket(2) may be equivalent to open(2) on a unix domain
48307c478bd9Sstevel@tonic-gate  * socket. This needs investigation.
48317c478bd9Sstevel@tonic-gate  */
48327c478bd9Sstevel@tonic-gate 
48337c478bd9Sstevel@tonic-gate /*ARGSUSED*/
48347c478bd9Sstevel@tonic-gate static void
48357c478bd9Sstevel@tonic-gate aus_socket(struct t_audit_data *tad)
48367c478bd9Sstevel@tonic-gate {
48377c478bd9Sstevel@tonic-gate 	struct a {
48387c478bd9Sstevel@tonic-gate 		long	domain;
48397c478bd9Sstevel@tonic-gate 		long	type;
48407c478bd9Sstevel@tonic-gate 		long	protocol;
48417c478bd9Sstevel@tonic-gate 	} *uap = (struct a *)ttolwp(curthread)->lwp_ap;
48427c478bd9Sstevel@tonic-gate 
48437c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_arg32(1, "domain", (uint32_t)uap->domain));
48447c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_arg32(2, "type", (uint32_t)uap->type));
48457c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_arg32(3, "protocol", (uint32_t)uap->protocol));
48467c478bd9Sstevel@tonic-gate }
48477c478bd9Sstevel@tonic-gate 
48487c478bd9Sstevel@tonic-gate /*ARGSUSED*/
48497c478bd9Sstevel@tonic-gate static void
48507c478bd9Sstevel@tonic-gate aus_sigqueue(struct t_audit_data *tad)
48517c478bd9Sstevel@tonic-gate {
48527c478bd9Sstevel@tonic-gate 	struct a {
48537c478bd9Sstevel@tonic-gate 		long	pid;
48547c478bd9Sstevel@tonic-gate 		long	signo;
48557c478bd9Sstevel@tonic-gate 		long	*val;
48567c478bd9Sstevel@tonic-gate 	} *uap = (struct a *)ttolwp(curthread)->lwp_ap;
48577c478bd9Sstevel@tonic-gate 	struct proc *p;
48587c478bd9Sstevel@tonic-gate 	uid_t uid, ruid;
48597c478bd9Sstevel@tonic-gate 	gid_t gid, rgid;
48607c478bd9Sstevel@tonic-gate 	pid_t pid;
48617c478bd9Sstevel@tonic-gate 	const auditinfo_addr_t *ainfo;
48627c478bd9Sstevel@tonic-gate 	cred_t *cr;
48637c478bd9Sstevel@tonic-gate 
48647c478bd9Sstevel@tonic-gate 	pid = (pid_t)uap->pid;
48657c478bd9Sstevel@tonic-gate 
48667c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_arg32(2, "signal", (uint32_t)uap->signo));
48677c478bd9Sstevel@tonic-gate 	if (pid > 0) {
48687c478bd9Sstevel@tonic-gate 		mutex_enter(&pidlock);
48697c478bd9Sstevel@tonic-gate 		if ((p = prfind(pid)) == (struct proc *)0) {
48707c478bd9Sstevel@tonic-gate 			mutex_exit(&pidlock);
48717c478bd9Sstevel@tonic-gate 			return;
48727c478bd9Sstevel@tonic-gate 		}
48737c478bd9Sstevel@tonic-gate 		mutex_enter(&p->p_lock); /* so process doesn't go away */
48747c478bd9Sstevel@tonic-gate 		mutex_exit(&pidlock);
48757c478bd9Sstevel@tonic-gate 
48767c478bd9Sstevel@tonic-gate 		mutex_enter(&p->p_crlock);
48777c478bd9Sstevel@tonic-gate 		crhold(cr = p->p_cred);
48787c478bd9Sstevel@tonic-gate 		mutex_exit(&p->p_crlock);
48797c478bd9Sstevel@tonic-gate 		mutex_exit(&p->p_lock);
48807c478bd9Sstevel@tonic-gate 
48817c478bd9Sstevel@tonic-gate 		ainfo = crgetauinfo(cr);
48827c478bd9Sstevel@tonic-gate 		if (ainfo == NULL) {
48837c478bd9Sstevel@tonic-gate 			crfree(cr);
48847c478bd9Sstevel@tonic-gate 			return;
48857c478bd9Sstevel@tonic-gate 		}
48867c478bd9Sstevel@tonic-gate 
48877c478bd9Sstevel@tonic-gate 		uid  = crgetuid(cr);
48887c478bd9Sstevel@tonic-gate 		gid  = crgetgid(cr);
48897c478bd9Sstevel@tonic-gate 		ruid = crgetruid(cr);
48907c478bd9Sstevel@tonic-gate 		rgid = crgetrgid(cr);
48917c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_process(uid, gid, ruid, rgid, pid,
48927c478bd9Sstevel@tonic-gate 		    ainfo->ai_auid, ainfo->ai_asid, &ainfo->ai_termid));
48937c478bd9Sstevel@tonic-gate 		crfree(cr);
48947c478bd9Sstevel@tonic-gate 	}
48957c478bd9Sstevel@tonic-gate 	else
48967c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32(1, "process ID", (uint32_t)pid));
48977c478bd9Sstevel@tonic-gate }
48987c478bd9Sstevel@tonic-gate 
48997c478bd9Sstevel@tonic-gate /*ARGSUSED*/
49007c478bd9Sstevel@tonic-gate static void
49017c478bd9Sstevel@tonic-gate aus_inst_sync(struct t_audit_data *tad)
49027c478bd9Sstevel@tonic-gate {
49037c478bd9Sstevel@tonic-gate 	struct a {
49047c478bd9Sstevel@tonic-gate 		long	name;	/* char */
49057c478bd9Sstevel@tonic-gate 		long	flags;
49067c478bd9Sstevel@tonic-gate 	} *uap = (struct a *)ttolwp(curthread)->lwp_ap;
49077c478bd9Sstevel@tonic-gate 
49087c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_arg32(2, "flags", (uint32_t)uap->flags));
49097c478bd9Sstevel@tonic-gate }
49107c478bd9Sstevel@tonic-gate 
49119acbbeafSnn /*ARGSUSED*/
49129acbbeafSnn static void
49139acbbeafSnn aus_brandsys(struct t_audit_data *tad)
49149acbbeafSnn {
49159acbbeafSnn 	klwp_t *clwp = ttolwp(curthread);
49169acbbeafSnn 
49179acbbeafSnn 	struct a {
49189acbbeafSnn 		long	cmd;
49199acbbeafSnn 		long	arg1;
49209acbbeafSnn 		long	arg2;
49219acbbeafSnn 		long	arg3;
49229acbbeafSnn 		long	arg4;
49239acbbeafSnn 		long	arg5;
49249acbbeafSnn 		long	arg6;
49259acbbeafSnn 	} *uap = (struct a *)clwp->lwp_ap;
49269acbbeafSnn 
49279acbbeafSnn 	au_uwrite(au_to_arg32(1, "cmd", (uint_t)uap->cmd));
49289acbbeafSnn #ifdef _LP64
49299acbbeafSnn 	au_uwrite(au_to_arg64(2, "arg1", (uint64_t)uap->arg1));
49309acbbeafSnn 	au_uwrite(au_to_arg64(3, "arg2", (uint64_t)uap->arg2));
49319acbbeafSnn 	au_uwrite(au_to_arg64(4, "arg3", (uint64_t)uap->arg3));
49329acbbeafSnn 	au_uwrite(au_to_arg64(5, "arg4", (uint64_t)uap->arg4));
49339acbbeafSnn 	au_uwrite(au_to_arg64(6, "arg5", (uint64_t)uap->arg5));
49349acbbeafSnn 	au_uwrite(au_to_arg64(7, "arg6", (uint64_t)uap->arg6));
49359acbbeafSnn #else
49369acbbeafSnn 	au_uwrite(au_to_arg32(2, "arg1", (uint32_t)uap->arg1));
49379acbbeafSnn 	au_uwrite(au_to_arg32(3, "arg2", (uint32_t)uap->arg2));
49389acbbeafSnn 	au_uwrite(au_to_arg32(4, "arg3", (uint32_t)uap->arg3));
49399acbbeafSnn 	au_uwrite(au_to_arg32(5, "arg4", (uint32_t)uap->arg4));
49409acbbeafSnn 	au_uwrite(au_to_arg32(6, "arg5", (uint32_t)uap->arg5));
49419acbbeafSnn 	au_uwrite(au_to_arg32(7, "arg6", (uint32_t)uap->arg6));
49429acbbeafSnn #endif
49439acbbeafSnn }
49449acbbeafSnn 
49457c478bd9Sstevel@tonic-gate /*ARGSUSED*/
49467c478bd9Sstevel@tonic-gate static void
49477c478bd9Sstevel@tonic-gate aus_p_online(struct t_audit_data *tad)
49487c478bd9Sstevel@tonic-gate {
49497c478bd9Sstevel@tonic-gate 	struct a {
49507c478bd9Sstevel@tonic-gate 		long	processor_id;
49517c478bd9Sstevel@tonic-gate 		long	flag;
49527c478bd9Sstevel@tonic-gate 	} *uap = (struct a *)ttolwp(curthread)->lwp_ap;
49537c478bd9Sstevel@tonic-gate 
49547c478bd9Sstevel@tonic-gate 	struct flags {
49557c478bd9Sstevel@tonic-gate 			int	flag;
49567c478bd9Sstevel@tonic-gate 			char	*cflag;
49577c478bd9Sstevel@tonic-gate 	} aflags[6] = {
49587c478bd9Sstevel@tonic-gate 			{ P_ONLINE, "P_ONLINE"},
49597c478bd9Sstevel@tonic-gate 			{ P_OFFLINE, "P_OFFLINE"},
49607c478bd9Sstevel@tonic-gate 			{ P_NOINTR, "P_NOINTR"},
49617c478bd9Sstevel@tonic-gate 			{ P_SPARE, "P_SPARE"},
49627c478bd9Sstevel@tonic-gate 			{ P_FAULTED, "P_FAULTED"},
49637c478bd9Sstevel@tonic-gate 			{ P_STATUS, "P_STATUS"}
49647c478bd9Sstevel@tonic-gate 	};
49657c478bd9Sstevel@tonic-gate 	int i;
49667c478bd9Sstevel@tonic-gate 	char *cflag;
49677c478bd9Sstevel@tonic-gate 
49687c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_arg32(1, "processor ID", (uint32_t)uap->processor_id));
49697c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_arg32(2, "flag", (uint32_t)uap->flag));
49707c478bd9Sstevel@tonic-gate 
49717c478bd9Sstevel@tonic-gate 	for (i = 0; i < 6; i++) {
49727c478bd9Sstevel@tonic-gate 		if (aflags[i].flag == uap->flag)
49737c478bd9Sstevel@tonic-gate 			break;
49747c478bd9Sstevel@tonic-gate 	}
49757c478bd9Sstevel@tonic-gate 	cflag = (i == 6) ? "bad flag":aflags[i].cflag;
49767c478bd9Sstevel@tonic-gate 
49777c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_text(cflag));
49787c478bd9Sstevel@tonic-gate }
49797c478bd9Sstevel@tonic-gate 
49807c478bd9Sstevel@tonic-gate /*ARGSUSED*/
49817c478bd9Sstevel@tonic-gate static void
49827c478bd9Sstevel@tonic-gate aus_processor_bind(struct t_audit_data *tad)
49837c478bd9Sstevel@tonic-gate {
49847c478bd9Sstevel@tonic-gate 	struct a {
49857c478bd9Sstevel@tonic-gate 		long	id_type;
49867c478bd9Sstevel@tonic-gate 		long	id;
49877c478bd9Sstevel@tonic-gate 		long	processor_id;
49887c478bd9Sstevel@tonic-gate 		long	obind;
49897c478bd9Sstevel@tonic-gate 	} *uap = (struct a *)ttolwp(curthread)->lwp_ap;
49907c478bd9Sstevel@tonic-gate 
49917c478bd9Sstevel@tonic-gate 	struct proc *p;
49927c478bd9Sstevel@tonic-gate 	int lwpcnt;
49937c478bd9Sstevel@tonic-gate 	uid_t uid, ruid;
49947c478bd9Sstevel@tonic-gate 	gid_t gid, rgid;
49957c478bd9Sstevel@tonic-gate 	pid_t pid;
49967c478bd9Sstevel@tonic-gate 	const auditinfo_addr_t *ainfo;
49977c478bd9Sstevel@tonic-gate 	cred_t *cr;
49987c478bd9Sstevel@tonic-gate 
49997c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_arg32(1, "ID type", (uint32_t)uap->id_type));
50007c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_arg32(2, "ID", (uint32_t)uap->id));
50017c478bd9Sstevel@tonic-gate 	if (uap->processor_id == PBIND_NONE)
50027c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_text("PBIND_NONE"));
50037c478bd9Sstevel@tonic-gate 	else
50047c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32(3, "processor_id",
5005745b2690Stz 		    (uint32_t)uap->processor_id));
50067c478bd9Sstevel@tonic-gate 
50077c478bd9Sstevel@tonic-gate 	switch (uap->id_type) {
50087c478bd9Sstevel@tonic-gate 	case P_MYID:
50097c478bd9Sstevel@tonic-gate 	case P_LWPID:
50107c478bd9Sstevel@tonic-gate 		mutex_enter(&pidlock);
50117c478bd9Sstevel@tonic-gate 		p = ttoproc(curthread);
50127c478bd9Sstevel@tonic-gate 		if (p == NULL || p->p_as == &kas) {
50137c478bd9Sstevel@tonic-gate 			mutex_exit(&pidlock);
50147c478bd9Sstevel@tonic-gate 			return;
50157c478bd9Sstevel@tonic-gate 		}
50167c478bd9Sstevel@tonic-gate 		mutex_enter(&p->p_lock);
50177c478bd9Sstevel@tonic-gate 		mutex_exit(&pidlock);
50187c478bd9Sstevel@tonic-gate 		lwpcnt = p->p_lwpcnt;
50197c478bd9Sstevel@tonic-gate 		pid  = p->p_pid;
50207c478bd9Sstevel@tonic-gate 
50217c478bd9Sstevel@tonic-gate 		mutex_enter(&p->p_crlock);
50227c478bd9Sstevel@tonic-gate 		crhold(cr = p->p_cred);
50237c478bd9Sstevel@tonic-gate 		mutex_exit(&p->p_crlock);
50247c478bd9Sstevel@tonic-gate 		mutex_exit(&p->p_lock);
50257c478bd9Sstevel@tonic-gate 
50267c478bd9Sstevel@tonic-gate 		ainfo = crgetauinfo(cr);
50277c478bd9Sstevel@tonic-gate 		if (ainfo == NULL) {
50287c478bd9Sstevel@tonic-gate 			crfree(cr);
50297c478bd9Sstevel@tonic-gate 			return;
50307c478bd9Sstevel@tonic-gate 		}
50317c478bd9Sstevel@tonic-gate 
50327c478bd9Sstevel@tonic-gate 		uid  = crgetuid(cr);
50337c478bd9Sstevel@tonic-gate 		gid  = crgetgid(cr);
50347c478bd9Sstevel@tonic-gate 		ruid = crgetruid(cr);
50357c478bd9Sstevel@tonic-gate 		rgid = crgetrgid(cr);
50367c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_process(uid, gid, ruid, rgid, pid,
50377c478bd9Sstevel@tonic-gate 		    ainfo->ai_auid, ainfo->ai_asid, &ainfo->ai_termid));
50387c478bd9Sstevel@tonic-gate 		crfree(cr);
50397c478bd9Sstevel@tonic-gate 		break;
50407c478bd9Sstevel@tonic-gate 	case P_PID:
50417c478bd9Sstevel@tonic-gate 		mutex_enter(&pidlock);
50427c478bd9Sstevel@tonic-gate 		p = prfind(uap->id);
50437c478bd9Sstevel@tonic-gate 		if (p == NULL || p->p_as == &kas) {
50447c478bd9Sstevel@tonic-gate 			mutex_exit(&pidlock);
50457c478bd9Sstevel@tonic-gate 			return;
50467c478bd9Sstevel@tonic-gate 		}
50477c478bd9Sstevel@tonic-gate 		mutex_enter(&p->p_lock);
50487c478bd9Sstevel@tonic-gate 		mutex_exit(&pidlock);
50497c478bd9Sstevel@tonic-gate 		lwpcnt = p->p_lwpcnt;
50507c478bd9Sstevel@tonic-gate 		pid  = p->p_pid;
50517c478bd9Sstevel@tonic-gate 
50527c478bd9Sstevel@tonic-gate 		mutex_enter(&p->p_crlock);
50537c478bd9Sstevel@tonic-gate 		crhold(cr = p->p_cred);
50547c478bd9Sstevel@tonic-gate 		mutex_exit(&p->p_crlock);
50557c478bd9Sstevel@tonic-gate 		mutex_exit(&p->p_lock);
50567c478bd9Sstevel@tonic-gate 
50577c478bd9Sstevel@tonic-gate 		ainfo = crgetauinfo(cr);
50587c478bd9Sstevel@tonic-gate 		if (ainfo == NULL) {
50597c478bd9Sstevel@tonic-gate 			crfree(cr);
50607c478bd9Sstevel@tonic-gate 			return;
50617c478bd9Sstevel@tonic-gate 		}
50627c478bd9Sstevel@tonic-gate 
50637c478bd9Sstevel@tonic-gate 		uid  = crgetuid(cr);
50647c478bd9Sstevel@tonic-gate 		gid  = crgetgid(cr);
50657c478bd9Sstevel@tonic-gate 		ruid = crgetruid(cr);
50667c478bd9Sstevel@tonic-gate 		rgid = crgetrgid(cr);
50677c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_process(uid, gid, ruid, rgid, pid,
50687c478bd9Sstevel@tonic-gate 		    ainfo->ai_auid, ainfo->ai_asid, &ainfo->ai_termid));
50697c478bd9Sstevel@tonic-gate 		crfree(cr);
50707c478bd9Sstevel@tonic-gate 
50717c478bd9Sstevel@tonic-gate 		break;
50727c478bd9Sstevel@tonic-gate 	default:
50737c478bd9Sstevel@tonic-gate 		return;
50747c478bd9Sstevel@tonic-gate 	}
50757c478bd9Sstevel@tonic-gate 
50767c478bd9Sstevel@tonic-gate 	if (uap->processor_id == PBIND_NONE &&
50777c478bd9Sstevel@tonic-gate 	    (!(uap->id_type == P_LWPID && lwpcnt > 1)))
50787c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_text("PBIND_NONE for process"));
50797c478bd9Sstevel@tonic-gate 	else
50807c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32(3, "processor_id",
5081745b2690Stz 		    (uint32_t)uap->processor_id));
50827c478bd9Sstevel@tonic-gate }
50837c478bd9Sstevel@tonic-gate 
50847c478bd9Sstevel@tonic-gate /*ARGSUSED*/
50857c478bd9Sstevel@tonic-gate static au_event_t
50867c478bd9Sstevel@tonic-gate aui_doorfs(au_event_t e)
50877c478bd9Sstevel@tonic-gate {
50887c478bd9Sstevel@tonic-gate 	uint32_t code;
50897c478bd9Sstevel@tonic-gate 
50907c478bd9Sstevel@tonic-gate 	struct a {		/* doorfs */
50917c478bd9Sstevel@tonic-gate 		long	a1;
50927c478bd9Sstevel@tonic-gate 		long	a2;
50937c478bd9Sstevel@tonic-gate 		long	a3;
50947c478bd9Sstevel@tonic-gate 		long	a4;
50957c478bd9Sstevel@tonic-gate 		long	a5;
50967c478bd9Sstevel@tonic-gate 		long	code;
50977c478bd9Sstevel@tonic-gate 	} *uap = (struct a *)ttolwp(curthread)->lwp_ap;
50987c478bd9Sstevel@tonic-gate 
50997c478bd9Sstevel@tonic-gate 	/*
51007c478bd9Sstevel@tonic-gate 	 *	audit formats for several of the
51017c478bd9Sstevel@tonic-gate 	 *	door calls have not yet been determined
51027c478bd9Sstevel@tonic-gate 	 */
51037c478bd9Sstevel@tonic-gate 	code = (uint32_t)uap->code;
51047c478bd9Sstevel@tonic-gate 	switch (code) {
51057c478bd9Sstevel@tonic-gate 	case DOOR_CALL:
51067c478bd9Sstevel@tonic-gate 		e = AUE_DOORFS_DOOR_CALL;
51077c478bd9Sstevel@tonic-gate 		break;
51087c478bd9Sstevel@tonic-gate 	case DOOR_RETURN:
51097c478bd9Sstevel@tonic-gate 		e = AUE_NULL;
51107c478bd9Sstevel@tonic-gate 		break;
51117c478bd9Sstevel@tonic-gate 	case DOOR_CREATE:
51127c478bd9Sstevel@tonic-gate 		e = AUE_DOORFS_DOOR_CREATE;
51137c478bd9Sstevel@tonic-gate 		break;
51147c478bd9Sstevel@tonic-gate 	case DOOR_REVOKE:
51157c478bd9Sstevel@tonic-gate 		e = AUE_DOORFS_DOOR_REVOKE;
51167c478bd9Sstevel@tonic-gate 		break;
51177c478bd9Sstevel@tonic-gate 	case DOOR_INFO:
51187c478bd9Sstevel@tonic-gate 		e = AUE_NULL;
51197c478bd9Sstevel@tonic-gate 		break;
51207c478bd9Sstevel@tonic-gate 	case DOOR_UCRED:
51217c478bd9Sstevel@tonic-gate 		e = AUE_NULL;
51227c478bd9Sstevel@tonic-gate 		break;
51237c478bd9Sstevel@tonic-gate 	case DOOR_BIND:
51247c478bd9Sstevel@tonic-gate 		e = AUE_NULL;
51257c478bd9Sstevel@tonic-gate 		break;
51267c478bd9Sstevel@tonic-gate 	case DOOR_UNBIND:
51277c478bd9Sstevel@tonic-gate 		e = AUE_NULL;
51287c478bd9Sstevel@tonic-gate 		break;
51297c478bd9Sstevel@tonic-gate 	case DOOR_GETPARAM:
51307c478bd9Sstevel@tonic-gate 		e = AUE_NULL;
51317c478bd9Sstevel@tonic-gate 		break;
51327c478bd9Sstevel@tonic-gate 	case DOOR_SETPARAM:
51337c478bd9Sstevel@tonic-gate 		e = AUE_NULL;
51347c478bd9Sstevel@tonic-gate 		break;
51357c478bd9Sstevel@tonic-gate 	default:	/* illegal system call */
51367c478bd9Sstevel@tonic-gate 		e = AUE_NULL;
51377c478bd9Sstevel@tonic-gate 		break;
51387c478bd9Sstevel@tonic-gate 	}
51397c478bd9Sstevel@tonic-gate 
51407c478bd9Sstevel@tonic-gate 	return (e);
51417c478bd9Sstevel@tonic-gate }
51427c478bd9Sstevel@tonic-gate 
51437c478bd9Sstevel@tonic-gate static door_node_t *
51447c478bd9Sstevel@tonic-gate au_door_lookup(int did)
51457c478bd9Sstevel@tonic-gate {
51467c478bd9Sstevel@tonic-gate 	vnode_t	*vp;
51477c478bd9Sstevel@tonic-gate 	file_t *fp;
51487c478bd9Sstevel@tonic-gate 
51497c478bd9Sstevel@tonic-gate 	if ((fp = getf(did)) == NULL)
51507c478bd9Sstevel@tonic-gate 		return (NULL);
51517c478bd9Sstevel@tonic-gate 	/*
51527c478bd9Sstevel@tonic-gate 	 * Use the underlying vnode (we may be namefs mounted)
51537c478bd9Sstevel@tonic-gate 	 */
5154da6c28aaSamw 	if (VOP_REALVP(fp->f_vnode, &vp, NULL))
51557c478bd9Sstevel@tonic-gate 		vp = fp->f_vnode;
51567c478bd9Sstevel@tonic-gate 
51577c478bd9Sstevel@tonic-gate 	if (vp == NULL || vp->v_type != VDOOR) {
51587c478bd9Sstevel@tonic-gate 		releasef(did);
51597c478bd9Sstevel@tonic-gate 		return (NULL);
51607c478bd9Sstevel@tonic-gate 	}
51617c478bd9Sstevel@tonic-gate 
51627c478bd9Sstevel@tonic-gate 	return (VTOD(vp));
51637c478bd9Sstevel@tonic-gate }
51647c478bd9Sstevel@tonic-gate 
51657c478bd9Sstevel@tonic-gate /*ARGSUSED*/
51667c478bd9Sstevel@tonic-gate static void
51677c478bd9Sstevel@tonic-gate aus_doorfs(struct t_audit_data *tad)
51687c478bd9Sstevel@tonic-gate {
51697c478bd9Sstevel@tonic-gate 
51707c478bd9Sstevel@tonic-gate 	struct a {		/* doorfs */
51717c478bd9Sstevel@tonic-gate 		long	a1;
51727c478bd9Sstevel@tonic-gate 		long	a2;
51737c478bd9Sstevel@tonic-gate 		long	a3;
51747c478bd9Sstevel@tonic-gate 		long	a4;
51757c478bd9Sstevel@tonic-gate 		long	a5;
51767c478bd9Sstevel@tonic-gate 		long	code;
51777c478bd9Sstevel@tonic-gate 	} *uap = (struct a *)ttolwp(curthread)->lwp_ap;
51787c478bd9Sstevel@tonic-gate 
51797c478bd9Sstevel@tonic-gate 	door_node_t	*dp;
51807c478bd9Sstevel@tonic-gate 	struct proc	*p;
51817c478bd9Sstevel@tonic-gate 	uint32_t	did;
51827c478bd9Sstevel@tonic-gate 	uid_t uid, ruid;
51837c478bd9Sstevel@tonic-gate 	gid_t gid, rgid;
51847c478bd9Sstevel@tonic-gate 	pid_t pid;
51857c478bd9Sstevel@tonic-gate 	const auditinfo_addr_t *ainfo;
51867c478bd9Sstevel@tonic-gate 	cred_t *cr;
51877c478bd9Sstevel@tonic-gate 
51887c478bd9Sstevel@tonic-gate 	did = (uint32_t)uap->a1;
51897c478bd9Sstevel@tonic-gate 
51907c478bd9Sstevel@tonic-gate 	switch (tad->tad_event) {
51917c478bd9Sstevel@tonic-gate 	case AUE_DOORFS_DOOR_CALL:
51927c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32(1, "door ID", (uint32_t)did));
51937c478bd9Sstevel@tonic-gate 		if ((dp = au_door_lookup(did)) == NULL)
51947c478bd9Sstevel@tonic-gate 			break;
51957c478bd9Sstevel@tonic-gate 
51967c478bd9Sstevel@tonic-gate 		if (DOOR_INVALID(dp)) {
51977c478bd9Sstevel@tonic-gate 			releasef(did);
51987c478bd9Sstevel@tonic-gate 			break;
51997c478bd9Sstevel@tonic-gate 		}
52007c478bd9Sstevel@tonic-gate 
52017c478bd9Sstevel@tonic-gate 		if ((p = dp->door_target) == NULL) {
52027c478bd9Sstevel@tonic-gate 			releasef(did);
52037c478bd9Sstevel@tonic-gate 			break;
52047c478bd9Sstevel@tonic-gate 		}
52057c478bd9Sstevel@tonic-gate 		mutex_enter(&p->p_lock);
52067c478bd9Sstevel@tonic-gate 		releasef(did);
52077c478bd9Sstevel@tonic-gate 
52087c478bd9Sstevel@tonic-gate 		pid  = p->p_pid;
52097c478bd9Sstevel@tonic-gate 
52107c478bd9Sstevel@tonic-gate 		mutex_enter(&p->p_crlock);
52117c478bd9Sstevel@tonic-gate 		crhold(cr = p->p_cred);
52127c478bd9Sstevel@tonic-gate 		mutex_exit(&p->p_crlock);
52137c478bd9Sstevel@tonic-gate 		mutex_exit(&p->p_lock);
52147c478bd9Sstevel@tonic-gate 
52157c478bd9Sstevel@tonic-gate 		ainfo = crgetauinfo(cr);
52167c478bd9Sstevel@tonic-gate 		if (ainfo == NULL) {
52177c478bd9Sstevel@tonic-gate 			crfree(cr);
52187c478bd9Sstevel@tonic-gate 			return;
52197c478bd9Sstevel@tonic-gate 		}
52207c478bd9Sstevel@tonic-gate 		uid  = crgetuid(cr);
52217c478bd9Sstevel@tonic-gate 		gid  = crgetgid(cr);
52227c478bd9Sstevel@tonic-gate 		ruid = crgetruid(cr);
52237c478bd9Sstevel@tonic-gate 		rgid = crgetrgid(cr);
52247c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_process(uid, gid, ruid, rgid, pid,
52257c478bd9Sstevel@tonic-gate 		    ainfo->ai_auid, ainfo->ai_asid, &ainfo->ai_termid));
52267c478bd9Sstevel@tonic-gate 		crfree(cr);
52277c478bd9Sstevel@tonic-gate 		break;
52287c478bd9Sstevel@tonic-gate 	case AUE_DOORFS_DOOR_RETURN:
52297c478bd9Sstevel@tonic-gate 		/*
52307c478bd9Sstevel@tonic-gate 		 * We may want to write information about
52317c478bd9Sstevel@tonic-gate 		 * all doors (if any) which will be copied
52327c478bd9Sstevel@tonic-gate 		 * by this call to the user space
52337c478bd9Sstevel@tonic-gate 		 */
52347c478bd9Sstevel@tonic-gate 		break;
52357c478bd9Sstevel@tonic-gate 	case AUE_DOORFS_DOOR_CREATE:
52367c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32(3, "door attr", (uint32_t)uap->a3));
52377c478bd9Sstevel@tonic-gate 		break;
52387c478bd9Sstevel@tonic-gate 	case AUE_DOORFS_DOOR_REVOKE:
52397c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32(1, "door ID", (uint32_t)did));
52407c478bd9Sstevel@tonic-gate 		break;
52417c478bd9Sstevel@tonic-gate 	case AUE_DOORFS_DOOR_INFO:
52427c478bd9Sstevel@tonic-gate 		break;
52437c478bd9Sstevel@tonic-gate 	case AUE_DOORFS_DOOR_CRED:
52447c478bd9Sstevel@tonic-gate 		break;
52457c478bd9Sstevel@tonic-gate 	case AUE_DOORFS_DOOR_BIND:
52467c478bd9Sstevel@tonic-gate 		break;
52477c478bd9Sstevel@tonic-gate 	case AUE_DOORFS_DOOR_UNBIND: {
52487c478bd9Sstevel@tonic-gate 		break;
52497c478bd9Sstevel@tonic-gate 	}
52507c478bd9Sstevel@tonic-gate 	default:	/* illegal system call */
52517c478bd9Sstevel@tonic-gate 		break;
52527c478bd9Sstevel@tonic-gate 	}
52537c478bd9Sstevel@tonic-gate }
52547c478bd9Sstevel@tonic-gate 
52557c478bd9Sstevel@tonic-gate /*ARGSUSED*/
52567c478bd9Sstevel@tonic-gate static au_event_t
52577c478bd9Sstevel@tonic-gate aui_acl(au_event_t e)
52587c478bd9Sstevel@tonic-gate {
52597c478bd9Sstevel@tonic-gate 	struct a {
52607c478bd9Sstevel@tonic-gate 		union {
52617c478bd9Sstevel@tonic-gate 			long	name;	/* char */
52627c478bd9Sstevel@tonic-gate 			long	fd;
52637c478bd9Sstevel@tonic-gate 		}		obj;
52647c478bd9Sstevel@tonic-gate 
52657c478bd9Sstevel@tonic-gate 		long		cmd;
52667c478bd9Sstevel@tonic-gate 		long		nentries;
52677c478bd9Sstevel@tonic-gate 		long		arg;	/* aclent_t */
52687c478bd9Sstevel@tonic-gate 	} *uap = (struct a *)ttolwp(curthread)->lwp_ap;
52697c478bd9Sstevel@tonic-gate 
52707c478bd9Sstevel@tonic-gate 	switch (uap->cmd) {
52717c478bd9Sstevel@tonic-gate 	case SETACL:
5272a7746f66Stz 	case ACE_SETACL:
5273a7746f66Stz 		/*
5274a7746f66Stz 		 * acl(SETACL/ACE_SETACL, ...) and facl(SETACL/ACE_SETACL, ...)
5275a7746f66Stz 		 * are expected.
5276a7746f66Stz 		 */
52777c478bd9Sstevel@tonic-gate 		break;
52787c478bd9Sstevel@tonic-gate 	case GETACL:
52797c478bd9Sstevel@tonic-gate 	case GETACLCNT:
5280ebbb0311SJan Friedel 	case ACE_GETACL:
5281a7746f66Stz 	case ACE_GETACLCNT:
5282ebbb0311SJan Friedel 		/* do nothing for these four values. */
52837c478bd9Sstevel@tonic-gate 		e = AUE_NULL;
52847c478bd9Sstevel@tonic-gate 		break;
52857c478bd9Sstevel@tonic-gate 	default:
52867c478bd9Sstevel@tonic-gate 		/* illegal system call */
52877c478bd9Sstevel@tonic-gate 		break;
52887c478bd9Sstevel@tonic-gate 	}
52897c478bd9Sstevel@tonic-gate 
52907c478bd9Sstevel@tonic-gate 	return (e);
52917c478bd9Sstevel@tonic-gate }
52927c478bd9Sstevel@tonic-gate 
52937c478bd9Sstevel@tonic-gate static void
5294a7746f66Stz au_acl(int cmd, int nentries, caddr_t bufp)
52957c478bd9Sstevel@tonic-gate {
5296a7746f66Stz 	size_t		a_size;
5297a7746f66Stz 	aclent_t	*aclbufp;
5298a7746f66Stz 	ace_t		*acebufp;
5299a7746f66Stz 	int		i;
53007c478bd9Sstevel@tonic-gate 
5301a7746f66Stz 	switch (cmd) {
53027c478bd9Sstevel@tonic-gate 	case GETACL:
53037c478bd9Sstevel@tonic-gate 	case GETACLCNT:
53047c478bd9Sstevel@tonic-gate 		break;
53057c478bd9Sstevel@tonic-gate 	case SETACL:
5306a7746f66Stz 		if (nentries < 3)
5307745b2690Stz 			break;
53087c478bd9Sstevel@tonic-gate 
5309a7746f66Stz 		a_size = nentries * sizeof (aclent_t);
5310a7746f66Stz 
5311a7746f66Stz 		if ((aclbufp = kmem_alloc(a_size, KM_SLEEP)) == NULL)
5312a7746f66Stz 			break;
5313a7746f66Stz 		if (copyin(bufp, aclbufp, a_size)) {
53147c478bd9Sstevel@tonic-gate 			kmem_free(aclbufp, a_size);
53157c478bd9Sstevel@tonic-gate 			break;
53167c478bd9Sstevel@tonic-gate 		}
5317a7746f66Stz 		for (i = 0; i < nentries; i++) {
5318a7746f66Stz 			au_uwrite(au_to_acl(aclbufp + i));
5319a7746f66Stz 		}
5320a7746f66Stz 		kmem_free(aclbufp, a_size);
5321a7746f66Stz 		break;
5322a7746f66Stz 
5323a7746f66Stz 	case ACE_SETACL:
5324a7746f66Stz 		if (nentries < 1 || nentries > MAX_ACL_ENTRIES)
5325a7746f66Stz 			break;
5326a7746f66Stz 
5327a7746f66Stz 		a_size = nentries * sizeof (ace_t);
5328a7746f66Stz 		if ((acebufp = kmem_alloc(a_size, KM_SLEEP)) == NULL)
5329a7746f66Stz 			break;
5330a7746f66Stz 		if (copyin(bufp, acebufp, a_size)) {
5331a7746f66Stz 			kmem_free(acebufp, a_size);
5332a7746f66Stz 			break;
5333a7746f66Stz 		}
5334a7746f66Stz 		for (i = 0; i < nentries; i++) {
5335a7746f66Stz 			au_uwrite(au_to_ace(acebufp + i));
5336a7746f66Stz 		}
5337a7746f66Stz 		kmem_free(acebufp, a_size);
5338a7746f66Stz 		break;
53397c478bd9Sstevel@tonic-gate 	default:
53407c478bd9Sstevel@tonic-gate 		break;
53417c478bd9Sstevel@tonic-gate 	}
53427c478bd9Sstevel@tonic-gate }
53437c478bd9Sstevel@tonic-gate 
5344a7746f66Stz /*ARGSUSED*/
5345a7746f66Stz static void
5346a7746f66Stz aus_acl(struct t_audit_data *tad)
5347a7746f66Stz {
5348a7746f66Stz 	struct a {
5349a7746f66Stz 		long	fname;
5350a7746f66Stz 		long	cmd;
5351a7746f66Stz 		long	nentries;
5352a7746f66Stz 		long	aclbufp;
5353a7746f66Stz 	} *uap = (struct a *)ttolwp(curthread)->lwp_ap;
5354a7746f66Stz 
5355a7746f66Stz 	au_uwrite(au_to_arg32(2, "cmd", (uint32_t)uap->cmd));
5356a7746f66Stz 	au_uwrite(au_to_arg32(3, "nentries", (uint32_t)uap->nentries));
5357a7746f66Stz 
5358a7746f66Stz 	au_acl(uap->cmd, uap->nentries, (caddr_t)uap->aclbufp);
5359a7746f66Stz }
5360a7746f66Stz 
53617c478bd9Sstevel@tonic-gate /*ARGSUSED*/
53627c478bd9Sstevel@tonic-gate static void
53637c478bd9Sstevel@tonic-gate aus_facl(struct t_audit_data *tad)
53647c478bd9Sstevel@tonic-gate {
53657c478bd9Sstevel@tonic-gate 	struct a {
53667c478bd9Sstevel@tonic-gate 		long	fd;
53677c478bd9Sstevel@tonic-gate 		long	cmd;
53687c478bd9Sstevel@tonic-gate 		long	nentries;
53697c478bd9Sstevel@tonic-gate 		long	aclbufp;
53707c478bd9Sstevel@tonic-gate 	} *uap = (struct a *)ttolwp(curthread)->lwp_ap;
53717c478bd9Sstevel@tonic-gate 	struct file  *fp;
53727c478bd9Sstevel@tonic-gate 	struct vnode *vp;
53737c478bd9Sstevel@tonic-gate 	struct f_audit_data *fad;
53747c478bd9Sstevel@tonic-gate 	int fd;
53757c478bd9Sstevel@tonic-gate 
53767c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_arg32(2, "cmd", (uint32_t)uap->cmd));
53777c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_arg32(3, "nentries", (uint32_t)uap->nentries));
53787c478bd9Sstevel@tonic-gate 
53797c478bd9Sstevel@tonic-gate 	fd = (int)uap->fd;
53807c478bd9Sstevel@tonic-gate 
53817c478bd9Sstevel@tonic-gate 	if ((fp = getf(fd)) == NULL)
53827c478bd9Sstevel@tonic-gate 		return;
53837c478bd9Sstevel@tonic-gate 
53847c478bd9Sstevel@tonic-gate 	/* get path from file struct here */
53857c478bd9Sstevel@tonic-gate 	fad = F2A(fp);
53867c478bd9Sstevel@tonic-gate 	if (fad->fad_aupath != NULL) {
53877c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_path(fad->fad_aupath));
53887c478bd9Sstevel@tonic-gate 	} else {
53897c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32(1, "no path: fd", (uint32_t)fd));
53907c478bd9Sstevel@tonic-gate 	}
53917c478bd9Sstevel@tonic-gate 
53927c478bd9Sstevel@tonic-gate 	vp = fp->f_vnode;
53937c478bd9Sstevel@tonic-gate 	audit_attributes(vp);
53947c478bd9Sstevel@tonic-gate 
53957c478bd9Sstevel@tonic-gate 	/* decrement file descriptor reference count */
53967c478bd9Sstevel@tonic-gate 	releasef(fd);
53977c478bd9Sstevel@tonic-gate 
5398a7746f66Stz 	au_acl(uap->cmd, uap->nentries, (caddr_t)uap->aclbufp);
53997c478bd9Sstevel@tonic-gate }
54007c478bd9Sstevel@tonic-gate 
54017c478bd9Sstevel@tonic-gate /*ARGSUSED*/
54027c478bd9Sstevel@tonic-gate static void
54037c478bd9Sstevel@tonic-gate auf_read(tad, error, rval)
54047c478bd9Sstevel@tonic-gate 	struct t_audit_data *tad;
54057c478bd9Sstevel@tonic-gate 	int error;
54067c478bd9Sstevel@tonic-gate 	rval_t *rval;
54077c478bd9Sstevel@tonic-gate {
54087c478bd9Sstevel@tonic-gate 	struct file *fp;
54097c478bd9Sstevel@tonic-gate 	struct f_audit_data *fad;
54107c478bd9Sstevel@tonic-gate 	int fd;
54117c478bd9Sstevel@tonic-gate 	register struct a {
54127c478bd9Sstevel@tonic-gate 		long	fd;
54137c478bd9Sstevel@tonic-gate 	} *uap = (struct a *)ttolwp(curthread)->lwp_ap;
54149e9e6ab8Spaulson 	au_kcontext_t	*kctx = GET_KCTX_PZ;
54157c478bd9Sstevel@tonic-gate 
54167c478bd9Sstevel@tonic-gate 	fd = (int)uap->fd;
54177c478bd9Sstevel@tonic-gate 
54187c478bd9Sstevel@tonic-gate 	/*
54197c478bd9Sstevel@tonic-gate 	 * convert file pointer to file descriptor
54207c478bd9Sstevel@tonic-gate 	 *   Note: fd ref count incremented here.
54217c478bd9Sstevel@tonic-gate 	 */
54227c478bd9Sstevel@tonic-gate 	if ((fp = getf(fd)) == NULL)
54237c478bd9Sstevel@tonic-gate 		return;
54247c478bd9Sstevel@tonic-gate 
54257c478bd9Sstevel@tonic-gate 	/* get path from file struct here */
54267c478bd9Sstevel@tonic-gate 	fad = F2A(fp);
54277c478bd9Sstevel@tonic-gate 	ASSERT(fad);
54287c478bd9Sstevel@tonic-gate 
54297c478bd9Sstevel@tonic-gate 	/*
54307c478bd9Sstevel@tonic-gate 	 * already processed this file for read attempt
54317c478bd9Sstevel@tonic-gate 	 *
54327c478bd9Sstevel@tonic-gate 	 * XXX might be better to turn off auditing in a aui_read() routine.
54337c478bd9Sstevel@tonic-gate 	 */
54347c478bd9Sstevel@tonic-gate 	if (fad->fad_flags & FAD_READ) {
54357c478bd9Sstevel@tonic-gate 		/* don't really want to audit every read attempt */
54367c478bd9Sstevel@tonic-gate 		tad->tad_flag = 0;
54377c478bd9Sstevel@tonic-gate 		/* free any residual audit data */
5438005d3febSMarek Pospisil 		au_close(kctx, &(u_ad), 0, 0, 0, NULL);
54397c478bd9Sstevel@tonic-gate 		releasef(fd);
54407c478bd9Sstevel@tonic-gate 		return;
54417c478bd9Sstevel@tonic-gate 	}
54427c478bd9Sstevel@tonic-gate 	/* mark things so we know what happened and don't repeat things */
54437c478bd9Sstevel@tonic-gate 	fad->fad_flags |= FAD_READ;
54447c478bd9Sstevel@tonic-gate 
54457c478bd9Sstevel@tonic-gate 	if (fad->fad_aupath != NULL) {
54467c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_path(fad->fad_aupath));
54477c478bd9Sstevel@tonic-gate 	} else {
54487c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32(1, "no path: fd", (uint32_t)fd));
54497c478bd9Sstevel@tonic-gate 	}
54507c478bd9Sstevel@tonic-gate 
54517c478bd9Sstevel@tonic-gate 	/* include attributes */
54527c478bd9Sstevel@tonic-gate 	audit_attributes(fp->f_vnode);
54537c478bd9Sstevel@tonic-gate 
54547c478bd9Sstevel@tonic-gate 	/* decrement file descriptor reference count */
54557c478bd9Sstevel@tonic-gate 	releasef(fd);
54567c478bd9Sstevel@tonic-gate }
54577c478bd9Sstevel@tonic-gate 
54587c478bd9Sstevel@tonic-gate /*ARGSUSED*/
54597c478bd9Sstevel@tonic-gate static void
54607c478bd9Sstevel@tonic-gate auf_write(tad, error, rval)
54617c478bd9Sstevel@tonic-gate 	struct t_audit_data *tad;
54627c478bd9Sstevel@tonic-gate 	int error;
54637c478bd9Sstevel@tonic-gate 	rval_t *rval;
54647c478bd9Sstevel@tonic-gate {
54657c478bd9Sstevel@tonic-gate 	struct file *fp;
54667c478bd9Sstevel@tonic-gate 	struct f_audit_data *fad;
54677c478bd9Sstevel@tonic-gate 	int fd;
54687c478bd9Sstevel@tonic-gate 	register struct a {
54697c478bd9Sstevel@tonic-gate 		long	fd;
54707c478bd9Sstevel@tonic-gate 	} *uap = (struct a *)ttolwp(curthread)->lwp_ap;
54719e9e6ab8Spaulson 	au_kcontext_t	*kctx = GET_KCTX_PZ;
54727c478bd9Sstevel@tonic-gate 
54737c478bd9Sstevel@tonic-gate 	fd = (int)uap->fd;
54747c478bd9Sstevel@tonic-gate 
54757c478bd9Sstevel@tonic-gate 	/*
54767c478bd9Sstevel@tonic-gate 	 * convert file pointer to file descriptor
54777c478bd9Sstevel@tonic-gate 	 *   Note: fd ref count incremented here.
54787c478bd9Sstevel@tonic-gate 	 */
54797c478bd9Sstevel@tonic-gate 	if ((fp = getf(fd)) == NULL)
54807c478bd9Sstevel@tonic-gate 		return;
54817c478bd9Sstevel@tonic-gate 
54827c478bd9Sstevel@tonic-gate 	/* get path from file struct here */
54837c478bd9Sstevel@tonic-gate 	fad = F2A(fp);
54847c478bd9Sstevel@tonic-gate 	ASSERT(fad);
54857c478bd9Sstevel@tonic-gate 
54867c478bd9Sstevel@tonic-gate 	/*
54877c478bd9Sstevel@tonic-gate 	 * already processed this file for write attempt
54887c478bd9Sstevel@tonic-gate 	 *
54897c478bd9Sstevel@tonic-gate 	 * XXX might be better to turn off auditing in a aus_write() routine.
54907c478bd9Sstevel@tonic-gate 	 */
54917c478bd9Sstevel@tonic-gate 	if (fad->fad_flags & FAD_WRITE) {
54927c478bd9Sstevel@tonic-gate 		/* don't really want to audit every write attempt */
54937c478bd9Sstevel@tonic-gate 		tad->tad_flag = 0;
54947c478bd9Sstevel@tonic-gate 		/* free any residual audit data */
5495005d3febSMarek Pospisil 		au_close(kctx, &(u_ad), 0, 0, 0, NULL);
54967c478bd9Sstevel@tonic-gate 		releasef(fd);
54977c478bd9Sstevel@tonic-gate 		return;
54987c478bd9Sstevel@tonic-gate 	}
54997c478bd9Sstevel@tonic-gate 	/* mark things so we know what happened and don't repeat things */
55007c478bd9Sstevel@tonic-gate 	fad->fad_flags |= FAD_WRITE;
55017c478bd9Sstevel@tonic-gate 
55027c478bd9Sstevel@tonic-gate 	if (fad->fad_aupath != NULL) {
55037c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_path(fad->fad_aupath));
55047c478bd9Sstevel@tonic-gate 	} else {
55057c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32(1, "no path: fd", (uint32_t)fd));
55067c478bd9Sstevel@tonic-gate 	}
55077c478bd9Sstevel@tonic-gate 
55087c478bd9Sstevel@tonic-gate 	/* include attributes */
55097c478bd9Sstevel@tonic-gate 	audit_attributes(fp->f_vnode);
55107c478bd9Sstevel@tonic-gate 
55117c478bd9Sstevel@tonic-gate 	/* decrement file descriptor reference count */
55127c478bd9Sstevel@tonic-gate 	releasef(fd);
55137c478bd9Sstevel@tonic-gate }
55147c478bd9Sstevel@tonic-gate 
55157c478bd9Sstevel@tonic-gate /*ARGSUSED*/
55167c478bd9Sstevel@tonic-gate static void
55177c478bd9Sstevel@tonic-gate auf_recv(tad, error, rval)
55187c478bd9Sstevel@tonic-gate 	struct t_audit_data *tad;
55197c478bd9Sstevel@tonic-gate 	int error;
55207c478bd9Sstevel@tonic-gate 	rval_t *rval;
55217c478bd9Sstevel@tonic-gate {
55227c478bd9Sstevel@tonic-gate 	struct sonode *so;
55237c478bd9Sstevel@tonic-gate 	char so_laddr[sizeof (struct sockaddr_in6)];
55247c478bd9Sstevel@tonic-gate 	char so_faddr[sizeof (struct sockaddr_in6)];
55257c478bd9Sstevel@tonic-gate 	struct file *fp;
55267c478bd9Sstevel@tonic-gate 	struct f_audit_data *fad;
55277c478bd9Sstevel@tonic-gate 	int fd;
55287c478bd9Sstevel@tonic-gate 	int err;
55290f1702c5SYu Xiangning 	socklen_t len;
55307c478bd9Sstevel@tonic-gate 	short so_family, so_type;
55317c478bd9Sstevel@tonic-gate 	register struct a {
55327c478bd9Sstevel@tonic-gate 		long	fd;
55337c478bd9Sstevel@tonic-gate 	} *uap = (struct a *)ttolwp(curthread)->lwp_ap;
55349e9e6ab8Spaulson 	au_kcontext_t	*kctx = GET_KCTX_PZ;
55357c478bd9Sstevel@tonic-gate 
55367c478bd9Sstevel@tonic-gate 	/*
55377c478bd9Sstevel@tonic-gate 	 * If there was an error, then nothing to do. Only generate
55387c478bd9Sstevel@tonic-gate 	 * audit record on first successful recv.
55397c478bd9Sstevel@tonic-gate 	 */
55407c478bd9Sstevel@tonic-gate 	if (error) {
55417c478bd9Sstevel@tonic-gate 		/* Turn off audit record generation here. */
55427c478bd9Sstevel@tonic-gate 		tad->tad_flag = 0;
55437c478bd9Sstevel@tonic-gate 		/* free any residual audit data */
5544005d3febSMarek Pospisil 		au_close(kctx, &(u_ad), 0, 0, 0, NULL);
55457c478bd9Sstevel@tonic-gate 		return;
55467c478bd9Sstevel@tonic-gate 	}
55477c478bd9Sstevel@tonic-gate 
55487c478bd9Sstevel@tonic-gate 	fd = (int)uap->fd;
55497c478bd9Sstevel@tonic-gate 
5550745b2690Stz 	if ((so = getsonode(fd, &err, &fp)) == NULL) {
55517c478bd9Sstevel@tonic-gate 		/* Turn off audit record generation here. */
55527c478bd9Sstevel@tonic-gate 		tad->tad_flag = 0;
55537c478bd9Sstevel@tonic-gate 		/* free any residual audit data */
5554005d3febSMarek Pospisil 		au_close(kctx, &(u_ad), 0, 0, 0, NULL);
55557c478bd9Sstevel@tonic-gate 		return;
55567c478bd9Sstevel@tonic-gate 	}
55577c478bd9Sstevel@tonic-gate 
55587c478bd9Sstevel@tonic-gate 	/* get path from file struct here */
55597c478bd9Sstevel@tonic-gate 	fad = F2A(fp);
55607c478bd9Sstevel@tonic-gate 	ASSERT(fad);
55617c478bd9Sstevel@tonic-gate 
55627c478bd9Sstevel@tonic-gate 	/*
55637c478bd9Sstevel@tonic-gate 	 * already processed this file for read attempt
55647c478bd9Sstevel@tonic-gate 	 */
55657c478bd9Sstevel@tonic-gate 	if (fad->fad_flags & FAD_READ) {
55667c478bd9Sstevel@tonic-gate 		releasef(fd);
55677c478bd9Sstevel@tonic-gate 		/* don't really want to audit every recv call */
55687c478bd9Sstevel@tonic-gate 		tad->tad_flag = 0;
55697c478bd9Sstevel@tonic-gate 		/* free any residual audit data */
5570005d3febSMarek Pospisil 		au_close(kctx, &(u_ad), 0, 0, 0, NULL);
55717c478bd9Sstevel@tonic-gate 		return;
55727c478bd9Sstevel@tonic-gate 	}
55737c478bd9Sstevel@tonic-gate 
55747c478bd9Sstevel@tonic-gate 	/* mark things so we know what happened and don't repeat things */
55757c478bd9Sstevel@tonic-gate 	fad->fad_flags |= FAD_READ;
55767c478bd9Sstevel@tonic-gate 
55777c478bd9Sstevel@tonic-gate 	so_family = so->so_family;
55787c478bd9Sstevel@tonic-gate 	so_type   = so->so_type;
55797c478bd9Sstevel@tonic-gate 
55807c478bd9Sstevel@tonic-gate 	switch (so_family) {
55817c478bd9Sstevel@tonic-gate 	case AF_INET:
55827c478bd9Sstevel@tonic-gate 	case AF_INET6:
55837c478bd9Sstevel@tonic-gate 		/*
55847c478bd9Sstevel@tonic-gate 		 * Only for connections.
55857c478bd9Sstevel@tonic-gate 		 * XXX - do we need to worry about SOCK_DGRAM or other types???
55867c478bd9Sstevel@tonic-gate 		 */
55877c478bd9Sstevel@tonic-gate 		if (so->so_state & SS_ISBOUND) {
55887c478bd9Sstevel@tonic-gate 
55897c478bd9Sstevel@tonic-gate 			bzero((void *)so_laddr, sizeof (so_laddr));
55907c478bd9Sstevel@tonic-gate 			bzero((void *)so_faddr, sizeof (so_faddr));
55917c478bd9Sstevel@tonic-gate 
55927c478bd9Sstevel@tonic-gate 			/* get local and foreign addresses */
55930f1702c5SYu Xiangning 			len = sizeof (so_laddr);
55940f1702c5SYu Xiangning 			(void) socket_getsockname(so,
55950f1702c5SYu Xiangning 			    (struct sockaddr *)so_laddr, &len, CRED());
55960f1702c5SYu Xiangning 			len = sizeof (so_faddr);
55970f1702c5SYu Xiangning 			(void) socket_getpeername(so,
55980f1702c5SYu Xiangning 			    (struct sockaddr *)so_faddr, &len, B_FALSE, CRED());
55997c478bd9Sstevel@tonic-gate 
56007c478bd9Sstevel@tonic-gate 			/*
56017c478bd9Sstevel@tonic-gate 			 * only way to drop out of switch. Note that we
56027c478bd9Sstevel@tonic-gate 			 * we release fd below.
56037c478bd9Sstevel@tonic-gate 			 */
56047c478bd9Sstevel@tonic-gate 
56057c478bd9Sstevel@tonic-gate 			break;
56067c478bd9Sstevel@tonic-gate 		}
56077c478bd9Sstevel@tonic-gate 
56087c478bd9Sstevel@tonic-gate 		releasef(fd);
56097c478bd9Sstevel@tonic-gate 
56107c478bd9Sstevel@tonic-gate 		/* don't really want to audit every recv call */
56117c478bd9Sstevel@tonic-gate 		tad->tad_flag = 0;
56127c478bd9Sstevel@tonic-gate 		/* free any residual audit data */
5613005d3febSMarek Pospisil 		au_close(kctx, &(u_ad), 0, 0, 0, NULL);
56147c478bd9Sstevel@tonic-gate 
56157c478bd9Sstevel@tonic-gate 		return;
56167c478bd9Sstevel@tonic-gate 
56177c478bd9Sstevel@tonic-gate 	case AF_UNIX:
56187c478bd9Sstevel@tonic-gate 
56197c478bd9Sstevel@tonic-gate 		if (fad->fad_aupath != NULL) {
56207c478bd9Sstevel@tonic-gate 			au_uwrite(au_to_path(fad->fad_aupath));
56217c478bd9Sstevel@tonic-gate 		} else {
56227c478bd9Sstevel@tonic-gate 			au_uwrite(au_to_arg32(1, "no path: fd", fd));
56237c478bd9Sstevel@tonic-gate 		}
56247c478bd9Sstevel@tonic-gate 
56257c478bd9Sstevel@tonic-gate 		audit_attributes(fp->f_vnode);
56267c478bd9Sstevel@tonic-gate 
56277c478bd9Sstevel@tonic-gate 		releasef(fd);
56287c478bd9Sstevel@tonic-gate 
56297c478bd9Sstevel@tonic-gate 		return;
56307c478bd9Sstevel@tonic-gate 
56317c478bd9Sstevel@tonic-gate 	default:
56327c478bd9Sstevel@tonic-gate 		releasef(fd);
56337c478bd9Sstevel@tonic-gate 
56347c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32(1, "so", (uint32_t)fd));
56357c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32(1, "family", (uint32_t)so_family));
56367c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32(1, "type", (uint32_t)so_type));
56377c478bd9Sstevel@tonic-gate 
56387c478bd9Sstevel@tonic-gate 		return;
56397c478bd9Sstevel@tonic-gate 	}
56407c478bd9Sstevel@tonic-gate 
56417c478bd9Sstevel@tonic-gate 	releasef(fd);
56427c478bd9Sstevel@tonic-gate 
56437c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_arg32(1, "so", (uint32_t)fd));
56447c478bd9Sstevel@tonic-gate 
56457c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_socket_ex(so_family, so_type, so_laddr, so_faddr));
56467c478bd9Sstevel@tonic-gate 
56477c478bd9Sstevel@tonic-gate }
56487c478bd9Sstevel@tonic-gate 
56497c478bd9Sstevel@tonic-gate /*ARGSUSED*/
56507c478bd9Sstevel@tonic-gate static void
56517c478bd9Sstevel@tonic-gate auf_send(tad, error, rval)
56527c478bd9Sstevel@tonic-gate 	struct t_audit_data *tad;
56537c478bd9Sstevel@tonic-gate 	int error;
56547c478bd9Sstevel@tonic-gate 	rval_t *rval;
56557c478bd9Sstevel@tonic-gate {
56567c478bd9Sstevel@tonic-gate 	struct sonode *so;
56577c478bd9Sstevel@tonic-gate 	char so_laddr[sizeof (struct sockaddr_in6)];
56587c478bd9Sstevel@tonic-gate 	char so_faddr[sizeof (struct sockaddr_in6)];
56597c478bd9Sstevel@tonic-gate 	struct file *fp;
56607c478bd9Sstevel@tonic-gate 	struct f_audit_data *fad;
56617c478bd9Sstevel@tonic-gate 	int fd;
56627c478bd9Sstevel@tonic-gate 	int err;
56630f1702c5SYu Xiangning 	socklen_t len;
56647c478bd9Sstevel@tonic-gate 	short so_family, so_type;
56657c478bd9Sstevel@tonic-gate 	register struct a {
56667c478bd9Sstevel@tonic-gate 		long	fd;
56677c478bd9Sstevel@tonic-gate 	} *uap = (struct a *)ttolwp(curthread)->lwp_ap;
56689e9e6ab8Spaulson 	au_kcontext_t	*kctx = GET_KCTX_PZ;
56697c478bd9Sstevel@tonic-gate 
56707c478bd9Sstevel@tonic-gate 	fd = (int)uap->fd;
56717c478bd9Sstevel@tonic-gate 
56727c478bd9Sstevel@tonic-gate 	/*
56737c478bd9Sstevel@tonic-gate 	 * If there was an error, then nothing to do. Only generate
56747c478bd9Sstevel@tonic-gate 	 * audit record on first successful send.
56757c478bd9Sstevel@tonic-gate 	 */
56767c478bd9Sstevel@tonic-gate 	if (error != 0) {
56777c478bd9Sstevel@tonic-gate 		/* Turn off audit record generation here. */
56787c478bd9Sstevel@tonic-gate 		tad->tad_flag = 0;
56797c478bd9Sstevel@tonic-gate 		/* free any residual audit data */
5680005d3febSMarek Pospisil 		au_close(kctx, &(u_ad), 0, 0, 0, NULL);
56817c478bd9Sstevel@tonic-gate 		return;
56827c478bd9Sstevel@tonic-gate 	}
56837c478bd9Sstevel@tonic-gate 
56847c478bd9Sstevel@tonic-gate 	fd = (int)uap->fd;
56857c478bd9Sstevel@tonic-gate 
5686745b2690Stz 	if ((so = getsonode(fd, &err, &fp)) == NULL) {
56877c478bd9Sstevel@tonic-gate 		/* Turn off audit record generation here. */
56887c478bd9Sstevel@tonic-gate 		tad->tad_flag = 0;
56897c478bd9Sstevel@tonic-gate 		/* free any residual audit data */
5690005d3febSMarek Pospisil 		au_close(kctx, &(u_ad), 0, 0, 0, NULL);
56917c478bd9Sstevel@tonic-gate 		return;
56927c478bd9Sstevel@tonic-gate 	}
56937c478bd9Sstevel@tonic-gate 
56947c478bd9Sstevel@tonic-gate 	/* get path from file struct here */
56957c478bd9Sstevel@tonic-gate 	fad = F2A(fp);
56967c478bd9Sstevel@tonic-gate 	ASSERT(fad);
56977c478bd9Sstevel@tonic-gate 
56987c478bd9Sstevel@tonic-gate 	/*
56997c478bd9Sstevel@tonic-gate 	 * already processed this file for write attempt
57007c478bd9Sstevel@tonic-gate 	 */
57017c478bd9Sstevel@tonic-gate 	if (fad->fad_flags & FAD_WRITE) {
57027c478bd9Sstevel@tonic-gate 		releasef(fd);
57037c478bd9Sstevel@tonic-gate 		/* don't really want to audit every send call */
57047c478bd9Sstevel@tonic-gate 		tad->tad_flag = 0;
57057c478bd9Sstevel@tonic-gate 		/* free any residual audit data */
5706005d3febSMarek Pospisil 		au_close(kctx, &(u_ad), 0, 0, 0, NULL);
57077c478bd9Sstevel@tonic-gate 		return;
57087c478bd9Sstevel@tonic-gate 	}
57097c478bd9Sstevel@tonic-gate 
57107c478bd9Sstevel@tonic-gate 	/* mark things so we know what happened and don't repeat things */
57117c478bd9Sstevel@tonic-gate 	fad->fad_flags |= FAD_WRITE;
57127c478bd9Sstevel@tonic-gate 
57137c478bd9Sstevel@tonic-gate 	so_family = so->so_family;
57147c478bd9Sstevel@tonic-gate 	so_type   = so->so_type;
57157c478bd9Sstevel@tonic-gate 
57167c478bd9Sstevel@tonic-gate 	switch (so_family) {
57177c478bd9Sstevel@tonic-gate 	case AF_INET:
57187c478bd9Sstevel@tonic-gate 	case AF_INET6:
57197c478bd9Sstevel@tonic-gate 		/*
57207c478bd9Sstevel@tonic-gate 		 * Only for connections.
57217c478bd9Sstevel@tonic-gate 		 * XXX - do we need to worry about SOCK_DGRAM or other types???
57227c478bd9Sstevel@tonic-gate 		 */
57237c478bd9Sstevel@tonic-gate 		if (so->so_state & SS_ISBOUND) {
57247c478bd9Sstevel@tonic-gate 
57257c478bd9Sstevel@tonic-gate 			bzero((void *)so_laddr, sizeof (so_laddr));
57267c478bd9Sstevel@tonic-gate 			bzero((void *)so_faddr, sizeof (so_faddr));
57277c478bd9Sstevel@tonic-gate 
57287c478bd9Sstevel@tonic-gate 			/* get local and foreign addresses */
57290f1702c5SYu Xiangning 			len = sizeof (so_laddr);
57300f1702c5SYu Xiangning 			(void) socket_getsockname(so,
57310f1702c5SYu Xiangning 			    (struct sockaddr *)so_laddr, &len, CRED());
57320f1702c5SYu Xiangning 			len = sizeof (so_faddr);
57330f1702c5SYu Xiangning 			(void) socket_getpeername(so,
57340f1702c5SYu Xiangning 			    (struct sockaddr *)so_faddr, &len, B_FALSE, CRED());
57357c478bd9Sstevel@tonic-gate 
57367c478bd9Sstevel@tonic-gate 			/*
57377c478bd9Sstevel@tonic-gate 			 * only way to drop out of switch. Note that we
57387c478bd9Sstevel@tonic-gate 			 * we release fd below.
57397c478bd9Sstevel@tonic-gate 			 */
57407c478bd9Sstevel@tonic-gate 
57417c478bd9Sstevel@tonic-gate 			break;
57427c478bd9Sstevel@tonic-gate 		}
57437c478bd9Sstevel@tonic-gate 
57447c478bd9Sstevel@tonic-gate 		releasef(fd);
57457c478bd9Sstevel@tonic-gate 		/* don't really want to audit every send call */
57467c478bd9Sstevel@tonic-gate 		tad->tad_flag = 0;
57477c478bd9Sstevel@tonic-gate 		/* free any residual audit data */
5748005d3febSMarek Pospisil 		au_close(kctx, &(u_ad), 0, 0, 0, NULL);
57497c478bd9Sstevel@tonic-gate 
57507c478bd9Sstevel@tonic-gate 		return;
57517c478bd9Sstevel@tonic-gate 
57527c478bd9Sstevel@tonic-gate 	case AF_UNIX:
57537c478bd9Sstevel@tonic-gate 
57547c478bd9Sstevel@tonic-gate 		if (fad->fad_aupath != NULL) {
57557c478bd9Sstevel@tonic-gate 			au_uwrite(au_to_path(fad->fad_aupath));
57567c478bd9Sstevel@tonic-gate 		} else {
57577c478bd9Sstevel@tonic-gate 			au_uwrite(au_to_arg32(1, "no path: fd", fd));
57587c478bd9Sstevel@tonic-gate 		}
57597c478bd9Sstevel@tonic-gate 
57607c478bd9Sstevel@tonic-gate 		audit_attributes(fp->f_vnode);
57617c478bd9Sstevel@tonic-gate 
57627c478bd9Sstevel@tonic-gate 		releasef(fd);
57637c478bd9Sstevel@tonic-gate 
57647c478bd9Sstevel@tonic-gate 		return;
57657c478bd9Sstevel@tonic-gate 
57667c478bd9Sstevel@tonic-gate 	default:
57677c478bd9Sstevel@tonic-gate 		releasef(fd);
57687c478bd9Sstevel@tonic-gate 
57697c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32(1, "so", (uint32_t)fd));
57707c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32(1, "family", (uint32_t)so_family));
57717c478bd9Sstevel@tonic-gate 		au_uwrite(au_to_arg32(1, "type", (uint32_t)so_type));
57727c478bd9Sstevel@tonic-gate 
57737c478bd9Sstevel@tonic-gate 		return;
57747c478bd9Sstevel@tonic-gate 	}
57757c478bd9Sstevel@tonic-gate 
57767c478bd9Sstevel@tonic-gate 	releasef(fd);
57777c478bd9Sstevel@tonic-gate 
57787c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_arg32(1, "so", (uint32_t)fd));
57797c478bd9Sstevel@tonic-gate 
57807c478bd9Sstevel@tonic-gate 	au_uwrite(au_to_socket_ex(so_family, so_type, so_laddr, so_faddr));
57817c478bd9Sstevel@tonic-gate }
5782657b1f3dSraf 
5783657b1f3dSraf static au_event_t
5784657b1f3dSraf aui_forksys(au_event_t e)
5785657b1f3dSraf {
5786657b1f3dSraf 	struct a {
5787657b1f3dSraf 		long	subcode;
5788657b1f3dSraf 		long	flags;
5789657b1f3dSraf 	} *uap = (struct a *)ttolwp(curthread)->lwp_ap;
5790657b1f3dSraf 
5791657b1f3dSraf 	switch ((uint_t)uap->subcode) {
5792657b1f3dSraf 	case 0:
5793657b1f3dSraf 		e = AUE_FORK1;
5794657b1f3dSraf 		break;
5795657b1f3dSraf 	case 1:
5796657b1f3dSraf 		e = AUE_FORKALL;
5797657b1f3dSraf 		break;
5798657b1f3dSraf 	case 2:
5799657b1f3dSraf 		e = AUE_VFORK;
5800657b1f3dSraf 		break;
5801657b1f3dSraf 	default:
5802657b1f3dSraf 		e = AUE_NULL;
5803657b1f3dSraf 		break;
5804657b1f3dSraf 	}
5805657b1f3dSraf 
5806657b1f3dSraf 	return (e);
5807657b1f3dSraf }
5808df2381bfSpraks 
5809df2381bfSpraks /*ARGSUSED*/
5810df2381bfSpraks static au_event_t
5811df2381bfSpraks aui_portfs(au_event_t e)
5812df2381bfSpraks {
5813df2381bfSpraks 	struct a {		/* portfs */
5814df2381bfSpraks 		long	a1;
5815df2381bfSpraks 		long	a2;
5816df2381bfSpraks 		long	a3;
5817df2381bfSpraks 	} *uap = (struct a *)ttolwp(curthread)->lwp_ap;
5818df2381bfSpraks 
5819df2381bfSpraks 	/*
5820df2381bfSpraks 	 * check opcode
5821df2381bfSpraks 	 */
5822df2381bfSpraks 	switch (((uint_t)uap->a1) & PORT_CODE_MASK) {
5823df2381bfSpraks 	case PORT_ASSOCIATE:
58248350182dSJan Friedel 		/* check source */
58258350182dSJan Friedel 		if (((uint_t)uap->a3 == PORT_SOURCE_FILE) ||
58268350182dSJan Friedel 		    ((uint_t)uap->a3 == PORT_SOURCE_FD)) {
58278350182dSJan Friedel 			e = AUE_PORTFS_ASSOCIATE;
58288350182dSJan Friedel 		} else {
58298350182dSJan Friedel 			e = AUE_NULL;
58308350182dSJan Friedel 		}
58318350182dSJan Friedel 		break;
5832df2381bfSpraks 	case PORT_DISSOCIATE:
58338350182dSJan Friedel 		/* check source */
58348350182dSJan Friedel 		if (((uint_t)uap->a3 == PORT_SOURCE_FILE) ||
58358350182dSJan Friedel 		    ((uint_t)uap->a3 == PORT_SOURCE_FD)) {
58368350182dSJan Friedel 			e = AUE_PORTFS_DISSOCIATE;
5837df2381bfSpraks 		} else {
5838df2381bfSpraks 			e = AUE_NULL;
5839df2381bfSpraks 		}
5840df2381bfSpraks 		break;
5841df2381bfSpraks 	default:
5842df2381bfSpraks 		e = AUE_NULL;
5843df2381bfSpraks 	}
5844df2381bfSpraks 	return (e);
5845df2381bfSpraks }
5846