PERFORCE change 86185 for review

Todd Miller millert at FreeBSD.org
Tue Nov 1 07:43:25 PST 2005


http://perforce.freebsd.org/chv.cgi?CH=86185

Change 86185 by millert at millert_ibook on 2005/11/01 15:42:33

	Enable locking inside flask using mutexes.
	The selinux code uses spinlock but SEBSD uses mutexes.
	SEDarwin can use either but we'll use mutexes for now.

Affected files ...

.. //depot/projects/trustedbsd/sedarwin7/src/sedarwin/sedarwin/avc/avc.c#5 edit
.. //depot/projects/trustedbsd/sedarwin7/src/sedarwin/sedarwin/linux-compat.h#8 edit

Differences ...

==== //depot/projects/trustedbsd/sedarwin7/src/sedarwin/sedarwin/avc/avc.c#5 (text+ko) ====

@@ -30,6 +30,10 @@
 #include <sedarwin/linux-compat.h>
 #include <sedarwin/avc/avc.h>
 #include <sedarwin/avc/avc_ss.h>
+#include <sedarwin/avc/avc_ss.h>
+#ifdef __APPLE__
+#include <kern/lock.h>
+#endif
 
 int selinux_enforcing = 0;
 
@@ -68,7 +72,10 @@
 	struct avc_callback_node *next;
 };
 
-#ifndef __APPLE__
+#ifdef __APPLE__
+static mutex_t *avc_lock;
+static mutex_t *avc_log_lock;
+#else
 static struct mtx avc_lock;
 static struct mtx avc_log_lock;
 #endif
@@ -219,8 +226,13 @@
 	if (!avc_audit_buffer)
 		panic("AVC:  unable to allocate audit buffer\n");
 
+#ifdef __APPLE__
+	avc_lock = mutex_alloc(ETAP_NO_TRACE);
+	avc_log_lock = mutex_alloc(ETAP_NO_TRACE);
+#else
 	mtx_init(&avc_lock, "SEBSD AVC", NULL, MTX_DEF);
 	mtx_init(&avc_log_lock, "SEBSD message lock", NULL, MTX_DEF);
+#endif
 
 	size_t  evsize;
 	char   *ev;

==== //depot/projects/trustedbsd/sedarwin7/src/sedarwin/sedarwin/linux-compat.h#8 (text+ko) ====

@@ -140,21 +140,21 @@
 #define GFP_KERNEL  M_WAITOK
 
 #ifdef __APPLE__
-/* TBD: Skip this for now: */
-#define mtx_init(a,b,c,d)
-
 /* TBD: no boot-time tunable support yet */
 #define TUNABLE_INT_FETCH(str,var)
 
-/* TBD: scary, but skip locking for now */
-#define mtx_lock(m)
-#define mtx_unlock(m)
-#endif
+/* spinlock */
+#define spinlock_t mutex_t *
+#define spin_lock_irqsave(m,flags)	mutex_lock(*(m))
+#define spin_unlock_irqrestore(m,flags)	mutex_unlock(*(m))
+
+#else /* ! __APPLE__ */
 
 /* spinlock */
 #define spinlock_t struct mtx
 #define spin_lock_irqsave(m,flags) mtx_lock(m)
 #define spin_unlock_irqrestore(m,flags) mtx_unlock(m)
+#endif /* !__APPLE__ */
 
 #endif /* _KERNEL */
 


More information about the p4-projects mailing list