Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 8 Mar 2009 00:50:37 +0000 (UTC)
From:      Robert Watson <rwatson@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r189503 - head/sys/security/mac
Message-ID:  <200903080050.n280obwZ067087@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: rwatson
Date: Sun Mar  8 00:50:37 2009
New Revision: 189503
URL: http://svn.freebsd.org/changeset/base/189503

Log:
  Add static DTrace probes for MAC Framework access control checks and
  privilege grants so that dtrace can be more easily used to monitor
  the security decisions being generated by the MAC Framework following
  policy invocation.
  
  Successful access control checks will be reported by:
  
    mac_framework:kernel:<entrypoint>:mac_check_ok
  
  Failed access control checks will be reported by:
  
    mac_framework:kernel:<entrypoint>:mac_check_err
  
  Successful privilege grants will be reported by:
  
    mac_framework:kernel:priv_grant:mac_grant_ok
  
  Failed privilege grants will be reported by:
  
    mac_framework:kernel:priv_grant:mac_grant_err
  
  In all cases, the return value (always 0 for _ok, otherwise an errno
  for _err) will be reported via arg0 on the probe, and subsequent
  arguments will hold entrypoint-specific data, in a style similar to
  privilege tracing.
  
  Obtained from:	TrustedBSD Project
  Sponsored by:	Google, Inc.

Modified:
  head/sys/security/mac/mac_audit.c
  head/sys/security/mac/mac_cred.c
  head/sys/security/mac/mac_framework.c
  head/sys/security/mac/mac_inet.c
  head/sys/security/mac/mac_internal.h
  head/sys/security/mac/mac_net.c
  head/sys/security/mac/mac_pipe.c
  head/sys/security/mac/mac_posix_sem.c
  head/sys/security/mac/mac_posix_shm.c
  head/sys/security/mac/mac_priv.c
  head/sys/security/mac/mac_process.c
  head/sys/security/mac/mac_socket.c
  head/sys/security/mac/mac_system.c
  head/sys/security/mac/mac_sysv_msg.c
  head/sys/security/mac/mac_sysv_sem.c
  head/sys/security/mac/mac_sysv_shm.c
  head/sys/security/mac/mac_vfs.c

Modified: head/sys/security/mac/mac_audit.c
==============================================================================
--- head/sys/security/mac/mac_audit.c	Sun Mar  8 00:11:26 2009	(r189502)
+++ head/sys/security/mac/mac_audit.c	Sun Mar  8 00:50:37 2009	(r189503)
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 1999-2002 Robert N. M. Watson
+ * Copyright (c) 1999-2002, 2009 Robert N. M. Watson
  * Copyright (c) 2001 Ilmar S. Habibulin
  * Copyright (c) 2001-2004 Networks Associates Technology, Inc.
  * Copyright (c) 2006 SPARTA, Inc.
@@ -15,6 +15,9 @@
  * This software was enhanced by SPARTA ISSO under SPAWAR contract
  * N66001-04-C-6019 ("SEFOS").
  *
+ * This software was developed at the University of Cambridge Computer
+ * Laboratory with support from a grant from Google, Inc. 
+ *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
@@ -40,8 +43,13 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
+#include "opt_kdtrace.h"
+
 #include <sys/param.h>
+#include <sys/kernel.h>
 #include <sys/module.h>
+#include <sys/queue.h>
+#include <sys/sdt.h>
 #include <sys/vnode.h>
 
 #include <security/audit/audit.h>
@@ -50,46 +58,64 @@ __FBSDID("$FreeBSD$");
 #include <security/mac/mac_internal.h>
 #include <security/mac/mac_policy.h>
 
+MAC_CHECK_PROBE_DEFINE2(proc_check_setaudit, "struct ucred *",
+    "struct auditinfo *");
+
 int
 mac_proc_check_setaudit(struct ucred *cred, struct auditinfo *ai)
 {
 	int error;
 
 	MAC_CHECK(proc_check_setaudit, cred, ai);
+	MAC_CHECK_PROBE2(proc_check_setaudit, error, cred, ai);
 
 	return (error);
 }
 
+MAC_CHECK_PROBE_DEFINE2(proc_check_setaudit_addr, "struct ucred *",
+    "struct auditinfo_addr *");
+
 int
 mac_proc_check_setaudit_addr(struct ucred *cred, struct auditinfo_addr *aia)
 {
 	int error;
 
 	MAC_CHECK(proc_check_setaudit_addr, cred, aia);
+	MAC_CHECK_PROBE2(proc_check_setaudit_addr, error, cred, aia);
 
 	return (error);
 }
 
+MAC_CHECK_PROBE_DEFINE2(proc_check_setauid, "struct ucred *", "uid_t");
+
 int
 mac_proc_check_setauid(struct ucred *cred, uid_t auid)
 {
 	int error;
 
 	MAC_CHECK(proc_check_setauid, cred, auid);
+	MAC_CHECK_PROBE2(proc_check_setauid, error, cred, auid);
 
 	return (error);
 }
 
+MAC_CHECK_PROBE_DEFINE3(system_check_audit, "struct ucred *", "void *",
+    "int");
+
 int
 mac_system_check_audit(struct ucred *cred, void *record, int length)
 {
 	int error;
 
 	MAC_CHECK(system_check_audit, cred, record, length);
+	MAC_CHECK_PROBE3(system_check_audit, error, cred, record, length);
 
 	return (error);
 }
 
+MAC_CHECK_PROBE_DEFINE2(system_check_auditctl, "struct ucred *",
+    "struct vnode *");
+
 int
 mac_system_check_auditctl(struct ucred *cred, struct vnode *vp)
 {
@@ -99,18 +125,21 @@ mac_system_check_auditctl(struct ucred *
 	ASSERT_VOP_LOCKED(vp, "mac_system_check_auditctl");
 
 	vl = (vp != NULL) ? vp->v_label : NULL;
-
 	MAC_CHECK(system_check_auditctl, cred, vp, vl);
+	MAC_CHECK_PROBE2(system_check_auditctl, error, cred, vp);
 
 	return (error);
 }
 
+MAC_CHECK_PROBE_DEFINE2(system_check_auditon, "struct ucred *", "int");
+
 int
 mac_system_check_auditon(struct ucred *cred, int cmd)
 {
 	int error;
 
 	MAC_CHECK(system_check_auditon, cred, cmd);
+	MAC_CHECK_PROBE2(system_check_auditon, error, cred, cmd);
 
 	return (error);
 }

Modified: head/sys/security/mac/mac_cred.c
==============================================================================
--- head/sys/security/mac/mac_cred.c	Sun Mar  8 00:11:26 2009	(r189502)
+++ head/sys/security/mac/mac_cred.c	Sun Mar  8 00:50:37 2009	(r189503)
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 1999-2002, 2008 Robert N. M. Watson
+ * Copyright (c) 1999-2002, 2008-2009 Robert N. M. Watson
  * Copyright (c) 2001 Ilmar S. Habibulin
  * Copyright (c) 2001-2003 Networks Associates Technology, Inc.
  * Copyright (c) 2005 Samy Al Bahra
@@ -18,6 +18,9 @@
  * This software was enhanced by SPARTA ISSO under SPAWAR contract
  * N66001-04-C-6019 ("SEFOS").
  *
+ * This software was developed at the University of Cambridge Computer
+ * Laboratory with support from a grant from Google, Inc. 
+ *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
@@ -43,6 +46,7 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
+#include "opt_kdtrace.h"
 #include "opt_mac.h"
 
 #include <sys/param.h>
@@ -55,6 +59,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/mac.h>
 #include <sys/proc.h>
 #include <sys/sbuf.h>
+#include <sys/sdt.h>
 #include <sys/systm.h>
 #include <sys/vnode.h>
 #include <sys/mount.h>
@@ -192,22 +197,30 @@ mac_cred_relabel(struct ucred *cred, str
 	MAC_PERFORM(cred_relabel, cred, newlabel);
 }
 
+MAC_CHECK_PROBE_DEFINE2(cred_check_relabel, "struct ucred *",
+    "struct label *");
+
 int
 mac_cred_check_relabel(struct ucred *cred, struct label *newlabel)
 {
 	int error;
 
 	MAC_CHECK(cred_check_relabel, cred, newlabel);
+	MAC_CHECK_PROBE2(cred_check_relabel, error, cred, newlabel);
 
 	return (error);
 }
 
+MAC_CHECK_PROBE_DEFINE2(cred_check_visible, "struct ucred *",
+    "struct ucred *");
+
 int
 mac_cred_check_visible(struct ucred *cr1, struct ucred *cr2)
 {
 	int error;
 
 	MAC_CHECK(cred_check_visible, cr1, cr2);
+	MAC_CHECK_PROBE2(cred_check_visible, error, cr1, cr2);
 
 	return (error);
 }

Modified: head/sys/security/mac/mac_framework.c
==============================================================================
--- head/sys/security/mac/mac_framework.c	Sun Mar  8 00:11:26 2009	(r189502)
+++ head/sys/security/mac/mac_framework.c	Sun Mar  8 00:50:37 2009	(r189503)
@@ -85,9 +85,11 @@ __FBSDID("$FreeBSD$");
 #include <security/mac/mac_policy.h>
 
 /*
- * DTrace SDT provider for MAC.
+ * DTrace SDT providers for MAC.
  */
 SDT_PROVIDER_DEFINE(mac);
+SDT_PROVIDER_DEFINE(mac_framework);
+
 SDT_PROBE_DEFINE2(mac, kernel, policy, modevent, "int",
     "struct mac_policy_conf *mpc");
 SDT_PROBE_DEFINE1(mac, kernel, policy, register, "struct mac_policy_conf *");

Modified: head/sys/security/mac/mac_inet.c
==============================================================================
--- head/sys/security/mac/mac_inet.c	Sun Mar  8 00:11:26 2009	(r189502)
+++ head/sys/security/mac/mac_inet.c	Sun Mar  8 00:50:37 2009	(r189503)
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 1999-2002, 2007 Robert N. M. Watson
+ * Copyright (c) 1999-2002, 2007, 2009 Robert N. M. Watson
  * Copyright (c) 2001 Ilmar S. Habibulin
  * Copyright (c) 2001-2004 Networks Associates Technology, Inc.
  * Copyright (c) 2006 SPARTA, Inc.
@@ -17,6 +17,9 @@
  * This software was enhanced by SPARTA ISSO under SPAWAR contract
  * N66001-04-C-6019 ("SEFOS").
  *
+ * This software was developed at the University of Cambridge Computer
+ * Laboratory with support from a grant from Google, Inc. 
+ *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
@@ -42,6 +45,7 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
+#include "opt_kdtrace.h"
 #include "opt_mac.h"
 
 #include <sys/param.h>
@@ -50,6 +54,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/malloc.h>
 #include <sys/mutex.h>
 #include <sys/sbuf.h>
+#include <sys/sdt.h>
 #include <sys/systm.h>
 #include <sys/mount.h>
 #include <sys/file.h>
@@ -298,6 +303,9 @@ mac_ipq_update(struct mbuf *m, struct ip
 	MAC_PERFORM(ipq_update, m, label, q, q->ipq_label);
 }
 
+MAC_CHECK_PROBE_DEFINE2(inpcb_check_deliver, "struct inpcb *",
+    "struct mbuf *");
+
 int
 mac_inpcb_check_deliver(struct inpcb *inp, struct mbuf *m)
 {
@@ -309,10 +317,14 @@ mac_inpcb_check_deliver(struct inpcb *in
 	label = mac_mbuf_to_label(m);
 
 	MAC_CHECK(inpcb_check_deliver, inp, inp->inp_label, m, label);
+	MAC_CHECK_PROBE2(inpcb_check_deliver, error, inp, m);
 
 	return (error);
 }
 
+MAC_CHECK_PROBE_DEFINE2(inpcb_check_visible, "struct ucred *",
+    "struct inpcb *");
+
 int
 mac_inpcb_check_visible(struct ucred *cred, struct inpcb *inp)
 {
@@ -321,6 +333,7 @@ mac_inpcb_check_visible(struct ucred *cr
 	INP_LOCK_ASSERT(inp);
 
 	MAC_CHECK(inpcb_check_visible, cred, inp, inp->inp_label);
+	MAC_CHECK_PROBE2(inpcb_check_visible, error, cred, inp);
 
 	return (error);
 }

Modified: head/sys/security/mac/mac_internal.h
==============================================================================
--- head/sys/security/mac/mac_internal.h	Sun Mar  8 00:11:26 2009	(r189502)
+++ head/sys/security/mac/mac_internal.h	Sun Mar  8 00:50:37 2009	(r189503)
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 1999-2002, 2006 Robert N. M. Watson
+ * Copyright (c) 1999-2002, 2006, 2009 Robert N. M. Watson
  * Copyright (c) 2001 Ilmar S. Habibulin
  * Copyright (c) 2001-2004 Networks Associates Technology, Inc.
  * Copyright (c) 2006 nCircle Network Security, Inc.
@@ -21,6 +21,9 @@
  * This software was enhanced by SPARTA ISSO under SPAWAR contract
  * N66001-04-C-6019 ("SEFOS").
  *
+ * This software was developed at the University of Cambridge Computer
+ * Laboratory with support from a grant from Google, Inc. 
+ *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
@@ -60,6 +63,72 @@ SYSCTL_DECL(_security_mac);
 #endif /* SYSCTL_DECL */
 
 /*
+ * MAC Framework SDT DTrace probe namespace, macros for declaring entry
+ * point probes, macros for invoking them.
+ */
+#ifdef SDT_PROVIDER_DECLARE
+SDT_PROVIDER_DECLARE(mac);		/* MAC Framework-level events. */
+SDT_PROVIDER_DECLARE(mac_framework);	/* Entry points to MAC. */
+
+#define	MAC_CHECK_PROBE_DEFINE4(name, arg0, arg1, arg2, arg3)		\
+	SDT_PROBE_DEFINE5(mac_framework, kernel, name, mac_check_err,	\
+	    "int", arg0, arg1, arg2, arg3);				\
+	SDT_PROBE_DEFINE5(mac_framework, kernel, name, mac_check_ok,	\
+	    "int", arg0, arg1, arg2, arg3);
+
+#define	MAC_CHECK_PROBE_DEFINE3(name, arg0, arg1, arg2)			\
+	SDT_PROBE_DEFINE4(mac_framework, kernel, name, mac_check_err,	\
+	    "int", arg0, arg1, arg2);					\
+	SDT_PROBE_DEFINE4(mac_framework, kernel, name, mac_check_ok,	\
+	    "int", arg0, arg1, arg2);
+
+#define	MAC_CHECK_PROBE_DEFINE2(name, arg0, arg1)			\
+	SDT_PROBE_DEFINE3(mac_framework, kernel, name, mac_check_err,	\
+	    "int", arg0, arg1);						\
+	SDT_PROBE_DEFINE3(mac_framework, kernel, name, mac_check_ok,	\
+	    "int", arg0, arg1);
+
+#define	MAC_CHECK_PROBE_DEFINE1(name, arg0)				\
+	SDT_PROBE_DEFINE2(mac_framework, kernel, name, mac_check_err,	\
+	    "int", arg0);						\
+	SDT_PROBE_DEFINE2(mac_framework, kernel, name, mac_check_ok,	\
+	    "int", arg0);
+
+#define	MAC_CHECK_PROBE4(name, error, arg0, arg1, arg2, arg3)	do {	\
+	if (error) {							\
+		SDT_PROBE(mac_framework, kernel, name, mac_check_err,	\
+		    error, arg0, arg1, arg2, arg3);			\
+	} else {							\
+		SDT_PROBE(mac_framework, kernel, name, mac_check_ok,	\
+		    0, arg0, arg1, arg2, arg3);				\
+	}								\
+} while (0)
+
+#define	MAC_CHECK_PROBE3(name, error, arg0, arg1, arg2)			\
+	MAC_CHECK_PROBE4(name, error, arg0, arg1, arg2, 0)
+#define	MAC_CHECK_PROBE2(name, error, arg0, arg1)			\
+	MAC_CHECK_PROBE3(name, error, arg0, arg1, 0)
+#define	MAC_CHECK_PROBE1(name, error, arg0)				\
+	MAC_CHECK_PROBE2(name, error, arg0, 0)
+#endif
+
+#define	MAC_GRANT_PROBE_DEFINE2(name, arg0, arg1)			\
+	SDT_PROBE_DEFINE3(mac_framework, kernel, name, mac_grant_err,	\
+	    "int", arg0, arg1);						\
+	SDT_PROBE_DEFINE3(mac_framework, kernel, name, mac_grant_ok,	\
+	    "INT", arg0, arg1);
+
+#define	MAC_GRANT_PROBE2(name, error, arg0, arg1)	do {		\
+	if (error) {							\
+		SDT_PROBE(mac_framework, kernel, name, mac_grant_err,	\
+		    error, arg0, arg1, 0, 0);				\
+	} else {							\
+		SDT_PROBE(mac_framework, kernel, name, mac_grant_ok,	\
+		    error, arg0, arg1, 0, 0);				\
+	}								\
+} while (0)
+
+/*
  * MAC Framework global types and typedefs.
  */
 LIST_HEAD(mac_policy_list_head, mac_policy_conf);

Modified: head/sys/security/mac/mac_net.c
==============================================================================
--- head/sys/security/mac/mac_net.c	Sun Mar  8 00:11:26 2009	(r189502)
+++ head/sys/security/mac/mac_net.c	Sun Mar  8 00:50:37 2009	(r189503)
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 1999-2002 Robert N. M. Watson
+ * Copyright (c) 1999-2002, 2009 Robert N. M. Watson
  * Copyright (c) 2001 Ilmar S. Habibulin
  * Copyright (c) 2001-2004 Networks Associates Technology, Inc.
  * Copyright (c) 2006 SPARTA, Inc.
@@ -17,6 +17,9 @@
  * Associates, Inc. under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"),
  * as part of the DARPA CHATS research program.
  *
+ * This software was developed at the University of Cambridge Computer
+ * Laboratory with support from a grant from Google, Inc. 
+ *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
@@ -42,6 +45,7 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
+#include "opt_kdtrace.h"
 #include "opt_mac.h"
 
 #include <sys/param.h>
@@ -52,6 +56,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/mac.h>
 #include <sys/priv.h>
 #include <sys/sbuf.h>
+#include <sys/sdt.h>
 #include <sys/systm.h>
 #include <sys/mount.h>
 #include <sys/file.h>
@@ -324,6 +329,9 @@ mac_ifnet_create_mbuf(struct ifnet *ifp,
 	MAC_IFNET_UNLOCK(ifp);
 }
 
+MAC_CHECK_PROBE_DEFINE2(bpfdesc_check_receive, "struct bpf_d *",
+    "struct ifnet *");
+
 int
 mac_bpfdesc_check_receive(struct bpf_d *d, struct ifnet *ifp)
 {
@@ -333,11 +341,15 @@ mac_bpfdesc_check_receive(struct bpf_d *
 
 	MAC_IFNET_LOCK(ifp);
 	MAC_CHECK(bpfdesc_check_receive, d, d->bd_label, ifp, ifp->if_label);
+	MAC_CHECK_PROBE2(bpfdesc_check_receive, error, d, ifp);
 	MAC_IFNET_UNLOCK(ifp);
 
 	return (error);
 }
 
+MAC_CHECK_PROBE_DEFINE2(ifnet_check_transmit, "struct ifnet *",
+    "struct mbuf *");
+
 int
 mac_ifnet_check_transmit(struct ifnet *ifp, struct mbuf *m)
 {
@@ -350,6 +362,7 @@ mac_ifnet_check_transmit(struct ifnet *i
 
 	MAC_IFNET_LOCK(ifp);
 	MAC_CHECK(ifnet_check_transmit, ifp, ifp->if_label, m, label);
+	MAC_CHECK_PROBE2(ifnet_check_transmit, error, ifp, m);
 	MAC_IFNET_UNLOCK(ifp);
 
 	return (error);

Modified: head/sys/security/mac/mac_pipe.c
==============================================================================
--- head/sys/security/mac/mac_pipe.c	Sun Mar  8 00:11:26 2009	(r189502)
+++ head/sys/security/mac/mac_pipe.c	Sun Mar  8 00:50:37 2009	(r189503)
@@ -1,6 +1,7 @@
 /*-
  * Copyright (c) 2002-2003 Networks Associates Technology, Inc.
  * Copyright (c) 2006 SPARTA, Inc.
+ * Copyright (c) 2009 Robert N. M. Watson
  * All rights reserved.
  *
  * This software was developed for the FreeBSD Project in part by Network
@@ -11,6 +12,9 @@
  * This software was enhanced by SPARTA ISSO under SPAWAR contract
  * N66001-04-C-6019 ("SEFOS").
  *
+ * This software was developed at the University of Cambridge Computer
+ * Laboratory with support from a grant from Google, Inc. 
+ *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
@@ -36,6 +40,7 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
+#include "opt_kdtrace.h"
 #include "opt_mac.h"
 
 #include <sys/param.h>
@@ -45,6 +50,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/module.h>
 #include <sys/mutex.h>
 #include <sys/sbuf.h>
+#include <sys/sdt.h>
 #include <sys/systm.h>
 #include <sys/vnode.h>
 #include <sys/pipe.h>
@@ -135,6 +141,9 @@ mac_pipe_relabel(struct ucred *cred, str
 	MAC_PERFORM(pipe_relabel, cred, pp, pp->pp_label, newlabel);
 }
 
+MAC_CHECK_PROBE_DEFINE4(pipe_check_ioctl, "struct ucred *",
+    "struct pipepair *", "unsigned long", "void *");
+
 int
 mac_pipe_check_ioctl(struct ucred *cred, struct pipepair *pp,
     unsigned long cmd, void *data)
@@ -144,10 +153,14 @@ mac_pipe_check_ioctl(struct ucred *cred,
 	mtx_assert(&pp->pp_mtx, MA_OWNED);
 
 	MAC_CHECK(pipe_check_ioctl, cred, pp, pp->pp_label, cmd, data);
+	MAC_CHECK_PROBE4(pipe_check_ioctl, error, cred, pp, cmd, data);
 
 	return (error);
 }
 
+MAC_CHECK_PROBE_DEFINE2(pipe_check_poll, "struct ucred *",
+    "struct pipepair *");
+
 int
 mac_pipe_check_poll(struct ucred *cred, struct pipepair *pp)
 {
@@ -156,10 +169,14 @@ mac_pipe_check_poll(struct ucred *cred, 
 	mtx_assert(&pp->pp_mtx, MA_OWNED);
 
 	MAC_CHECK(pipe_check_poll, cred, pp, pp->pp_label);
+	MAC_CHECK_PROBE2(pipe_check_poll, error, cred, pp);
 
 	return (error);
 }
 
+MAC_CHECK_PROBE_DEFINE2(pipe_check_read, "struct ucred *",
+    "struct pipepair *");
+
 int
 mac_pipe_check_read(struct ucred *cred, struct pipepair *pp)
 {
@@ -168,10 +185,14 @@ mac_pipe_check_read(struct ucred *cred, 
 	mtx_assert(&pp->pp_mtx, MA_OWNED);
 
 	MAC_CHECK(pipe_check_read, cred, pp, pp->pp_label);
+	MAC_CHECK_PROBE2(pipe_check_read, error, cred, pp);
 
 	return (error);
 }
 
+MAC_CHECK_PROBE_DEFINE3(pipe_check_relabel, "struct ucred *",
+    "struct pipepair *", "struct label *");
+
 static int
 mac_pipe_check_relabel(struct ucred *cred, struct pipepair *pp,
     struct label *newlabel)
@@ -181,10 +202,14 @@ mac_pipe_check_relabel(struct ucred *cre
 	mtx_assert(&pp->pp_mtx, MA_OWNED);
 
 	MAC_CHECK(pipe_check_relabel, cred, pp, pp->pp_label, newlabel);
+	MAC_CHECK_PROBE3(pipe_check_relabel, error, cred, pp, newlabel);
 
 	return (error);
 }
 
+MAC_CHECK_PROBE_DEFINE2(pipe_check_stat, "struct ucred *",
+    "struct pipepair *");
+
 int
 mac_pipe_check_stat(struct ucred *cred, struct pipepair *pp)
 {
@@ -193,10 +218,14 @@ mac_pipe_check_stat(struct ucred *cred, 
 	mtx_assert(&pp->pp_mtx, MA_OWNED);
 
 	MAC_CHECK(pipe_check_stat, cred, pp, pp->pp_label);
+	MAC_CHECK_PROBE2(pipe_check_stat, error, cred, pp);
 
 	return (error);
 }
 
+MAC_CHECK_PROBE_DEFINE2(pipe_check_write, "struct ucred *",
+    "struct pipepair *");
+
 int
 mac_pipe_check_write(struct ucred *cred, struct pipepair *pp)
 {
@@ -205,6 +234,7 @@ mac_pipe_check_write(struct ucred *cred,
 	mtx_assert(&pp->pp_mtx, MA_OWNED);
 
 	MAC_CHECK(pipe_check_write, cred, pp, pp->pp_label);
+	MAC_CHECK_PROBE2(pipe_check_write, error, cred, pp);
 
 	return (error);
 }

Modified: head/sys/security/mac/mac_posix_sem.c
==============================================================================
--- head/sys/security/mac/mac_posix_sem.c	Sun Mar  8 00:11:26 2009	(r189502)
+++ head/sys/security/mac/mac_posix_sem.c	Sun Mar  8 00:50:37 2009	(r189503)
@@ -1,5 +1,6 @@
 /*-
  * Copyright (c) 2003-2006 SPARTA, Inc.
+ * Copyright (c) 2009 Robert N. M. Watson
  * All rights reserved.
  *
  * This software was developed for the FreeBSD Project in part by Network
@@ -10,6 +11,9 @@
  * This software was enhanced by SPARTA ISSO under SPAWAR contract
  * N66001-04-C-6019 ("SEFOS").
  *
+ * This software was developed at the University of Cambridge Computer
+ * Laboratory with support from a grant from Google, Inc. 
+ *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
@@ -35,6 +39,7 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
+#include "opt_kdtrace.h"
 #include "opt_mac.h"
 #include "opt_posix.h"
 
@@ -43,6 +48,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/ksem.h>
 #include <sys/malloc.h>
 #include <sys/module.h>
+#include <sys/sdt.h>
 #include <sys/systm.h>
 #include <sys/sysctl.h>
 
@@ -95,16 +101,23 @@ mac_posixsem_create(struct ucred *cred, 
 	MAC_PERFORM(posixsem_create, cred, ks, ks->ks_label);
 }
 
+MAC_CHECK_PROBE_DEFINE2(posixsem_check_open, "struct ucred *",
+    "struct ksem *");
+
 int
 mac_posixsem_check_open(struct ucred *cred, struct ksem *ks)
 {
 	int error;
 
 	MAC_CHECK(posixsem_check_open, cred, ks, ks->ks_label);
+	MAC_CHECK_PROBE2(posixsem_check_open, error, cred, ks);
 
 	return (error);
 }
 
+MAC_CHECK_PROBE_DEFINE3(posixsem_check_getvalue, "struct ucred *",
+    "struct ucred *", "struct ksem *");
+
 int
 mac_posixsem_check_getvalue(struct ucred *active_cred, struct ucred *file_cred,
     struct ksem *ks)
@@ -113,10 +126,15 @@ mac_posixsem_check_getvalue(struct ucred
 
 	MAC_CHECK(posixsem_check_getvalue, active_cred, file_cred, ks,
 	    ks->ks_label);
+	MAC_CHECK_PROBE3(posixsem_check_getvalue, error, active_cred,
+	    file_cred, ks);
 
 	return (error);
 }
 
+MAC_CHECK_PROBE_DEFINE3(posixsem_check_post, "struct ucred *",
+    "struct ucred *", "struct ksem *");
+
 int
 mac_posixsem_check_post(struct ucred *active_cred, struct ucred *file_cred,
     struct ksem *ks)
@@ -125,10 +143,15 @@ mac_posixsem_check_post(struct ucred *ac
 
 	MAC_CHECK(posixsem_check_post, active_cred, file_cred, ks,
 	    ks->ks_label);
+	MAC_CHECK_PROBE3(posixsem_check_post, error, active_cred, file_cred,
+	    ks);
 
 	return (error);
 }
 
+MAC_CHECK_PROBE_DEFINE3(posixsem_check_stat, "struct ucred *",
+    "struct ucred *", "struct ksem *");
+
 int
 mac_posixsem_check_stat(struct ucred *active_cred, struct ucred *file_cred,
     struct ksem *ks)
@@ -137,20 +160,29 @@ mac_posixsem_check_stat(struct ucred *ac
 
 	MAC_CHECK(posixsem_check_stat, active_cred, file_cred, ks,
 	    ks->ks_label);
+	MAC_CHECK_PROBE3(posixsem_check_stat, error, active_cred, file_cred,
+	    ks);
 
 	return (error);
 }
 
+MAC_CHECK_PROBE_DEFINE2(posixsem_check_unlink, "struct ucred *",
+    "struct ksem *");
+
 int
 mac_posixsem_check_unlink(struct ucred *cred, struct ksem *ks)
 {
 	int error;
 
 	MAC_CHECK(posixsem_check_unlink, cred, ks, ks->ks_label);
+	MAC_CHECK_PROBE2(posixsem_check_unlink, error, cred, ks);
 
 	return (error);
 }
 
+MAC_CHECK_PROBE_DEFINE3(posixsem_check_wait, "struct ucred *",
+    "struct ucred *", "struct ksem *");
+
 int
 mac_posixsem_check_wait(struct ucred *active_cred, struct ucred *file_cred,
     struct ksem *ks)
@@ -159,6 +191,8 @@ mac_posixsem_check_wait(struct ucred *ac
 
 	MAC_CHECK(posixsem_check_wait, active_cred, file_cred, ks,
 	    ks->ks_label);
+	MAC_CHECK_PROBE3(posixsem_check_wait, error, active_cred, file_cred,
+	    ks);
 
 	return (error);
 }

Modified: head/sys/security/mac/mac_posix_shm.c
==============================================================================
--- head/sys/security/mac/mac_posix_shm.c	Sun Mar  8 00:11:26 2009	(r189502)
+++ head/sys/security/mac/mac_posix_shm.c	Sun Mar  8 00:50:37 2009	(r189503)
@@ -1,5 +1,6 @@
 /*-
  * Copyright (c) 2003-2006 SPARTA, Inc.
+ * Copyright (c) 2009 Robert N. M. Watson
  * All rights reserved.
  *
  * This software was developed for the FreeBSD Project in part by Network
@@ -8,7 +9,10 @@
  * as part of the DARPA CHATS research program.
  *
  * This software was enhanced by SPARTA ISSO under SPAWAR contract
- * N66001-04-C-6019 ("SEFOS").
+ * N66001-04-C-6019 ("SEFOS"). *
+ *
+ * This software was developed at the University of Cambridge Computer
+ * Laboratory with support from a grant from Google, Inc. 
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -35,6 +39,7 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
+#include "opt_kdtrace.h"
 #include "opt_mac.h"
 
 #include <sys/param.h>
@@ -42,6 +47,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/mman.h>
 #include <sys/malloc.h>
 #include <sys/module.h>
+#include <sys/sdt.h>
 #include <sys/systm.h>
 #include <sys/sysctl.h>
 
@@ -94,6 +100,9 @@ mac_posixshm_create(struct ucred *cred, 
 	MAC_PERFORM(posixshm_create, cred, shmfd, shmfd->shm_label);
 }
 
+MAC_CHECK_PROBE_DEFINE4(posixshm_check_mmap, "struct ucred *",
+    "struct shmfd *", "int", "int");
+
 int
 mac_posixshm_check_mmap(struct ucred *cred, struct shmfd *shmfd, int prot,
     int flags)
@@ -102,20 +111,29 @@ mac_posixshm_check_mmap(struct ucred *cr
 
 	MAC_CHECK(posixshm_check_mmap, cred, shmfd, shmfd->shm_label, prot,
 	    flags);
+	MAC_CHECK_PROBE4(posixshm_check_mmap, error, cred, shmfd, prot,
+	    flags);
 
 	return (error);
 }
 
+MAC_CHECK_PROBE_DEFINE2(posixshm_check_open, "struct ucred *",
+    "struct shmfd *");
+
 int
 mac_posixshm_check_open(struct ucred *cred, struct shmfd *shmfd)
 {
 	int error;
 
 	MAC_CHECK(posixshm_check_open, cred, shmfd, shmfd->shm_label);
+	MAC_CHECK_PROBE2(posixshm_check_open, error, cred, shmfd);
 
 	return (error);
 }
 
+MAC_CHECK_PROBE_DEFINE3(posixshm_check_stat, "struct ucred *",
+    "struct ucred *", "struct shmfd *");
+
 int
 mac_posixshm_check_stat(struct ucred *active_cred, struct ucred *file_cred,
     struct shmfd *shmfd)
@@ -124,10 +142,15 @@ mac_posixshm_check_stat(struct ucred *ac
 
 	MAC_CHECK(posixshm_check_stat, active_cred, file_cred, shmfd,
 	    shmfd->shm_label);
+	MAC_CHECK_PROBE3(posixshm_check_stat, error, active_cred, file_cred,
+	    shmfd);
 
 	return (error);
 }
 
+MAC_CHECK_PROBE_DEFINE3(posixshm_check_truncate, "struct ucred *",
+    "struct ucred *", "struct shmfd *");
+
 int
 mac_posixshm_check_truncate(struct ucred *active_cred, struct ucred *file_cred,
     struct shmfd *shmfd)
@@ -136,16 +159,22 @@ mac_posixshm_check_truncate(struct ucred
 
 	MAC_CHECK(posixshm_check_truncate, active_cred, file_cred, shmfd,
 	    shmfd->shm_label);
+	MAC_CHECK_PROBE3(posixshm_check_truncate, error, active_cred,
+	    file_cred, shmfd);
 
 	return (error);
 }
 
+MAC_CHECK_PROBE_DEFINE2(posixshm_check_unlink, "struct ucred *",
+    "struct shmfd *");
+
 int
 mac_posixshm_check_unlink(struct ucred *cred, struct shmfd *shmfd)
 {
 	int error;
 
 	MAC_CHECK(posixshm_check_unlink, cred, shmfd, shmfd->shm_label);
+	MAC_CHECK_PROBE2(posixshm_check_unlink, error, cred, shmfd);
 
 	return (error);
 }

Modified: head/sys/security/mac/mac_priv.c
==============================================================================
--- head/sys/security/mac/mac_priv.c	Sun Mar  8 00:11:26 2009	(r189502)
+++ head/sys/security/mac/mac_priv.c	Sun Mar  8 00:50:37 2009	(r189503)
@@ -1,10 +1,14 @@
 /*-
  * Copyright (c) 2006 nCircle Network Security, Inc.
+ * Copyright (c) 2009 Robert N. M. Watson
  * All rights reserved.
  *
  * This software was developed by Robert N. M. Watson for the TrustedBSD
  * Project under contract to nCircle Network Security, Inc.
  *
+ * This software was developed at the University of Cambridge Computer
+ * Laboratory with support from a grant from Google, Inc.
+ *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
@@ -34,10 +38,13 @@
 #include "sys/cdefs.h"
 __FBSDID("$FreeBSD$");
 
+#include "opt_kdtrace.h"
 #include "opt_mac.h"
 
 #include <sys/param.h>
+#include <sys/kernel.h>
 #include <sys/priv.h>
+#include <sys/sdt.h>
 #include <sys/module.h>
 
 #include <security/mac/mac_framework.h>
@@ -54,6 +61,8 @@ __FBSDID("$FreeBSD$");
  * composition.
  */
 
+MAC_CHECK_PROBE_DEFINE2(priv_check, "struct ucred *", "int");
+
 /*
  * Restrict access to a privilege for a credential.  Return failure if any
  * policy denies access.
@@ -64,10 +73,13 @@ mac_priv_check(struct ucred *cred, int p
 	int error;
 
 	MAC_CHECK(priv_check, cred, priv);
+	MAC_CHECK_PROBE2(priv_check, error, cred, priv);
 
 	return (error);
 }
 
+MAC_GRANT_PROBE_DEFINE2(priv_grant, "struct ucred *", "int");
+
 /*
  * Grant access to a privilege for a credential.  Return success if any
  * policy grants access.
@@ -78,6 +90,7 @@ mac_priv_grant(struct ucred *cred, int p
 	int error;
 
 	MAC_GRANT(priv_grant, cred, priv);
+	MAC_GRANT_PROBE2(priv_grant, error, cred, priv);
 
 	return (error);
 }

Modified: head/sys/security/mac/mac_process.c
==============================================================================
--- head/sys/security/mac/mac_process.c	Sun Mar  8 00:11:26 2009	(r189502)
+++ head/sys/security/mac/mac_process.c	Sun Mar  8 00:50:37 2009	(r189503)
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 1999-2002, 2008 Robert N. M. Watson
+ * Copyright (c) 1999-2002, 2008-2009 Robert N. M. Watson
  * Copyright (c) 2001 Ilmar S. Habibulin
  * Copyright (c) 2001-2003 Networks Associates Technology, Inc.
  * Copyright (c) 2005 Samy Al Bahra
@@ -18,6 +18,9 @@
  * This software was enhanced by SPARTA ISSO under SPAWAR contract
  * N66001-04-C-6019 ("SEFOS").
  *
+ * This software was developed at the University of Cambridge Computer
+ * Laboratory with support from a grant from Google, Inc.
+ *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
@@ -43,6 +46,7 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
+#include "opt_kdtrace.h"
 #include "opt_mac.h"
 
 #include <sys/param.h>
@@ -55,6 +59,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/mac.h>
 #include <sys/proc.h>
 #include <sys/sbuf.h>
+#include <sys/sdt.h>
 #include <sys/systm.h>
 #include <sys/vnode.h>
 #include <sys/mount.h>
@@ -373,6 +378,8 @@ mac_proc_vm_revoke_recurse(struct thread
 	vm_map_unlock(map);
 }
 
+MAC_CHECK_PROBE_DEFINE2(proc_check_debug, "struct ucred *", "struct proc *");
+
 int
 mac_proc_check_debug(struct ucred *cred, struct proc *p)
 {
@@ -381,10 +388,13 @@ mac_proc_check_debug(struct ucred *cred,
 	PROC_LOCK_ASSERT(p, MA_OWNED);
 
 	MAC_CHECK(proc_check_debug, cred, p);
+	MAC_CHECK_PROBE2(proc_check_debug, error, cred, p);
 
 	return (error);
 }
 
+MAC_CHECK_PROBE_DEFINE2(proc_check_sched, "struct ucred *", "struct proc *");
+
 int
 mac_proc_check_sched(struct ucred *cred, struct proc *p)
 {
@@ -393,10 +403,14 @@ mac_proc_check_sched(struct ucred *cred,
 	PROC_LOCK_ASSERT(p, MA_OWNED);
 
 	MAC_CHECK(proc_check_sched, cred, p);
+	MAC_CHECK_PROBE2(proc_check_sched, error, cred, p);
 
 	return (error);
 }
 
+MAC_CHECK_PROBE_DEFINE3(proc_check_signal, "struct ucred *", "struct proc *",
+    "int");
+
 int
 mac_proc_check_signal(struct ucred *cred, struct proc *p, int signum)
 {
@@ -405,10 +419,13 @@ mac_proc_check_signal(struct ucred *cred
 	PROC_LOCK_ASSERT(p, MA_OWNED);
 
 	MAC_CHECK(proc_check_signal, cred, p, signum);
+	MAC_CHECK_PROBE3(proc_check_signal, error, cred, p, signum);
 
 	return (error);
 }
 
+MAC_CHECK_PROBE_DEFINE2(proc_check_setuid, "struct ucred *", "uid_t");
+
 int
 mac_proc_check_setuid(struct proc *p, struct ucred *cred, uid_t uid)
 {
@@ -417,9 +434,13 @@ mac_proc_check_setuid(struct proc *p, st
 	PROC_LOCK_ASSERT(p, MA_OWNED);
 
 	MAC_CHECK(proc_check_setuid, cred, uid);
+	MAC_CHECK_PROBE2(proc_check_setuid, error, cred, uid);
+
 	return (error);
 }
 
+MAC_CHECK_PROBE_DEFINE2(proc_check_seteuid, "struct ucred *", "uid_t");
+
 int
 mac_proc_check_seteuid(struct proc *p, struct ucred *cred, uid_t euid)
 {
@@ -428,9 +449,13 @@ mac_proc_check_seteuid(struct proc *p, s
 	PROC_LOCK_ASSERT(p, MA_OWNED);
 
 	MAC_CHECK(proc_check_seteuid, cred, euid);
+	MAC_CHECK_PROBE2(proc_check_seteuid, error, cred, euid);
+
 	return (error);
 }
 
+MAC_CHECK_PROBE_DEFINE2(proc_check_setgid, "struct ucred *", "gid_t");
+
 int
 mac_proc_check_setgid(struct proc *p, struct ucred *cred, gid_t gid)
 {
@@ -439,10 +464,13 @@ mac_proc_check_setgid(struct proc *p, st
 	PROC_LOCK_ASSERT(p, MA_OWNED);
 
 	MAC_CHECK(proc_check_setgid, cred, gid);
+	MAC_CHECK_PROBE2(proc_check_setgid, error, cred, gid);
 
 	return (error);
 }
 
+MAC_CHECK_PROBE_DEFINE2(proc_check_setegid, "struct ucred *", "gid_t");
+
 int
 mac_proc_check_setegid(struct proc *p, struct ucred *cred, gid_t egid)
 {
@@ -451,10 +479,14 @@ mac_proc_check_setegid(struct proc *p, s
 	PROC_LOCK_ASSERT(p, MA_OWNED);
 

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200903080050.n280obwZ067087>