164027e4dSRobert Watson.\"- 264027e4dSRobert Watson.\" Copyright (c) 1999, 2000, 2001, 2002 Robert N. M. Watson 364027e4dSRobert Watson.\" Copyright (c) 2002 Networks Associates Technology, Inc. 464027e4dSRobert Watson.\" All rights reserved. 564027e4dSRobert Watson.\" 664027e4dSRobert Watson.\" This software was developed by Robert Watson for the TrustedBSD Project. 764027e4dSRobert Watson.\" 864027e4dSRobert Watson.\" This software was developed for the FreeBSD Project in part by Network 964027e4dSRobert Watson.\" Associates Laboratories, the Security Research Division of Network 1064027e4dSRobert Watson.\" Associates, Inc. under DARPA/SPAWAR contract N66001-01-C-8035 1164027e4dSRobert Watson.\" ("CBOSS"), as part of the DARPA CHATS research program. 1264027e4dSRobert Watson.\" 1364027e4dSRobert Watson.\" Redistribution and use in source and binary forms, with or without 1464027e4dSRobert Watson.\" modification, are permitted provided that the following conditions 1564027e4dSRobert Watson.\" are met: 1664027e4dSRobert Watson.\" 1. Redistributions of source code must retain the above copyright 1764027e4dSRobert Watson.\" notice, this list of conditions and the following disclaimer. 1864027e4dSRobert Watson.\" 2. Redistributions in binary form must reproduce the above copyright 1964027e4dSRobert Watson.\" notice, this list of conditions and the following disclaimer in the 2064027e4dSRobert Watson.\" documentation and/or other materials provided with the distribution. 2164027e4dSRobert Watson.\" 3. The names of the authors may not be used to endorse or promote 2264027e4dSRobert Watson.\" products derived from this software without specific prior written 2364027e4dSRobert Watson.\" permission. 2464027e4dSRobert Watson.\" 2564027e4dSRobert Watson.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 2664027e4dSRobert Watson.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2764027e4dSRobert Watson.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2864027e4dSRobert Watson.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 2964027e4dSRobert Watson.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 3064027e4dSRobert Watson.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 3164027e4dSRobert Watson.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 3264027e4dSRobert Watson.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 3364027e4dSRobert Watson.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3464027e4dSRobert Watson.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3564027e4dSRobert Watson.\" SUCH DAMAGE. 3664027e4dSRobert Watson.\" 3764027e4dSRobert Watson.\" $FreeBSD$ 3864027e4dSRobert Watson.\" 3964027e4dSRobert Watson.Dd February 16, 2002 4064027e4dSRobert Watson.Os 4164027e4dSRobert Watson.Dt MAC 9 4264027e4dSRobert Watson.Sh NAME 4364027e4dSRobert Watson.Nm mac 4464027e4dSRobert Watson.Nd TrustedBSD Mandatory Access Control framework 4564027e4dSRobert Watson.Sh SYNOPSIS 4664027e4dSRobert Watson.In sys/types.h 4764027e4dSRobert Watson.In sys/mac.h 4864027e4dSRobert Watson.Pp 4964027e4dSRobert WatsonIn the kernel configuration file: 5064027e4dSRobert Watson.Cd "options MAC" 5164027e4dSRobert Watson.Cd "options MAC_DEBUG" 5264027e4dSRobert Watson.Sh DESCRIPTION 5364027e4dSRobert Watson.Ss Introduction 5464027e4dSRobert WatsonThe TrustedBSD mandatory access control framework permits dynamically 5564027e4dSRobert Watsonintroduced system security modules to modify system security functionality. 5664027e4dSRobert WatsonThis can be used to support a variety of new security services, including 5764027e4dSRobert Watsontraditional labeled mandatory access control models. 5864027e4dSRobert WatsonThe framework provides a series of entry points which must be called by 5964027e4dSRobert Watsoncode supporting various kernel services, especially with respects to access 6064027e4dSRobert Watsoncontrol points and object creation. 6164027e4dSRobert WatsonThe framework then calls out to security modules to offer them the 6264027e4dSRobert Watsonopportunity to modify security behavior at those MAC API entry points. 6364027e4dSRobert WatsonBoth consumers of the API (normal kernel services) and security modules 6464027e4dSRobert Watsonmust be aware of the semantics of the API calls, particularly with respect 6564027e4dSRobert Watsonto synchronization primitives (such as locking). 6664027e4dSRobert Watson.Ss Kernel objects supported by the framework 6764027e4dSRobert WatsonThe MAC framework manages labels on a variety of types of in-kernel 6864027e4dSRobert Watsonobjects, including process credentials, vnodes, devfs_dirents, mount 6964027e4dSRobert Watsonpoints, sockets, mbufs, bpf descriptors, network interfaces, ip fragment 7064027e4dSRobert Watsonqueues, and pipes. 7164027e4dSRobert WatsonLabel data on kernel objects, represented by struct label, is 7264027e4dSRobert Watsonpolicy-unaware, and may be used in the manner seen fit by policy modules. 7364027e4dSRobert Watson.Ss API for Consumers 7464027e4dSRobert WatsonThe MAC API provides a large set of entry points, too broad to specifically 7564027e4dSRobert Watsondocument here. 7664027e4dSRobert WatsonIn general, these entry points represent an access control check or other 7764027e4dSRobert WatsonMAC-relevant operations, accept one or more subjects (credentials) 7864027e4dSRobert Watsonauthorizing the activity, a set of objects on which the operation 7964027e4dSRobert Watsonis to be performed, and a set of operation arguments providing information 8064027e4dSRobert Watsonabout the type of operation being requested. 8164027e4dSRobert Watson.Ss Locking for Consumers 8264027e4dSRobert WatsonConsumers of the MAC API must be aware of the locking requirements for 8364027e4dSRobert Watsoneach API entry point: generally, appropriate locks must be held over each 8464027e4dSRobert Watsonsubject or object being passed into the call, so that MAC modules may 8564027e4dSRobert Watsonmake use of various aspects of the object for access control purposes. 8664027e4dSRobert WatsonFor example, vnode locks are frequently required in order that the MAC 8764027e4dSRobert Watsonframework and modules may retrieve security labels and attributes from the 8864027e4dSRobert Watsonvnodes for the purposes of access control. 8964027e4dSRobert WatsonSimilarly, the caller must be aware of the reference counting semantics 9064027e4dSRobert Watsonof any subject or object passed into the MAC API: all calls require that 9164027e4dSRobert Watsona valid reference to the object be held for the duration of the 9264027e4dSRobert Watson(potentially lengthy) MAC API call. 9364027e4dSRobert WatsonUnder some circumstances, objects must be held in either a shared or 9464027e4dSRobert Watsonexclusive manner. 9564027e4dSRobert Watson.Ss API for Module Writers 9664027e4dSRobert WatsonEach module exports a structure describing the MAC API operations that 9764027e4dSRobert Watsonthe module chooses to implement, including initialization and destruction 9864027e4dSRobert WatsonAPI entry points, a variety of object creation and destruction calls, 9964027e4dSRobert Watsonand a large set of access control check points. 10064027e4dSRobert WatsonIn the future, additional audit entry points will also be present. 10164027e4dSRobert WatsonModule authors may choose to only implement a subset of the entry points, 10264027e4dSRobert Watsonsetting API function pointers in the description structure to NULL, 10364027e4dSRobert Watsonpermitting the framework to avoid calling into the module. 10464027e4dSRobert Watson.Ss Locking for Module Writers 10564027e4dSRobert WatsonModule writers must be aware of the locking semantics of entry points 10664027e4dSRobert Watsonthat they implement: MAC API entry points will have specific locking 10764027e4dSRobert Watsonor reference counting semantics for each argument, and modules must follow 10864027e4dSRobert Watsonthe locking and reference counting protocol or risk a variety of failure 10964027e4dSRobert Watsonmodes (including race conditions, inappropriate pointer dereferences, 11064027e4dSRobert Watsonetc). 11164027e4dSRobert Watson.Pp 11264027e4dSRobert WatsonMAC module writers must also be aware that MAC API entry points will 11364027e4dSRobert Watsonfrequently be invoked from deep in a kernel stack, and as such must be 11464027e4dSRobert Watsoncareful to avoid violating more global locking requirements, such as 11564027e4dSRobert Watsonglobal lock order requirements. 11664027e4dSRobert WatsonFor example, it may be inappropriate to lock additional objects not 11764027e4dSRobert Watsonspecifically maintained and ordered by the policy module, or the 11864027e4dSRobert Watsonpolicy module might violate a global ordering requirement relating 11964027e4dSRobert Watsonto those additional objects. 12064027e4dSRobert Watson.Pp 12164027e4dSRobert WatsonFinally, MAC API module implementors must be careful to avoid 12264027e4dSRobert Watsoninappropriately calling back into the MAC framework: the framework 12364027e4dSRobert Watsonmakes use of locking to prevent inconsistencies during policy module 12464027e4dSRobert Watsonattachment and detachment. 12564027e4dSRobert WatsonMAC API modules should avoid producing scenarios in which deadlocks 12664027e4dSRobert Watsonor inconsistencies might occur. 12764027e4dSRobert Watson.Ss Adding New MAC Entry Points 12864027e4dSRobert WatsonThe MAC API is intended to be easily expandable as new services are 12964027e4dSRobert Watsonadded to the kernel. 13064027e4dSRobert WatsonIn order that policies may be guaranteed the opportunity to ubiquitously 13164027e4dSRobert Watsonprotect system subjects and objects, it is important that kernel 13264027e4dSRobert Watsondevelopers maintain awareness of when security checks or relevant 13364027e4dSRobert Watsonsubject or object operations occur in newly written or modified kernel 13464027e4dSRobert Watsoncode. 13564027e4dSRobert WatsonNew entry points must be carefully documented so as to prevent any 13664027e4dSRobert Watsonconfusion regarding lock orders and semantics. 13764027e4dSRobert WatsonIntroducing new entry points requires four distinct pieces of work: 13864027e4dSRobert Watsonintroducing new MAC API entries reflecting the operation arguments, 13964027e4dSRobert Watsonscattering these MAC API entry points throughout the new or modified 14064027e4dSRobert Watsonkernel service, extending the front-end implementation of the MAC API 14164027e4dSRobert Watsonframework, and modifying appropriate modules to take advantage of 14264027e4dSRobert Watsonthe new entry points so that they may consistently enforce their 14364027e4dSRobert Watsonpolicies. 14464027e4dSRobert Watson.Sh ENTRY POINTS 14564027e4dSRobert WatsonSystem service and module authors should reference the FreeBSD 14664027e4dSRobert WatsonDeveloper's Handbook for information on the MAC Framework APIs. 14764027e4dSRobert Watson.Pp 14864027e4dSRobert Watson.Sh SEE ALSO 14964027e4dSRobert Watson.Xr acl 3 , 15064027e4dSRobert Watson.Xr cap 3 , 15164027e4dSRobert Watson.Xr mac 3 , 15264027e4dSRobert Watson.Xr lomac 4 , 15364027e4dSRobert Watson.Xr posix1e 3 , 15464027e4dSRobert Watson.Xr ucred 9 , 15564027e4dSRobert Watson.Xr vaccess 9 , 15664027e4dSRobert Watson.Xr vaccess_acl_posix1e 9 , 15764027e4dSRobert Watson.Xr VFS 9 , 15864027e4dSRobert Watson.Sh AUTHORS 15964027e4dSRobert WatsonThis man page was written by 16064027e4dSRobert Watson.An Robert Watson . 16164027e4dSRobert WatsonThis software was contributed to the 16264027e4dSRobert Watson.Fx 16364027e4dSRobert WatsonProject by Network Associates Laboratories, the Security Research 16464027e4dSRobert WatsonDivision of Network Associates Inc. under DARPA/SPAWAR contract 16564027e4dSRobert WatsonN66001-01-C-8035 ("CBOSS"), as part of the DARPA CHATS research program. 16664027e4dSRobert Watson.Pp 16764027e4dSRobert Watson.An -nosplit 16864027e4dSRobert WatsonThe TrustedBSD MAC Framework was designed by 16964027e4dSRobert Watson.An Robert Watson , 17064027e4dSRobert Watsonand implemented by the Network Associates Laboratories Network Security 17164027e4dSRobert Watson(NETSEC), Secure Execution Environement (SEE), and Adaptive 17264027e4dSRobert WatsonNetwork Defense research groups. 17364027e4dSRobert WatsonNetwork Associates Laboratory staff contributing to the CBOSS Project 17464027e4dSRobert Watsoninclude (in alphabetical order): 17564027e4dSRobert Watson.An Lee Badger , 17664027e4dSRobert Watson.An Brian Feldman , 17764027e4dSRobert Watson.An Tim Fraser , 17864027e4dSRobert Watson.An Doug Kilpatrick , 17964027e4dSRobert Watson.An Suresh Krishnaswamy , 18064027e4dSRobert Watson.An Adam Migus , 18164027e4dSRobert Watson.An Wayne Morrison , 18264027e4dSRobert Watson.An Chris Vance , 18364027e4dSRobert Watsonand 18464027e4dSRobert Watson.An Robert Watson . 18564027e4dSRobert Watson.Pp 18664027e4dSRobert WatsonSub-contracted staff include: 18764027e4dSRobert Watson.An Chris Costello , 18864027e4dSRobert Watson.An Poul-Henning Kamp , 18964027e4dSRobert Watson.An Jonathan Lemon , 19064027e4dSRobert Watson.An Kirk McKusick , 19164027e4dSRobert Watson.An Dag-Erling Smorgrav . 19264027e4dSRobert Watson.Pp 19364027e4dSRobert WatsonAdditional contributors include: 19464027e4dSRobert Watson.An Chris Faulhaber , 19564027e4dSRobert Watson.An Ilmar Habibulin , 19664027e4dSRobert Watson.An Thomas Moestl , 19764027e4dSRobert Watsonand 19864027e4dSRobert Watson.An Andrew Reiter . 19964027e4dSRobert Watson.An -split 200