From nobody@FreeBSD.org  Tue Aug 11 17:51:50 2009
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 917A2106566B
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 11 Aug 2009 17:51:50 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id 8043A8FC58
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 11 Aug 2009 17:51:50 +0000 (UTC)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.3/8.14.3) with ESMTP id n7BHpoJa082936
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 11 Aug 2009 17:51:50 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id n7BHpoHI082935;
	Tue, 11 Aug 2009 17:51:50 GMT
	(envelope-from nobody)
Message-Id: <200908111751.n7BHpoHI082935@www.freebsd.org>
Date: Tue, 11 Aug 2009 17:51:50 GMT
From: Steve Polyack <spolyack@collaborativefusion.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: security.mac.bsdextended.firstmatch_enabled default is incorrect
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         137677
>Category:       kern
>Synopsis:       [mac] security.mac.bsdextended.firstmatch_enabled default is incorrect
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Aug 11 18:00:16 UTC 2009
>Closed-Date:    
>Last-Modified:  Wed Aug 12 07:34:56 UTC 2009
>Originator:     Steve Polyack
>Release:        7.2-RELEASE
>Organization:
Collaborative Fusion, Inc.
>Environment:
FreeBSD xxxxx 7.2-RELEASE-p3 FreeBSD 7.2-RELEASE-p3 #0: Tue Aug 11 10:34:08 EDT 2009     root@xxxxx:/usr/obj/usr/src/sys/GENERIC-MAC  amd64
>Description:
The manpage for the mac_bsdextended kernel module states that the default for the security.mac.bsdextended.firstmatch_enabled is 1.  This does not appear to be true, as a recently rebuilt 6.3 machine as well as a fresh 7.2-RELEASE install both have the sysctl set to 0 upon loading the module:

$ sysctl security.mac.bsdextended.firstmatch_enabled 
security.mac.bsdextended.firstmatch_enabled: 0


The source code for the module appears to initialize the sysctl with the (correct) value of 1, so I'm unsure as to where the problem actually is:
/*
 * This tunable is here for compatibility.  It will allow the user to switch
 * between the new mode (first rule matches) and the old functionality (all
 * rules match).
 */
static int ugidfw_firstmatch_enabled;
SYSCTL_INT(_security_mac_bsdextended, OID_AUTO, firstmatch_enabled,
    CTLFLAG_RW, &ugidfw_firstmatch_enabled, 1,
    "Disable/enable match first rule functionality");
>How-To-Repeat:
- Build and install a kernel with 'options MAC'.
- Reboot and kldload mac_bsdextended.
- Observe that the sysctl security.mac.bsdextended.firstmatch_enabled is set to 0 after spending a good amount of time wondering why your ugidfw rules aren't working as expected.
>Fix:


>Release-Note:
>Audit-Trail:
>Unformatted:
