164027e4dSRobert Watson.\"- 257792dedSRobert Watson.\" Copyright (c) 1999-2002 Robert N. M. Watson 357792dedSRobert Watson.\" Copyright (c) 2002-2004 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.\" 2264027e4dSRobert Watson.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 2364027e4dSRobert Watson.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2464027e4dSRobert Watson.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2564027e4dSRobert Watson.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 2664027e4dSRobert Watson.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2764027e4dSRobert Watson.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2864027e4dSRobert Watson.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2964027e4dSRobert Watson.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 3064027e4dSRobert Watson.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3164027e4dSRobert Watson.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3264027e4dSRobert Watson.\" SUCH DAMAGE. 3364027e4dSRobert Watson.\" 3464027e4dSRobert Watson.\" $FreeBSD$ 3564027e4dSRobert Watson.\" 3664027e4dSRobert Watson.Dd February 16, 2002 3764027e4dSRobert Watson.Dt MAC 9 384ac17494SRuslan Ermilov.Os 3964027e4dSRobert Watson.Sh NAME 4064027e4dSRobert Watson.Nm mac 4164027e4dSRobert Watson.Nd TrustedBSD Mandatory Access Control framework 4264027e4dSRobert Watson.Sh SYNOPSIS 4364027e4dSRobert Watson.In sys/types.h 4464027e4dSRobert Watson.In sys/mac.h 4564027e4dSRobert Watson.Pp 4664027e4dSRobert WatsonIn the kernel configuration file: 4764027e4dSRobert Watson.Cd "options MAC" 4864027e4dSRobert Watson.Cd "options MAC_DEBUG" 4964027e4dSRobert Watson.Sh DESCRIPTION 5064027e4dSRobert Watson.Ss Introduction 514ac17494SRuslan ErmilovThe 524ac17494SRuslan Ermilov.Tn TrustedBSD 534ac17494SRuslan Ermilovmandatory access control framework permits dynamically 5464027e4dSRobert Watsonintroduced system security modules to modify system security functionality. 5564027e4dSRobert WatsonThis can be used to support a variety of new security services, including 5664027e4dSRobert Watsontraditional labeled mandatory access control models. 5764027e4dSRobert WatsonThe framework provides a series of entry points which must be called by 5864027e4dSRobert Watsoncode supporting various kernel services, especially with respects to access 5964027e4dSRobert Watsoncontrol points and object creation. 6064027e4dSRobert WatsonThe framework then calls out to security modules to offer them the 6164027e4dSRobert Watsonopportunity to modify security behavior at those MAC API entry points. 6264027e4dSRobert WatsonBoth consumers of the API (normal kernel services) and security modules 6364027e4dSRobert Watsonmust be aware of the semantics of the API calls, particularly with respect 6464027e4dSRobert Watsonto synchronization primitives (such as locking). 654ac17494SRuslan Ermilov.Ss Note on Appropriateness for Production Use 664ac17494SRuslan ErmilovThe 674ac17494SRuslan Ermilov.Tn TrustedBSD 684ac17494SRuslan ErmilovMAC Framework included in 69bf139e97SRobert Watson.Fx 5.0 70bf139e97SRobert Watsonis considered experimental, and should not be deployed in production 71bf139e97SRobert Watsonenvironments without careful consideration of the risks associated with 72bf139e97SRobert Watsonthe use of experimental operating system features. 734ac17494SRuslan Ermilov.Ss Kernel Objects Supported by the Framework 7464027e4dSRobert WatsonThe MAC framework manages labels on a variety of types of in-kernel 7564027e4dSRobert Watsonobjects, including process credentials, vnodes, devfs_dirents, mount 764ac17494SRuslan Ermilovpoints, sockets, mbufs, bpf descriptors, network interfaces, IP fragment 7764027e4dSRobert Watsonqueues, and pipes. 784ac17494SRuslan ErmilovLabel data on kernel objects, represented by 794ac17494SRuslan Ermilov.Vt "struct label" , 804ac17494SRuslan Ermilovis policy-unaware, and may be used in the manner seen fit by policy modules. 8164027e4dSRobert Watson.Ss API for Consumers 8264027e4dSRobert WatsonThe MAC API provides a large set of entry points, too broad to specifically 8364027e4dSRobert Watsondocument here. 8464027e4dSRobert WatsonIn general, these entry points represent an access control check or other 8564027e4dSRobert WatsonMAC-relevant operations, accept one or more subjects (credentials) 8664027e4dSRobert Watsonauthorizing the activity, a set of objects on which the operation 8764027e4dSRobert Watsonis to be performed, and a set of operation arguments providing information 8864027e4dSRobert Watsonabout the type of operation being requested. 8964027e4dSRobert Watson.Ss Locking for Consumers 9064027e4dSRobert WatsonConsumers of the MAC API must be aware of the locking requirements for 9164027e4dSRobert Watsoneach API entry point: generally, appropriate locks must be held over each 9264027e4dSRobert Watsonsubject or object being passed into the call, so that MAC modules may 9364027e4dSRobert Watsonmake use of various aspects of the object for access control purposes. 9464027e4dSRobert WatsonFor example, vnode locks are frequently required in order that the MAC 9564027e4dSRobert Watsonframework and modules may retrieve security labels and attributes from the 9664027e4dSRobert Watsonvnodes for the purposes of access control. 9764027e4dSRobert WatsonSimilarly, the caller must be aware of the reference counting semantics 9864027e4dSRobert Watsonof any subject or object passed into the MAC API: all calls require that 9964027e4dSRobert Watsona valid reference to the object be held for the duration of the 10064027e4dSRobert Watson(potentially lengthy) MAC API call. 10164027e4dSRobert WatsonUnder some circumstances, objects must be held in either a shared or 10264027e4dSRobert Watsonexclusive manner. 10364027e4dSRobert Watson.Ss API for Module Writers 10464027e4dSRobert WatsonEach module exports a structure describing the MAC API operations that 10564027e4dSRobert Watsonthe module chooses to implement, including initialization and destruction 10664027e4dSRobert WatsonAPI entry points, a variety of object creation and destruction calls, 10764027e4dSRobert Watsonand a large set of access control check points. 10864027e4dSRobert WatsonIn the future, additional audit entry points will also be present. 10964027e4dSRobert WatsonModule authors may choose to only implement a subset of the entry points, 1104ac17494SRuslan Ermilovsetting API function pointers in the description structure to 1114ac17494SRuslan Ermilov.Dv NULL , 11264027e4dSRobert Watsonpermitting the framework to avoid calling into the module. 11364027e4dSRobert Watson.Ss Locking for Module Writers 11464027e4dSRobert WatsonModule writers must be aware of the locking semantics of entry points 11564027e4dSRobert Watsonthat they implement: MAC API entry points will have specific locking 11664027e4dSRobert Watsonor reference counting semantics for each argument, and modules must follow 11764027e4dSRobert Watsonthe locking and reference counting protocol or risk a variety of failure 11864027e4dSRobert Watsonmodes (including race conditions, inappropriate pointer dereferences, 11964027e4dSRobert Watsonetc). 12064027e4dSRobert Watson.Pp 12164027e4dSRobert WatsonMAC module writers must also be aware that MAC API entry points will 12264027e4dSRobert Watsonfrequently be invoked from deep in a kernel stack, and as such must be 12364027e4dSRobert Watsoncareful to avoid violating more global locking requirements, such as 12464027e4dSRobert Watsonglobal lock order requirements. 12564027e4dSRobert WatsonFor example, it may be inappropriate to lock additional objects not 12664027e4dSRobert Watsonspecifically maintained and ordered by the policy module, or the 12764027e4dSRobert Watsonpolicy module might violate a global ordering requirement relating 12864027e4dSRobert Watsonto those additional objects. 12964027e4dSRobert Watson.Pp 13064027e4dSRobert WatsonFinally, MAC API module implementors must be careful to avoid 13164027e4dSRobert Watsoninappropriately calling back into the MAC framework: the framework 13264027e4dSRobert Watsonmakes use of locking to prevent inconsistencies during policy module 13364027e4dSRobert Watsonattachment and detachment. 13464027e4dSRobert WatsonMAC API modules should avoid producing scenarios in which deadlocks 13564027e4dSRobert Watsonor inconsistencies might occur. 13664027e4dSRobert Watson.Ss Adding New MAC Entry Points 13764027e4dSRobert WatsonThe MAC API is intended to be easily expandable as new services are 13864027e4dSRobert Watsonadded to the kernel. 13964027e4dSRobert WatsonIn order that policies may be guaranteed the opportunity to ubiquitously 14064027e4dSRobert Watsonprotect system subjects and objects, it is important that kernel 14164027e4dSRobert Watsondevelopers maintain awareness of when security checks or relevant 14264027e4dSRobert Watsonsubject or object operations occur in newly written or modified kernel 14364027e4dSRobert Watsoncode. 14464027e4dSRobert WatsonNew entry points must be carefully documented so as to prevent any 14564027e4dSRobert Watsonconfusion regarding lock orders and semantics. 14664027e4dSRobert WatsonIntroducing new entry points requires four distinct pieces of work: 14764027e4dSRobert Watsonintroducing new MAC API entries reflecting the operation arguments, 14864027e4dSRobert Watsonscattering these MAC API entry points throughout the new or modified 14964027e4dSRobert Watsonkernel service, extending the front-end implementation of the MAC API 15064027e4dSRobert Watsonframework, and modifying appropriate modules to take advantage of 15164027e4dSRobert Watsonthe new entry points so that they may consistently enforce their 15264027e4dSRobert Watsonpolicies. 15364027e4dSRobert Watson.Sh ENTRY POINTS 1544ac17494SRuslan ErmilovSystem service and module authors should reference the 1554ac17494SRuslan Ermilov.%T "FreeBSD Developer's Handbook" 1564ac17494SRuslan Ermilovfor information on the MAC Framework APIs. 15764027e4dSRobert Watson.Sh SEE ALSO 15864027e4dSRobert Watson.Xr acl 3 , 15964027e4dSRobert Watson.Xr mac 3 , 16064027e4dSRobert Watson.Xr posix1e 3 , 16112cfff28SChris Costello.Xr mac_biba 4 , 16212cfff28SChris Costello.Xr mac_bsdextended 4 , 16312cfff28SChris Costello.Xr mac_ifoff 4 , 16482e9524eSChristian Brueffer.Xr mac_lomac 4 , 16512cfff28SChris Costello.Xr mac_mls 4 , 16612cfff28SChris Costello.Xr mac_none 4 , 16712cfff28SChris Costello.Xr mac_partition 4 , 16812cfff28SChris Costello.Xr mac_seeotheruids 4 , 16912cfff28SChris Costello.Xr mac_test 4 , 17064027e4dSRobert Watson.Xr ucred 9 , 17164027e4dSRobert Watson.Xr vaccess 9 , 17264027e4dSRobert Watson.Xr vaccess_acl_posix1e 9 , 1734ac17494SRuslan Ermilov.Xr VFS 9 174bbc9e2b1SChris Costello.Rs 175bbc9e2b1SChris Costello.%T "The FreeBSD Developers' Handbook" 176bbc9e2b1SChris Costello.%O "http://www.FreeBSD.org/doc/en_US.ISO8859-1/books/developers-handbook/" 177bbc9e2b1SChris Costello.Re 1789cbda590SRuslan Ermilov.Sh HISTORY 1799cbda590SRuslan ErmilovThe 1809cbda590SRuslan Ermilov.Tn TrustedBSD 1819cbda590SRuslan ErmilovMAC Framework first appeared in 1829cbda590SRuslan Ermilov.Fx 5.0 . 18364027e4dSRobert Watson.Sh AUTHORS 184571dba6eSHiten PandyaThis manual page was written by 18564027e4dSRobert Watson.An Robert Watson . 18664027e4dSRobert WatsonThis software was contributed to the 18764027e4dSRobert Watson.Fx 18864027e4dSRobert WatsonProject by Network Associates Laboratories, the Security Research 1895203edcdSRuslan ErmilovDivision of Network Associates Inc.\& under DARPA/SPAWAR contract 1904ac17494SRuslan ErmilovN66001-01-C-8035 1914ac17494SRuslan Ermilov.Pq Dq CBOSS , 1924ac17494SRuslan Ermilovas part of the DARPA CHATS research program. 19364027e4dSRobert Watson.Pp 19464027e4dSRobert Watson.An -nosplit 1954ac17494SRuslan ErmilovThe 1964ac17494SRuslan Ermilov.Tn TrustedBSD 1974ac17494SRuslan ErmilovMAC Framework was designed by 19864027e4dSRobert Watson.An Robert Watson , 19964027e4dSRobert Watsonand implemented by the Network Associates Laboratories Network Security 20057bd0fc6SJens Schweikhardt(NETSEC), Secure Execution Environment (SEE), and Adaptive 20164027e4dSRobert WatsonNetwork Defense research groups. 20264027e4dSRobert WatsonNetwork Associates Laboratory staff contributing to the CBOSS Project 20364027e4dSRobert Watsoninclude (in alphabetical order): 20464027e4dSRobert Watson.An Lee Badger , 20564027e4dSRobert Watson.An Brian Feldman , 20657792dedSRobert Watson.An Hrishikesh Dandekar , 20764027e4dSRobert Watson.An Tim Fraser , 20864027e4dSRobert Watson.An Doug Kilpatrick , 20964027e4dSRobert Watson.An Suresh Krishnaswamy , 21064027e4dSRobert Watson.An Adam Migus , 21164027e4dSRobert Watson.An Wayne Morrison , 21257792dedSRobert Watson.An Andrew Reisse , 21364027e4dSRobert Watson.An Chris Vance , 21464027e4dSRobert Watsonand 21564027e4dSRobert Watson.An Robert Watson . 21664027e4dSRobert Watson.Pp 21764027e4dSRobert WatsonSub-contracted staff include: 21864027e4dSRobert Watson.An Chris Costello , 21964027e4dSRobert Watson.An Poul-Henning Kamp , 22064027e4dSRobert Watson.An Jonathan Lemon , 22164027e4dSRobert Watson.An Kirk McKusick , 22209e06539SDag-Erling Smørgrav.An Dag-Erling Sm\(/orgrav . 22364027e4dSRobert Watson.Pp 22464027e4dSRobert WatsonAdditional contributors include: 225bf7f20c2SRuslan Ermilov.An Pawel Dawidek , 22664027e4dSRobert Watson.An Chris Faulhaber , 22764027e4dSRobert Watson.An Ilmar Habibulin , 22857792dedSRobert Watson.An Mike Halderman , 22957792dedSRobert Watson.An Bosko Milekic , 23064027e4dSRobert Watson.An Thomas Moestl , 23157792dedSRobert Watson.An Andrew Reiter , 23264027e4dSRobert Watsonand 23357792dedSRobert Watson.An Tim Robbins . 234bf139e97SRobert Watson.Sh BUGS 235bf139e97SRobert WatsonSee the earlier section in this document concerning appropriateness 236bf139e97SRobert Watsonfor production use. 2374ac17494SRuslan ErmilovThe 2384ac17494SRuslan Ermilov.Tn TrustedBSD 2394ac17494SRuslan ErmilovMAC Framework is considered experimental in 240bf139e97SRobert Watson.Fx . 241bf139e97SRobert Watson.Pp 242bf139e97SRobert WatsonWhile the MAC Framework design is intended to support the containment of 2439759d0e4SChris Costellothe root user, not all attack channels are currently protected by entry 244bf139e97SRobert Watsonpoint checks. 245bf139e97SRobert WatsonAs such, MAC Framework policies should not be relied on, in isolation, 246bf139e97SRobert Watsonto protect against a malicious privileged user. 247