Patch to hook up libtesla and assertions to the FreeBSD 9.x kernel. This assumes that something like the following has been done first: mkdir -p src/sys/tesla/assertions mkdir src/sys/tesla/assertions/audit mkdir src/sys/tesla/assertions/mwc ln -s ~/ctsrd/tesla/trunk/tesla/* src/sys/tesla/ ln -s ~/ctsrd/tesla/trunk/libtesla/*.[ch] src/sys/tesla/ ln -s ~/ctsrd/tesla/trunk/assertions/mwc/*.[ch] src/sys/tesla/assertions/mwc ln -s ~/ctsrd/tesla/trunk/assertions/audit/*.[ch] \ src/sys/tesla/assertions/audit Index: conf/files =================================================================== --- conf/files (revision 219626) +++ conf/files (working copy) @@ -2879,6 +2879,14 @@ security/mac_stub/mac_stub.c optional mac_stub security/mac_test/mac_test.c optional mac_test teken/teken.c optional sc +tesla/assertions/audit/audit_assertion.c optional tesla +tesla/assertions/audit/audit_automata.c optional tesla +tesla/assertions/mwc/mwc_assertion.c optional tesla +tesla/assertions/mwc/mwc_automata.c optional tesla +tesla/tesla_state.c optional tesla +tesla/tesla_state_global.c optional tesla +tesla/tesla_state_perthread.c optional tesla +tesla/tesla_util.c optional tesla ufs/ffs/ffs_alloc.c optional ffs ufs/ffs/ffs_balloc.c optional ffs ufs/ffs/ffs_inode.c optional ffs Index: conf/options =================================================================== --- conf/options (revision 219626) +++ conf/options (working copy) @@ -578,6 +578,7 @@ RESTARTABLE_PANICS opt_global.h RWLOCK_NOINLINE opt_global.h SX_NOINLINE opt_global.h +TESLA opt_global.h VFS_BIO_DEBUG opt_global.h # These are VM related options Index: kern/vfs_vnops.c =================================================================== --- kern/vfs_vnops.c (revision 219626) +++ kern/vfs_vnops.c (working copy) @@ -63,6 +63,8 @@ #include +#include + static fo_rdwr_t vn_read; static fo_rdwr_t vn_write; static fo_truncate_t vn_truncate; @@ -378,6 +380,8 @@ VFS_ASSERT_GIANT(vp->v_mount); + mwc_event_assertion(vp, file_cred); + if ((ioflg & IO_NODELOCKED) == 0) { mp = NULL; if (rw == UIO_WRITE) { Index: kern/subr_trap.c =================================================================== --- kern/subr_trap.c (revision 219626) +++ kern/subr_trap.c (working copy) @@ -76,6 +76,9 @@ #include +#include +#include + #ifdef VIMAGE #include #endif @@ -271,6 +274,9 @@ struct proc *p; int error, traced; + __tesla_event_function_prologue_syscall(NULL, 0); + mwc_event_tesla_syscall_enter(); + PCPU_INC(cnt.v_syscall); p = td->td_proc; @@ -423,5 +429,8 @@ td->td_dbgflags &= ~(TDB_SCX | TDB_EXEC | TDB_FORK); PROC_UNLOCK(p); } + + mwc_event_tesla_syscall_return(); + __tesla_event_function_return_syscall(NULL, 0); } #endif /* HAVE_SYSCALL_ARGS_DEF */ Index: security/mac/mac_vfs.c =================================================================== --- security/mac/mac_vfs.c (revision 219626) +++ security/mac/mac_vfs.c (working copy) @@ -77,6 +77,8 @@ #include #include +#include + /* * Warn about EA transactions only the first time they happen. No locking on * this variable. @@ -940,6 +942,8 @@ MAC_CHECK_PROBE3(vnode_check_write, error, active_cred, file_cred, vp); + mwc_event_mac_vnode_check_write(active_cred, vp, error); + return (error); } Index: security/audit/audit.c =================================================================== --- security/audit/audit.c (revision 219626) +++ security/audit/audit.c (working copy) @@ -70,6 +70,8 @@ #include #include +#include + #include FEATURE(audit, "BSM audit support"); @@ -574,6 +576,8 @@ { int retval; + __tesla_event_function_prologue_audit_submit(NULL); + /* * Commit the audit record as desired; once we pass the record into * audit_commit(), the memory is owned by the audit subsystem. The @@ -589,6 +593,8 @@ audit_commit(td->td_ar, error, retval); td->td_ar = NULL; td->td_pflags &= ~TDP_AUDITREC; + + __tesla_event_function_return_audit_submit(NULL, 0); } void Index: sys/kernel.h =================================================================== --- sys/kernel.h (revision 219626) +++ sys/kernel.h (working copy) @@ -111,6 +111,7 @@ SI_SUB_CPU = 0x2100000, /* CPU resource(s)*/ SI_SUB_RANDOM = 0x2120000, /* random number generator */ SI_SUB_KDTRACE = 0x2140000, /* Kernel dtrace hooks */ + SI_SUB_TESLA = 0x2140000, /* Kernel TESLA hooks */ SI_SUB_MAC = 0x2180000, /* TrustedBSD MAC subsystem */ SI_SUB_MAC_POLICY = 0x21C0000, /* TrustedBSD MAC policies */ SI_SUB_MAC_LATE = 0x21D0000, /* TrustedBSD MAC subsystem */ @@ -120,6 +121,7 @@ SI_SUB_DDB_SERVICES = 0x2380000, /* capture, scripting, etc. */ SI_SUB_RUN_QUEUE = 0x2400000, /* set up run queue*/ SI_SUB_KTRACE = 0x2480000, /* ktrace */ + SI_SUB_TESLA_ASSERTION = 0x2485000, /* TESLA assertions */ SI_SUB_OPENSOLARIS = 0x2490000, /* OpenSolaris compatibility */ SI_SUB_CYCLIC = 0x24A0000, /* Cyclic timers */ SI_SUB_AUDIT = 0x24C0000, /* audit */ Index: sys/proc.h =================================================================== --- sys/proc.h (revision 219626) +++ sys/proc.h (working copy) @@ -215,6 +215,7 @@ sigqueue_t td_sigqueue; /* (c) Sigs arrived, not delivered. */ #define td_siglist td_sigqueue.sq_signals u_char td_lend_user_pri; /* (t) Lend user pri. */ + void *td_tesla[TESLA_PERTHREAD_MAX]; /* (k) TESLA state. */ /* Cleared during fork1() */ #define td_startzero td_flags Index: sys/param.h =================================================================== --- sys/param.h (revision 219626) +++ sys/param.h (working copy) @@ -87,6 +87,7 @@ #define NOGROUP 65535 /* marker for empty group set member */ #define MAXHOSTNAMELEN 256 /* max hostname size */ #define SPECNAMELEN 63 /* max length of devicename */ +#define TESLA_PERTHREAD_MAX 8 /* max TESLA assertions/thread */ /* More types and definitions used throughout the kernel. */ #ifdef _KERNEL