From owner-p4-projects@FreeBSD.ORG Tue Nov 1 15:43:24 2005 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 3431C16A423; Tue, 1 Nov 2005 15:43:24 +0000 (GMT) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D416F16A41F for ; Tue, 1 Nov 2005 15:43:23 +0000 (GMT) (envelope-from millert@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8723943D46 for ; Tue, 1 Nov 2005 15:43:23 +0000 (GMT) (envelope-from millert@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id jA1FhN6D064502 for ; Tue, 1 Nov 2005 15:43:23 GMT (envelope-from millert@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id jA1FhNkl064499 for perforce@freebsd.org; Tue, 1 Nov 2005 15:43:23 GMT (envelope-from millert@freebsd.org) Date: Tue, 1 Nov 2005 15:43:23 GMT Message-Id: <200511011543.jA1FhNkl064499@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to millert@freebsd.org using -f From: Todd Miller To: Perforce Change Reviews Cc: Subject: PERFORCE change 86185 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Nov 2005 15:43:25 -0000 http://perforce.freebsd.org/chv.cgi?CH=86185 Change 86185 by millert@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 #include #include +#include +#ifdef __APPLE__ +#include +#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 */