Date: Fri, 20 Jan 2006 18:01:04 GMT From: Todd Miller <millert@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 90016 for review Message-ID: <200601201801.k0KI14b0089701@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=90016 Change 90016 by millert@millert_g4tower on 2006/01/20 18:00:52 Adapt to new module build method and pull in changes from DSEP Affected files ... .. //depot/projects/trustedbsd/sedarwin7/src/stacktrace/module/Makefile#4 edit .. //depot/projects/trustedbsd/sedarwin7/src/stacktrace/module/mac_stacktrace.c#5 edit .. //depot/projects/trustedbsd/sedarwin7/src/stacktrace/module/mac_stacktrace.c.in#1 add .. //depot/projects/trustedbsd/sedarwin7/src/stacktrace/module/mk_policy_ops.awk#1 add .. //depot/projects/trustedbsd/sedarwin7/src/stacktrace/module/mk_stubs.awk#1 add .. //depot/projects/trustedbsd/sedarwin7/src/stacktrace/module/mk_trace.awk#1 add Differences ... ==== //depot/projects/trustedbsd/sedarwin7/src/stacktrace/module/Makefile#4 (text+ko) ==== @@ -1,14 +1,57 @@ +POLICY= stacktrace +POLICY_VER= 1.0 +POLICY_COMPVER= 1.0 +POLICY_DESC= "Stacktrace module" +POLICY_SRCS= mac_stacktrace.c +POLICY_NOMAN= yes + +CFLAGS=-I.. -Wall + include ../../Makeconfig -include ../../darwin/build/PolicyKext.mk +include $(DARWIN_ROOT)/build/PolicyKext.mk + +CLEANFILES += trace.in stubs.in policy_ops.in policy.in \ + funcnames.in + +update: mac_stacktrace.c.in trace.in stubs.in policy_ops.in + @echo Updating mac_stacktrace.c... + @cpp -U__APPLE_CC__ -C -P mac_stacktrace.c.in \ + | sed -e 's/^@@@/#/g' \ + | grep -v ^#pragma \ + > mac_stacktrace.c + +policy.in: $(EXPORT_HDRS)/bsd/sys/mac_policy.h + @cpp -P $< \ + | grep -v ^\$ \ + | awk 'RS=";" { if ($$1 == "typedef") { print $$0";" } }' \ + | tr -d "\n\t" \ + | tr ";" "\n" \ + | sed -e 's/typedef //g' \ + -e 's/,/, /g' \ + -e 's/_t(/ (/g' \ + -e 's/ mpo_/ /g' \ + > $@ -CFLAGS += -DKERNEL -DAPPLE $(DARWIN_HDRS) -I.. +stubs.in: policy.in + @cat $< \ + | grep -v init_bsd \ + | grep -v syscall \ + | awk -f mk_stubs.awk \ + > $@ -mac_stacktrace.kext.tar: mac_stacktrace.o +trace.in: policy.in + @cat $< \ + | grep -v syscall \ + | awk -f mk_trace.awk \ + > $@ -clean: - rm -f mac_stacktrace.o mac_stacktrace.kext.tar - rm -rf mac_stacktrace.kext +funcnames.in: policy.in + @cat $< \ + | grep -v syscall \ + | awk '{if (NR != 1) { printf ",\n" } printf "\t\"" $$2 "\""}' \ + > $@ -install: mac_stacktrace.kext.tar - cat $< | (cd $(DESTDIR)/System/Library/Extensions; tar xf -) - touch $(DESTDIR)/System/Library/Extensions/mac_stacktrace.kext/LoadEarly +policy_ops.in: policy.in + @cat $< \ + | awk -f mk_policy_ops.awk \ + > $@ ==== //depot/projects/trustedbsd/sedarwin7/src/stacktrace/module/mac_stacktrace.c#5 (text+ko) ==== @@ -1,4 +1,5 @@ /*- + * Copyright (c) 2005 SPARTA, Inc. * Copyright (c) 2004 Networks Associates Technology, Inc. * All rights reserved. * @@ -31,9 +32,7 @@ #include <sys/types.h> #include <sys/param.h> #include <sys/conf.h> -#include <sys/extattr.h> #include <sys/kernel.h> -#include <sys/mac.h> #include <sys/malloc.h> #include <sys/mount.h> #include <sys/proc.h> @@ -47,15 +46,16 @@ #include <sys/shm.h> #include <stdarg.h> -#include <net/bpfdesc.h> #include <net/if.h> #include <net/if_types.h> #include <net/if_var.h> +#include <sys/mac.h> +#include <sys/mac_policy.h> + #include <mach/kmod.h> #include <kern/lock.h> #include <kern/kalloc.h> -#include <sys/mac_policy.h> #include "stacktrace_syscalls.h" #if 0 @@ -82,189 +82,206 @@ short onoff; }; -#define TRACE_DATA(name, num, onoff) \ - static struct function_info name##_td = { \ - num, \ - onoff, \ - } +#define TRACE_DATA(name, num, onoff) static struct function_info name##_td = { num, onoff } + TRACE_DATA(destroy, 0, STACKTRACE_ON); -TRACE_DATA(init, 1, STACKTRACE_OFF); // not tracing this because buffer not malloc'd yet -TRACE_DATA(syscall, 2, STACKTRACE_ON); -TRACE_DATA(init_bpfdesc_label, 3, STACKTRACE_ON); -TRACE_DATA(init_cred_label, 4, STACKTRACE_ON); +TRACE_DATA(init, 1, STACKTRACE_ON); +TRACE_DATA(init_bsd, 2, STACKTRACE_ON); +TRACE_DATA(init_cred_label, 3, STACKTRACE_ON); +TRACE_DATA(init_lctx_label, 4, STACKTRACE_ON); TRACE_DATA(init_devfsdirent_label, 5, STACKTRACE_ON); -TRACE_DATA(init_ifnet_label, 6, STACKTRACE_ON); -TRACE_DATA(init_ipq_label, 7, STACKTRACE_ON); -TRACE_DATA(init_mbuf_label, 8, STACKTRACE_ON); -TRACE_DATA(init_mount_label,9 , STACKTRACE_ON); -TRACE_DATA(init_mount_fs_label, 10, STACKTRACE_ON); -TRACE_DATA(init_socket_label, 11, STACKTRACE_ON); -TRACE_DATA(init_socket_peer_label, 12, STACKTRACE_ON); -TRACE_DATA(init_pipe_label, 13, STACKTRACE_ON); -TRACE_DATA(init_proc_label, 14, STACKTRACE_ON); -TRACE_DATA(init_task_label, 15, STACKTRACE_ON); -TRACE_DATA(init_port_label, 16, STACKTRACE_OFF); // disabled 2004-07-14 per RW -TRACE_DATA(init_vnode_label, 17, STACKTRACE_ON); -TRACE_DATA(destroy_bpfdesc_label, 18, STACKTRACE_ON); -TRACE_DATA(destroy_cred_label, 19 , STACKTRACE_ON); -TRACE_DATA(destroy_devfsdirent_label, 20, STACKTRACE_ON); -TRACE_DATA(destroy_ifnet_label, 21, STACKTRACE_ON); -TRACE_DATA(destroy_ipq_label, 22, STACKTRACE_ON); -TRACE_DATA(destroy_mbuf_label, 23, STACKTRACE_ON); -TRACE_DATA(destroy_mount_label, 24, STACKTRACE_ON); -TRACE_DATA(destroy_mount_fs_label, 25, STACKTRACE_ON); -TRACE_DATA(destroy_socket_label, 26, STACKTRACE_ON); -TRACE_DATA(destroy_socket_peer_label, 27, STACKTRACE_ON); -TRACE_DATA(destroy_pipe_label, 28, STACKTRACE_ON); -TRACE_DATA(destroy_proc_label, 29 , STACKTRACE_ON); -TRACE_DATA(destroy_task_label, 30, STACKTRACE_ON); -TRACE_DATA(destroy_port_label, 31, STACKTRACE_OFF); // disabled 2004-07-14 per RW -TRACE_DATA(destroy_vnode_label, 32, STACKTRACE_ON); -TRACE_DATA(copy_cred_to_task, 33, STACKTRACE_ON); -TRACE_DATA(copy_mbuf_label, 34, STACKTRACE_ON); -TRACE_DATA(update_port_from_cred_label, 35, STACKTRACE_OFF); // disabled 2004-07-14 per RW -TRACE_DATA(copy_pipe_label, 36, STACKTRACE_ON); -TRACE_DATA(copy_vnode_label, 37, STACKTRACE_ON); -TRACE_DATA(copy_devfs_label, 38, STACKTRACE_ON); -TRACE_DATA(copy_port_label, 39 , STACKTRACE_OFF); // disabled 2004-07-14 per RW -TRACE_DATA(externalize_cred_label, 40, STACKTRACE_ON); -TRACE_DATA(externalize_ifnet_label, 41, STACKTRACE_ON); -TRACE_DATA(externalize_pipe_label, 42, STACKTRACE_ON); -TRACE_DATA(externalize_socket_label, 43, STACKTRACE_ON); -TRACE_DATA(externalize_socket_peer_label, 44, STACKTRACE_ON); -TRACE_DATA(externalize_vnode_label, 45, STACKTRACE_ON); -TRACE_DATA(internalize_cred_label, 46, STACKTRACE_ON); -TRACE_DATA(internalize_ifnet_label, 47, STACKTRACE_ON); -TRACE_DATA(internalize_pipe_label, 48, STACKTRACE_ON); -TRACE_DATA(internalize_socket_label, 49 , STACKTRACE_ON); -TRACE_DATA(internalize_vnode_label, 50, STACKTRACE_ON); -TRACE_DATA(associate_vnode_devfs, 51, STACKTRACE_ON); -TRACE_DATA(associate_vnode_extattr, 52, STACKTRACE_ON); -TRACE_DATA(associate_vnode_singlelabel, 53, STACKTRACE_ON); -TRACE_DATA(create_devfs_device, 54, STACKTRACE_ON); -TRACE_DATA(create_devfs_directory, 55, STACKTRACE_ON); -TRACE_DATA(create_devfs_symlink, 56, STACKTRACE_ON); -TRACE_DATA(create_vnode_extattr, 57, STACKTRACE_ON); -TRACE_DATA(create_mount, 58, STACKTRACE_ON); -TRACE_DATA(create_root_mount, 59, STACKTRACE_ON); // deprecated & removed -TRACE_DATA(relabel_vnode, 60, STACKTRACE_ON); -TRACE_DATA(setlabel_vnode_extattr, 61, STACKTRACE_ON); -TRACE_DATA(update_devfsdirent, 62, STACKTRACE_ON); -TRACE_DATA(create_mbuf_from_socket, 63, STACKTRACE_ON); -TRACE_DATA(create_socket, 64, STACKTRACE_ON); -TRACE_DATA(create_socket_from_socket, 65, STACKTRACE_ON); -TRACE_DATA(relabel_socket, 66, STACKTRACE_ON); -TRACE_DATA(relabel_pipe, 67, STACKTRACE_ON); -TRACE_DATA(set_socket_peer_from_mbuf, 68, STACKTRACE_ON); -TRACE_DATA(set_socket_peer_from_socket, 69 , STACKTRACE_ON); -TRACE_DATA(create_pipe, 70, STACKTRACE_ON); -TRACE_DATA(create_port, 71, STACKTRACE_OFF); // disabled 2004-07-14 per RW -TRACE_DATA(create_bpfdesc, 72, STACKTRACE_ON); -TRACE_DATA(create_ifnet, 73, STACKTRACE_ON); -TRACE_DATA(create_ipq, 74, STACKTRACE_ON); -TRACE_DATA(create_datagram_from_ipq, 75, STACKTRACE_ON); -TRACE_DATA(create_fragment, 76, STACKTRACE_ON); -TRACE_DATA(create_mbuf_from_mbuf, 77, STACKTRACE_ON); -TRACE_DATA(create_mbuf_linklayer, 78, STACKTRACE_ON); -TRACE_DATA(create_mbuf_from_bpfdesc, 79 , STACKTRACE_ON); -TRACE_DATA(create_mbuf_from_ifnet, 80, STACKTRACE_ON); -TRACE_DATA(create_mbuf_multicast_encap, 81, STACKTRACE_ON); -TRACE_DATA(create_mbuf_netlayer, 82, STACKTRACE_ON); -TRACE_DATA(fragment_match, 83, STACKTRACE_ON); -TRACE_DATA(reflect_mbuf_icmp, 84, STACKTRACE_ON); -TRACE_DATA(reflect_mbuf_tcp, 85, STACKTRACE_ON); -TRACE_DATA(relabel_ifnet, 86, STACKTRACE_ON); -TRACE_DATA(update_ipq, 87, STACKTRACE_ON); -TRACE_DATA(update_mbuf_from_cipso, 88, STACKTRACE_ON); -TRACE_DATA(create_cred, 89 , STACKTRACE_ON); -TRACE_DATA(create_task,90, STACKTRACE_ON); -TRACE_DATA(execve_transition,91, STACKTRACE_ON); -TRACE_DATA(execve_will_transition,92, STACKTRACE_ON); -TRACE_DATA(create_proc0,93, STACKTRACE_ON); -TRACE_DATA(create_proc1,94, STACKTRACE_ON); -TRACE_DATA(relabel_cred,95, STACKTRACE_ON); -TRACE_DATA(thread_userret,96, STACKTRACE_ON); -TRACE_DATA(check_service_access,97, STACKTRACE_ON); -TRACE_DATA(check_bpfdesc_receive,98, STACKTRACE_ON); -TRACE_DATA(check_cred_relabel,99 , STACKTRACE_ON); -TRACE_DATA(check_port_relabel, 100, STACKTRACE_OFF); // disabled 2004-07-14 per RW -TRACE_DATA(check_port_send, 101, STACKTRACE_OFF); // disabled 2004-07-14 per RW -TRACE_DATA(check_port_make_send, 102, STACKTRACE_OFF); // disabled 2004-07-14 per RW -TRACE_DATA(check_port_copy_send, 103, STACKTRACE_OFF); // disabled 2004-07-14 per RW -TRACE_DATA(check_port_move_receive, 104, STACKTRACE_OFF); // disabled 2004-07-14 per RW +TRACE_DATA(init_mbuf_failed_label, 6, STACKTRACE_ON); +TRACE_DATA(init_mbuf_socket_label, 7, STACKTRACE_ON); +TRACE_DATA(init_mount_label, 8, STACKTRACE_ON); +TRACE_DATA(init_mount_fs_label, 9, STACKTRACE_ON); +TRACE_DATA(init_port_label, 10, STACKTRACE_ON); +TRACE_DATA(init_posix_sem_label, 11, STACKTRACE_ON); +TRACE_DATA(init_posix_shm_label, 12, STACKTRACE_ON); +TRACE_DATA(init_proc_label, 13, STACKTRACE_ON); +TRACE_DATA(init_socket_label, 14, STACKTRACE_ON); +TRACE_DATA(init_socket_peer_label, 15, STACKTRACE_ON); +TRACE_DATA(init_sysv_sem_label, 16, STACKTRACE_ON); +TRACE_DATA(init_sysv_shm_label, 17, STACKTRACE_ON); +TRACE_DATA(init_task_label, 18, STACKTRACE_ON); +TRACE_DATA(init_tcp_label, 19, STACKTRACE_ON); +TRACE_DATA(init_mbuf_unknown_source_label, 20, STACKTRACE_ON); +TRACE_DATA(init_vnode_label, 21, STACKTRACE_ON); +TRACE_DATA(destroy_cred_label, 22, STACKTRACE_ON); +TRACE_DATA(destroy_lctx_label, 23, STACKTRACE_ON); +TRACE_DATA(destroy_devfsdirent_label, 24, STACKTRACE_ON); +TRACE_DATA(destroy_mbuf_socket_label, 25, STACKTRACE_ON); +TRACE_DATA(destroy_mount_label, 26, STACKTRACE_ON); +TRACE_DATA(destroy_mount_fs_label, 27, STACKTRACE_ON); +TRACE_DATA(destroy_port_label, 28, STACKTRACE_ON); +TRACE_DATA(destroy_posix_sem_label, 29, STACKTRACE_ON); +TRACE_DATA(destroy_posix_shm_label, 30, STACKTRACE_ON); +TRACE_DATA(destroy_proc_label, 31, STACKTRACE_ON); +TRACE_DATA(destroy_socket_label, 32, STACKTRACE_ON); +TRACE_DATA(destroy_socket_peer_label, 33, STACKTRACE_ON); +TRACE_DATA(destroy_sysv_sem_label, 34, STACKTRACE_ON); +TRACE_DATA(destroy_sysv_shm_label, 35, STACKTRACE_ON); +TRACE_DATA(destroy_task_label, 36, STACKTRACE_ON); +TRACE_DATA(destroy_vnode_label, 37, STACKTRACE_ON); +TRACE_DATA(cleanup_sysv_sem_label, 38, STACKTRACE_ON); +TRACE_DATA(cleanup_sysv_shm_label, 39, STACKTRACE_ON); +TRACE_DATA(copy_cred_to_task, 40, STACKTRACE_ON); +TRACE_DATA(update_port_from_cred_label, 41, STACKTRACE_ON); +TRACE_DATA(copy_vnode_label, 42, STACKTRACE_ON); +TRACE_DATA(copy_devfs_label, 43, STACKTRACE_ON); +TRACE_DATA(copy_mbuf_socket_label, 44, STACKTRACE_ON); +TRACE_DATA(copy_port_label, 45, STACKTRACE_ON); +TRACE_DATA(externalize_cred_label, 46, STACKTRACE_ON); +TRACE_DATA(externalize_cred_audit_label, 47, STACKTRACE_ON); +TRACE_DATA(externalize_lctx_label, 48, STACKTRACE_ON); +TRACE_DATA(externalize_vnode_label, 49, STACKTRACE_ON); +TRACE_DATA(externalize_vnode_audit_label, 50, STACKTRACE_ON); +TRACE_DATA(internalize_cred_label, 51, STACKTRACE_ON); +TRACE_DATA(internalize_lctx_label, 52, STACKTRACE_ON); +TRACE_DATA(internalize_vnode_label, 53, STACKTRACE_ON); +TRACE_DATA(associate_vnode_devfs, 54, STACKTRACE_ON); +TRACE_DATA(associate_vnode_extattr, 55, STACKTRACE_ON); +TRACE_DATA(associate_vnode_singlelabel, 56, STACKTRACE_ON); +TRACE_DATA(create_devfs_device, 57, STACKTRACE_ON); +TRACE_DATA(create_devfs_directory, 58, STACKTRACE_ON); +TRACE_DATA(create_devfs_symlink, 59, STACKTRACE_ON); +TRACE_DATA(create_vnode_extattr, 60, STACKTRACE_ON); +TRACE_DATA(create_mount, 61, STACKTRACE_ON); +TRACE_DATA(relabel_vnode, 62, STACKTRACE_ON); +TRACE_DATA(setlabel_vnode_extattr, 63, STACKTRACE_ON); +TRACE_DATA(update_devfsdirent, 64, STACKTRACE_ON); +TRACE_DATA(copy_socket_label, 65, STACKTRACE_ON); +TRACE_DATA(create_socket, 66, STACKTRACE_ON); +TRACE_DATA(create_socket_from_socket, 67, STACKTRACE_ON); +TRACE_DATA(create_mbuf_from_socket, 68, STACKTRACE_ON); +TRACE_DATA(externalize_socket_label, 69, STACKTRACE_ON); +TRACE_DATA(externalize_socket_peer_label, 70, STACKTRACE_ON); +TRACE_DATA(internalize_socket_label, 71, STACKTRACE_ON); +TRACE_DATA(relabel_socket, 72, STACKTRACE_ON); +TRACE_DATA(set_socket_peer_from_socket, 73, STACKTRACE_ON); +TRACE_DATA(set_socket_peer_from_mbuf, 74, STACKTRACE_ON); +TRACE_DATA(create_port, 75, STACKTRACE_ON); +TRACE_DATA(create_kernel_port, 76, STACKTRACE_ON); +TRACE_DATA(update_port_kobject, 77, STACKTRACE_ON); +TRACE_DATA(create_posix_sem, 78, STACKTRACE_ON); +TRACE_DATA(create_posix_shm, 79, STACKTRACE_ON); +TRACE_DATA(create_sysv_sem, 80, STACKTRACE_ON); +TRACE_DATA(create_sysv_shm, 81, STACKTRACE_ON); +TRACE_DATA(create_cred, 82, STACKTRACE_ON); +TRACE_DATA(create_task, 83, STACKTRACE_ON); +TRACE_DATA(create_kernel_task, 84, STACKTRACE_ON); +TRACE_DATA(execve_transition, 85, STACKTRACE_ON); +TRACE_DATA(execve_will_transition, 86, STACKTRACE_ON); +TRACE_DATA(create_proc0, 87, STACKTRACE_ON); +TRACE_DATA(create_proc1, 88, STACKTRACE_ON); +TRACE_DATA(relabel_cred, 89, STACKTRACE_ON); +TRACE_DATA(request_object_label, 90, STACKTRACE_ON); +TRACE_DATA(proc_create_lctx, 91, STACKTRACE_ON); +TRACE_DATA(proc_join_lctx, 92, STACKTRACE_ON); +TRACE_DATA(proc_leave_lctx, 93, STACKTRACE_ON); +TRACE_DATA(relabel_lctx, 94, STACKTRACE_ON); +TRACE_DATA(check_service_access, 95, STACKTRACE_ON); +TRACE_DATA(check_cred_relabel, 96, STACKTRACE_ON); +TRACE_DATA(check_lctx_relabel, 97, STACKTRACE_ON); +TRACE_DATA(check_port_relabel, 98, STACKTRACE_ON); +TRACE_DATA(check_port_send, 99, STACKTRACE_ON); +TRACE_DATA(check_port_make_send, 100, STACKTRACE_ON); +TRACE_DATA(check_port_copy_send, 101, STACKTRACE_ON); +TRACE_DATA(check_port_hold_send, 102, STACKTRACE_ON); +TRACE_DATA(check_port_hold_receive, 103, STACKTRACE_ON); +TRACE_DATA(check_port_move_receive, 104, STACKTRACE_ON); TRACE_DATA(check_cred_visible, 105, STACKTRACE_ON); -TRACE_DATA(check_ifnet_relabel, 106, STACKTRACE_ON); -TRACE_DATA(check_ifnet_transmit, 107, STACKTRACE_ON); -TRACE_DATA(check_kenv_dump, 108, STACKTRACE_ON); -TRACE_DATA(check_kenv_get, 109 , STACKTRACE_ON); -TRACE_DATA(check_kenv_set, 110, STACKTRACE_ON); -TRACE_DATA(check_kenv_unset, 111, STACKTRACE_ON); -TRACE_DATA(check_kld_load, 112, STACKTRACE_ON); -TRACE_DATA(check_kld_stat, 113, STACKTRACE_ON); -TRACE_DATA(check_kld_unload, 114, STACKTRACE_ON); -TRACE_DATA(check_mount_stat, 115, STACKTRACE_ON); -TRACE_DATA(check_pipe_ioctl, 116, STACKTRACE_ON); -TRACE_DATA(check_pipe_poll, 117, STACKTRACE_ON); -TRACE_DATA(check_pipe_read, 118, STACKTRACE_ON); -TRACE_DATA(check_pipe_relabel, 119 , STACKTRACE_ON); -TRACE_DATA(check_pipe_stat, 120, STACKTRACE_ON); -TRACE_DATA(check_pipe_write, 121, STACKTRACE_ON); -TRACE_DATA(check_proc_debug, 122, STACKTRACE_ON); -TRACE_DATA(check_proc_sched, 123, STACKTRACE_ON); -TRACE_DATA(check_proc_signal, 124, STACKTRACE_ON); -TRACE_DATA(check_proc_wait, 125, STACKTRACE_ON); -TRACE_DATA(check_socket_bind, 126, STACKTRACE_ON); -TRACE_DATA(check_socket_connect, 127, STACKTRACE_ON); -TRACE_DATA(check_socket_deliver, 128, STACKTRACE_ON); -TRACE_DATA(check_socket_listen, 129 , STACKTRACE_ON); -TRACE_DATA(check_socket_receive, 130, STACKTRACE_ON); -TRACE_DATA(check_socket_relabel, 131, STACKTRACE_ON); -TRACE_DATA(check_socket_send, 132, STACKTRACE_ON); -TRACE_DATA(check_socket_visible, 133, STACKTRACE_ON); -TRACE_DATA(check_sysarch_ioperm, 134, STACKTRACE_ON); -TRACE_DATA(check_system_acct, 135, STACKTRACE_ON); -TRACE_DATA(check_system_nfsd, 136, STACKTRACE_ON); -TRACE_DATA(check_system_reboot, 137, STACKTRACE_ON); -TRACE_DATA(check_system_settime, 138, STACKTRACE_ON); -TRACE_DATA(check_system_swapon, 139 , STACKTRACE_ON); -TRACE_DATA(check_system_swapoff, 140, STACKTRACE_ON); -TRACE_DATA(check_system_sysctl, 141, STACKTRACE_ON); -TRACE_DATA(check_vnode_access, 142, STACKTRACE_ON); -TRACE_DATA(check_vnode_chdir, 143, STACKTRACE_ON); -TRACE_DATA(check_vnode_chroot, 144, STACKTRACE_ON); -TRACE_DATA(check_vnode_create, 145, STACKTRACE_ON); -TRACE_DATA(check_vnode_delete, 146, STACKTRACE_ON); -TRACE_DATA(check_vnode_deleteextattr, 147, STACKTRACE_ON); -TRACE_DATA(check_vnode_exec, 148, STACKTRACE_ON); -TRACE_DATA(check_vnode_deleteacl, 149 , STACKTRACE_ON); -TRACE_DATA(check_vnode_getacl, 150, STACKTRACE_ON); -TRACE_DATA(check_vnode_getextattr, 151, STACKTRACE_ON); -TRACE_DATA(check_vnode_link, 152, STACKTRACE_ON); -TRACE_DATA(check_vnode_listextattr, 153, STACKTRACE_ON); -TRACE_DATA(check_vnode_lookup, 154, STACKTRACE_ON); -TRACE_DATA(check_vnode_mmap, 155, STACKTRACE_ON); -TRACE_DATA(check_vnode_mmap_downgrade, 156, STACKTRACE_ON); -TRACE_DATA(check_vnode_mprotect, 157, STACKTRACE_ON); -TRACE_DATA(check_vnode_open, 158, STACKTRACE_ON); -TRACE_DATA(check_vnode_poll, 159 , STACKTRACE_ON); -TRACE_DATA(check_vnode_read, 160, STACKTRACE_ON); -TRACE_DATA(check_vnode_readdir, 161, STACKTRACE_ON); -TRACE_DATA(check_vnode_readlink, 162, STACKTRACE_ON); -TRACE_DATA(check_vnode_relabel, 163, STACKTRACE_ON); -TRACE_DATA(check_vnode_rename_from, 164, STACKTRACE_ON); -TRACE_DATA(check_vnode_rename_to, 165, STACKTRACE_ON); -TRACE_DATA(check_vnode_revoke, 166, STACKTRACE_ON); -TRACE_DATA(check_vnode_setacl, 167, STACKTRACE_ON); -TRACE_DATA(check_vnode_setextattr, 168, STACKTRACE_ON); -TRACE_DATA(check_vnode_setflags, 169 , STACKTRACE_ON); -TRACE_DATA(check_vnode_setmode, 170, STACKTRACE_ON); -TRACE_DATA(check_vnode_setowner, 171, STACKTRACE_ON); -TRACE_DATA(check_vnode_setutimes, 172, STACKTRACE_ON); -TRACE_DATA(check_vnode_stat, 173, STACKTRACE_ON); -TRACE_DATA(check_vnode_write, 174, STACKTRACE_ON); -TRACE_DATA(init_bsd, 175, STACKTRACE_ON); - +TRACE_DATA(check_fcntl, 106, STACKTRACE_ON); +TRACE_DATA(check_get_fd, 107, STACKTRACE_ON); +TRACE_DATA(check_ioctl, 108, STACKTRACE_ON); +TRACE_DATA(check_ipc_method, 109, STACKTRACE_ON); +TRACE_DATA(check_posix_sem_create, 110, STACKTRACE_ON); +TRACE_DATA(check_posix_sem_open, 111, STACKTRACE_ON); +TRACE_DATA(check_posix_sem_post, 112, STACKTRACE_ON); +TRACE_DATA(check_posix_sem_unlink, 113, STACKTRACE_ON); +TRACE_DATA(check_posix_sem_wait, 114, STACKTRACE_ON); +TRACE_DATA(check_posix_shm_create, 115, STACKTRACE_ON); +TRACE_DATA(check_posix_shm_open, 116, STACKTRACE_ON); +TRACE_DATA(check_posix_shm_mmap, 117, STACKTRACE_ON); +TRACE_DATA(check_posix_shm_stat, 118, STACKTRACE_ON); +TRACE_DATA(check_posix_shm_truncate, 119, STACKTRACE_ON); +TRACE_DATA(check_posix_shm_unlink, 120, STACKTRACE_ON); +TRACE_DATA(check_sysv_semctl, 121, STACKTRACE_ON); +TRACE_DATA(check_sysv_semget, 122, STACKTRACE_ON); +TRACE_DATA(check_sysv_semop, 123, STACKTRACE_ON); +TRACE_DATA(check_sysv_shmat, 124, STACKTRACE_ON); +TRACE_DATA(check_sysv_shmctl, 125, STACKTRACE_ON); +TRACE_DATA(check_sysv_shmdt, 126, STACKTRACE_ON); +TRACE_DATA(check_sysv_shmget, 127, STACKTRACE_ON); +TRACE_DATA(check_mount_stat, 128, STACKTRACE_ON); +TRACE_DATA(check_proc_debug, 129, STACKTRACE_ON); +TRACE_DATA(check_proc_sched, 130, STACKTRACE_ON); +TRACE_DATA(check_proc_signal, 131, STACKTRACE_ON); +TRACE_DATA(check_proc_wait, 132, STACKTRACE_ON); +TRACE_DATA(check_set_fd, 133, STACKTRACE_ON); +TRACE_DATA(check_socket_accept, 134, STACKTRACE_ON); +TRACE_DATA(check_socket_bind, 135, STACKTRACE_ON); +TRACE_DATA(check_socket_connect, 136, STACKTRACE_ON); +TRACE_DATA(check_socket_deliver, 137, STACKTRACE_ON); +TRACE_DATA(check_socket_listen, 138, STACKTRACE_ON); +TRACE_DATA(check_socket_poll, 139, STACKTRACE_ON); +TRACE_DATA(check_socket_receive, 140, STACKTRACE_ON); +TRACE_DATA(check_socket_relabel, 141, STACKTRACE_ON); +TRACE_DATA(check_socket_select, 142, STACKTRACE_ON); +TRACE_DATA(check_socket_send, 143, STACKTRACE_ON); +TRACE_DATA(check_socket_stat, 144, STACKTRACE_ON); +TRACE_DATA(check_system_acct, 145, STACKTRACE_ON); +TRACE_DATA(check_system_nfsd, 146, STACKTRACE_ON); +TRACE_DATA(check_system_reboot, 147, STACKTRACE_ON); +TRACE_DATA(check_system_settime, 148, STACKTRACE_ON); +TRACE_DATA(check_system_swapon, 149, STACKTRACE_ON); +TRACE_DATA(check_system_swapoff, 150, STACKTRACE_ON); +TRACE_DATA(check_system_sysctl, 151, STACKTRACE_ON); +TRACE_DATA(check_vnode_access, 152, STACKTRACE_ON); +TRACE_DATA(check_vnode_chdir, 153, STACKTRACE_ON); +TRACE_DATA(check_vnode_chroot, 154, STACKTRACE_ON); +TRACE_DATA(check_vnode_create, 155, STACKTRACE_ON); +TRACE_DATA(check_vnode_delete, 156, STACKTRACE_ON); +TRACE_DATA(check_vnode_deleteextattr, 157, STACKTRACE_ON); +TRACE_DATA(check_vnode_exchangedata, 158, STACKTRACE_ON); +TRACE_DATA(check_vnode_exec, 159, STACKTRACE_ON); +TRACE_DATA(check_vnode_getattrlist, 160, STACKTRACE_ON); +TRACE_DATA(check_vnode_getextattr, 161, STACKTRACE_ON); +TRACE_DATA(check_vnode_link, 162, STACKTRACE_ON); +TRACE_DATA(check_vnode_listextattr, 163, STACKTRACE_ON); +TRACE_DATA(check_vnode_lookup, 164, STACKTRACE_ON); +TRACE_DATA(check_vnode_mmap, 165, STACKTRACE_ON); +TRACE_DATA(check_vnode_mmap_downgrade, 166, STACKTRACE_ON); +TRACE_DATA(check_vnode_mprotect, 167, STACKTRACE_ON); +TRACE_DATA(check_vnode_open, 168, STACKTRACE_ON); +TRACE_DATA(check_vnode_poll, 169, STACKTRACE_ON); +TRACE_DATA(check_vnode_read, 170, STACKTRACE_ON); +TRACE_DATA(check_vnode_readdir, 171, STACKTRACE_ON); +TRACE_DATA(check_vnode_readlink, 172, STACKTRACE_ON); +TRACE_DATA(check_vnode_relabel, 173, STACKTRACE_ON); +TRACE_DATA(check_vnode_rename_from, 174, STACKTRACE_ON); +TRACE_DATA(check_vnode_rename_to, 175, STACKTRACE_ON); +TRACE_DATA(check_vnode_revoke, 176, STACKTRACE_ON); +TRACE_DATA(check_vnode_select, 177, STACKTRACE_ON); +TRACE_DATA(check_vnode_setattrlist, 178, STACKTRACE_ON); +TRACE_DATA(check_vnode_setextattr, 179, STACKTRACE_ON); +TRACE_DATA(check_vnode_setflags, 180, STACKTRACE_ON); +TRACE_DATA(check_vnode_setmode, 181, STACKTRACE_ON); +TRACE_DATA(check_vnode_setowner, 182, STACKTRACE_ON); +TRACE_DATA(check_vnode_setutimes, 183, STACKTRACE_ON); +TRACE_DATA(check_vnode_stat, 184, STACKTRACE_ON); +TRACE_DATA(check_vnode_write, 185, STACKTRACE_ON); +TRACE_DATA(check_system_audit, 186, STACKTRACE_ON); +TRACE_DATA(check_system_auditon, 187, STACKTRACE_ON); +TRACE_DATA(check_system_auditctl, 188, STACKTRACE_ON); +TRACE_DATA(check_proc_getauid, 189, STACKTRACE_ON); +TRACE_DATA(check_proc_getlcid, 190, STACKTRACE_ON); +TRACE_DATA(check_proc_setauid, 191, STACKTRACE_ON); +TRACE_DATA(check_proc_setlcid, 192, STACKTRACE_ON); +TRACE_DATA(check_proc_getaudit, 193, STACKTRACE_ON); +TRACE_DATA(check_proc_setaudit, 194, STACKTRACE_ON); +TRACE_DATA(audit_preselect, 195, STACKTRACE_ON); +TRACE_DATA(audit_postselect, 196, STACKTRACE_ON); /* * Buffer control. */ @@ -278,9 +295,7 @@ static int global_naxdepth = 0; // highest recursion level // TODO add a timestamp for time of last call // TODO add a timestamp for time of last reset -static mutex_t *buff_mtx; // mutex that protects a trace -static short global_enable = STACKTRACE_OFF; // STACKTRACE_ON or STACKTRACE_OFF, starts OFF till init_bsd -static int debugcount = 0; +static short global_enable = STACKTRACE_OFF; // STACKTRACE_ON, STACKTRACE_OFF or STACKTRACE_FULL; starts OFF till init_bsd /* * Initialize buffer pointers. @@ -303,18 +318,6 @@ // TODO add a timestamp for buffer reset } // initpointers -/* - * Return 1 if a pointer could be a code return address. - */ -static int -validcodeptr(const char *cp) -{ - - if ((cp != 0) && (((vm_address_t)cp & 0x80000000) == 0)) - return (1); - else - return (0); -} // validcodeptr /* * Return 1 if a pointer could be a stack frame pointer. @@ -416,7 +419,8 @@ initpointers(); // Reset the buffer to empty. global_resets++; } else if (global_fullbuffer_action == FULLBUFF_STOP) - global_enable = STACKTRACE_OFF; // Turn off tracing when buffer is full. + global_enable = STACKTRACE_FULL; + printf("stacktrace: buffer full, tracing disabled\n"); } // copy the temp slot into buffer, hopefully no page fault // TODO lock buffer, disable tracing @@ -443,7 +447,7 @@ * Syscall machinery. */ static int -stacktrace_syscall(struct proc *td, int call, void *args) +stacktrace_syscall(struct proc *td, int call, void *args, int *retv) { struct stacktrace_user_args p; int err = EINVAL; @@ -463,17 +467,20 @@ /* * If tracing goes from off too on, reset the buffer. */ - if (global_enable == STACKTRACE_OFF) + if (global_enable != STACKTRACE_ON) { initpointers(); - global_enable = STACKTRACE_ON; + global_enable = STACKTRACE_ON; + } err = 0; break; case STACKTRACE_OFF: - if (global_enable == STACKTRACE_ON) { - //kfree((vm_offset_t)buffer_basep, bufsize); - //buffer_basep = NULL; - } + + + + + + global_enable = STACKTRACE_OFF; err = 0; break; @@ -536,9 +543,11 @@ /* * Restore master trace setting following copyout() and - * buffer reset. + * buffer reset. If we had disabled tracing due to a full + * buffer, enable it now that the buffer has been flushed. */ - global_enable = prev_global_enable; + global_enable = (prev_global_enable == STACKTRACE_FULL) ? + STACKTRACE_ON : prev_global_enable; break; default: @@ -552,23 +561,8 @@ // ================================================================ static void -stacktrace_destroy(struct mac_policy_conf *conf) -{ - - trace(&destroy_td); -} // stacktrace_destroy - -static void -stacktrace_init(struct mac_policy_conf *conf) -{ - - trace(&init_td); -} // stacktrace_init - -static void -stacktrace_init_bsd(struct mac_policy_conf *conf) +stacktrace_init_bsd (struct mac_policy_conf *mpc) { - /* * We don't trace anything before this call. Thus we miss two calls: * to init and init_task_label (from machine_startup -> setup_main). @@ -576,1643 +570,1525 @@ global_enable = STACKTRACE_ON; initpointers(); trace(&init_bsd_td); -} // stacktrace_init_bsd +} -// stacktrace_syscall is above static void -stacktrace_init_bpfdesc_label(struct label *label) +stacktrace_destroy(struct mac_policy_conf *mpc) { + trace(&destroy_td); +} - trace(&init_bpfdesc_label_td); +static void +stacktrace_init(struct mac_policy_conf *mpc) +{ + trace(&init_td); } static void -stacktrace_init_cred_label(struct label *label) +stacktrace_init_cred_label(struct label *label) { - trace(&init_cred_label_td); } static void -stacktrace_init_devfsdirent_label(struct label *label) +stacktrace_init_lctx_label(struct label *label) { + trace(&init_lctx_label_td); +} +static void +stacktrace_init_devfsdirent_label(struct label *label) +{ trace(&init_devfsdirent_label_td); } static void -stacktrace_init_ifnet_label(struct label *label) +stacktrace_init_mbuf_failed_label(struct label *label) { - - trace(&init_ifnet_label_td); + trace(&init_mbuf_failed_label_td); } static int -stacktrace_init_ipq_label(struct label *label, int flag) +stacktrace_init_mbuf_socket_label(struct label *label, int waitok) { - - trace(&init_ipq_label_td); + trace(&init_mbuf_socket_label_td); return (0); } -static int -stacktrace_init_mbuf_label(struct label *label, int flag) +static void +stacktrace_init_mount_label(struct label *label) { + trace(&init_mount_label_td); +} - trace(&init_mbuf_label_td); - return (0); +static void +stacktrace_init_mount_fs_label(struct label *label) +{ + trace(&init_mount_fs_label_td); } static void -stacktrace_init_mount_label(struct label *label) +stacktrace_init_port_label(struct label *label) { + trace(&init_port_label_td); +} - trace(&init_mount_label_td); +static void +stacktrace_init_posix_sem_label(struct label *label) +{ + trace(&init_posix_sem_label_td); } static void -stacktrace_init_mount_fs_label(struct label *label) +stacktrace_init_posix_shm_label(struct label *label) { + trace(&init_posix_shm_label_td); +} - trace(&init_mount_fs_label_td); +static void +stacktrace_init_proc_label(struct label *label) +{ + trace(&init_proc_label_td); } static int -stacktrace_init_socket_label(struct label *label, int flag) +stacktrace_init_socket_label(struct label *label, int waitok) { - trace(&init_socket_label_td); return (0); } static int -stacktrace_init_socket_peer_label(struct label *label, int flag) +stacktrace_init_socket_peer_label(struct label *label, int waitok) { trace(&init_socket_peer_label_td); return (0); } -#if 0 // this is currently disabled in mac_policy.h (5-19-04) static void -stacktrace_init_pipe_label(struct label *label) +stacktrace_init_sysv_sem_label(struct label *label) { - - trace(&init_pipe_label_td); + trace(&init_sysv_sem_label_td); } -#endif static void -stacktrace_init_proc_label(struct label *label) +stacktrace_init_sysv_shm_label(struct label *label) { - - trace(&init_proc_label_td); + trace(&init_sysv_shm_label_td); } static void -stacktrace_init_task_label(struct label *label) +stacktrace_init_task_label(struct label *label) { - trace(&init_task_label_td); } static void -stacktrace_init_port_label(struct label *label) +stacktrace_init_tcp_label(struct label *label) { + trace(&init_tcp_label_td); +} -#ifndef NOPORTS - trace(&init_port_label_td); -#endif +static void +stacktrace_init_mbuf_unknown_source_label(struct label *label) +{ + trace(&init_mbuf_unknown_source_label_td); } static void -stacktrace_init_vnode_label(struct label *label) +stacktrace_init_vnode_label(struct label *label) { - trace(&init_vnode_label_td); } static void -stacktrace_destroy_bpfdesc_label(struct label *label) +stacktrace_destroy_cred_label(struct label *label) { - - trace(&destroy_bpfdesc_label_td); + trace(&destroy_cred_label_td); } static void -stacktrace_destroy_cred_label(struct label *label) +stacktrace_destroy_lctx_label(struct label *label) { - - trace(&destroy_cred_label_td); + trace(&destroy_lctx_label_td); } static void -stacktrace_destroy_devfsdirent_label(struct label *label) +stacktrace_destroy_devfsdirent_label(struct label *label) { - trace(&destroy_devfsdirent_label_td); } static void -stacktrace_destroy_ifnet_label(struct label *label) +stacktrace_destroy_mbuf_socket_label(struct label *label) { + trace(&destroy_mbuf_socket_label_td); +} - trace(&destroy_ifnet_label_td); +static void +stacktrace_destroy_mount_label(struct label *label) +{ + trace(&destroy_mount_label_td); } static void -stacktrace_destroy_ipq_label(struct label *label) +stacktrace_destroy_mount_fs_label(struct label *label) { + trace(&destroy_mount_fs_label_td); +} - trace(&destroy_ipq_label_td); +static void +stacktrace_destroy_port_label(struct label *label) +{ + trace(&destroy_port_label_td); } static void -stacktrace_destroy_mbuf_label(struct label *label) +stacktrace_destroy_posix_sem_label(struct label *label) { - - trace(&destroy_mbuf_label_td); + trace(&destroy_posix_sem_label_td); } static void -stacktrace_destroy_mount_label(struct label *label) +stacktrace_destroy_posix_shm_label(struct label *label) { - - trace(&destroy_mount_label_td); + trace(&destroy_posix_shm_label_td); } static void -stacktrace_destroy_mount_fs_label(struct label *label) +stacktrace_destroy_proc_label(struct label *label) { - - trace(&destroy_mount_fs_label_td); + trace(&destroy_proc_label_td); } static void -stacktrace_destroy_socket_label(struct label *label) +stacktrace_destroy_socket_label(struct label *label) { - trace(&destroy_socket_label_td); } static void -stacktrace_destroy_socket_peer_label(struct label *label) +stacktrace_destroy_socket_peer_label(struct label *label) { - trace(&destroy_socket_peer_label_td); } -#if 0 static void -stacktrace_destroy_pipe_label(struct label *label) +stacktrace_destroy_sysv_sem_label(struct label *label) { - - trace(&destroy_pipe_label_td); + trace(&destroy_sysv_sem_label_td); } -#endif static void -stacktrace_destroy_proc_label(struct label *label) +stacktrace_destroy_sysv_shm_label(struct label *label) { - - trace(&destroy_proc_label_td); + trace(&destroy_sysv_shm_label_td); } static void -stacktrace_destroy_task_label(struct label *label) +stacktrace_destroy_task_label(struct label *label) { - trace(&destroy_task_label_td); } static void -stacktrace_destroy_port_label(struct label *label) +stacktrace_destroy_vnode_label(struct label *label) { - - trace(&destroy_port_label_td); + trace(&destroy_vnode_label_td); } static void -stacktrace_destroy_vnode_label(struct label *label) +stacktrace_cleanup_sysv_sem_label(struct label *label) { - - trace(&destroy_vnode_label_td); + trace(&cleanup_sysv_sem_label_td); } static void -stacktrace_copy_cred_to_task(struct label *src, struct label *dest) +stacktrace_cleanup_sysv_shm_label(struct label *shmlabel) { - - trace(©_cred_to_task_td); + trace(&cleanup_sysv_shm_label_td); } static void -stacktrace_copy_mbuf_label(struct label *src, struct label *dest) +stacktrace_copy_cred_to_task(struct label *cred, struct label *task) { - - trace(©_mbuf_label_td); + trace(©_cred_to_task_td); } static void -stacktrace_update_port_from_cred_label(struct label *src, struct label *dest) +stacktrace_update_port_from_cred_label(struct label *cred, struct label *task) { - trace(&update_port_from_cred_label_td); } -#if 0 static void -stacktrace_copy_pipe_label(struct label *src, struct label *dest) +stacktrace_copy_vnode_label(struct label *src, struct label *dest) { - - trace(©_pipe_label_td); + trace(©_vnode_label_td); } -#endif static void -stacktrace_copy_vnode_label(struct label *src, struct label *dest) +stacktrace_copy_devfs_label(struct label *src, struct label *dest) { - - trace(©_vnode_label_td); + trace(©_devfs_label_td); } static void -stacktrace_copy_devfs_label(struct label *src, struct label *dest) +stacktrace_copy_mbuf_socket_label(struct label *src, struct label *dest) { - - trace(©_devfs_label_td); + trace(©_mbuf_socket_label_td); } static void -stacktrace_copy_port_label(struct label *src, struct label *dest) +stacktrace_copy_port_label(struct label *src, struct label *dest) { >>> TRUNCATED FOR MAIL (1000 lines) <<<
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200601201801.k0KI14b0089701>