xref: /freebsd/share/man/man9/mac.9 (revision fa9896e082a1046ff4fbc75fcba4d18d1f2efc19)
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.\"
34c1a14887SCeri Davies.Dd May 20, 2021
3564027e4dSRobert Watson.Dt MAC 9
364ac17494SRuslan Ermilov.Os
3764027e4dSRobert Watson.Sh NAME
3864027e4dSRobert Watson.Nm mac
3964027e4dSRobert Watson.Nd TrustedBSD Mandatory Access Control framework
4064027e4dSRobert Watson.Sh SYNOPSIS
4164027e4dSRobert Watson.In sys/types.h
4264027e4dSRobert Watson.In sys/mac.h
4364027e4dSRobert Watson.Pp
4464027e4dSRobert WatsonIn the kernel configuration file:
4564027e4dSRobert Watson.Cd "options MAC"
4664027e4dSRobert Watson.Cd "options MAC_DEBUG"
4764027e4dSRobert Watson.Sh DESCRIPTION
4864027e4dSRobert Watson.Ss Introduction
494ac17494SRuslan ErmilovThe
504ac17494SRuslan Ermilov.Tn TrustedBSD
514ac17494SRuslan Ermilovmandatory access control framework permits dynamically
5264027e4dSRobert Watsonintroduced system security modules to modify system security functionality.
5364027e4dSRobert WatsonThis can be used to support a variety of new security services, including
5464027e4dSRobert Watsontraditional labeled mandatory access control models.
5564027e4dSRobert WatsonThe framework provides a series of entry points which must be called by
5664027e4dSRobert Watsoncode supporting various kernel services, especially with respects to access
5764027e4dSRobert Watsoncontrol points and object creation.
5864027e4dSRobert WatsonThe framework then calls out to security modules to offer them the
5964027e4dSRobert Watsonopportunity to modify security behavior at those MAC API entry points.
6064027e4dSRobert WatsonBoth consumers of the API (normal kernel services) and security modules
6164027e4dSRobert Watsonmust be aware of the semantics of the API calls, particularly with respect
6264027e4dSRobert Watsonto synchronization primitives (such as locking).
634ac17494SRuslan Ermilov.Ss Kernel Objects Supported by the Framework
6464027e4dSRobert WatsonThe MAC framework manages labels on a variety of types of in-kernel
6564027e4dSRobert Watsonobjects, including process credentials, vnodes, devfs_dirents, mount
664ac17494SRuslan Ermilovpoints, sockets, mbufs, bpf descriptors, network interfaces, IP fragment
6764027e4dSRobert Watsonqueues, and pipes.
684ac17494SRuslan ErmilovLabel data on kernel objects, represented by
694ac17494SRuslan Ermilov.Vt "struct label" ,
704ac17494SRuslan Ermilovis policy-unaware, and may be used in the manner seen fit by policy modules.
7164027e4dSRobert Watson.Ss API for Consumers
7264027e4dSRobert WatsonThe MAC API provides a large set of entry points, too broad to specifically
7364027e4dSRobert Watsondocument here.
7464027e4dSRobert WatsonIn general, these entry points represent an access control check or other
7564027e4dSRobert WatsonMAC-relevant operations, accept one or more subjects (credentials)
7664027e4dSRobert Watsonauthorizing the activity, a set of objects on which the operation
7764027e4dSRobert Watsonis to be performed, and a set of operation arguments providing information
7864027e4dSRobert Watsonabout the type of operation being requested.
7964027e4dSRobert Watson.Ss Locking for Consumers
8064027e4dSRobert WatsonConsumers of the MAC API must be aware of the locking requirements for
8164027e4dSRobert Watsoneach API entry point: generally, appropriate locks must be held over each
8264027e4dSRobert Watsonsubject or object being passed into the call, so that MAC modules may
8364027e4dSRobert Watsonmake use of various aspects of the object for access control purposes.
8464027e4dSRobert WatsonFor example, vnode locks are frequently required in order that the MAC
8564027e4dSRobert Watsonframework and modules may retrieve security labels and attributes from the
8664027e4dSRobert Watsonvnodes for the purposes of access control.
8764027e4dSRobert WatsonSimilarly, the caller must be aware of the reference counting semantics
8864027e4dSRobert Watsonof any subject or object passed into the MAC API: all calls require that
8964027e4dSRobert Watsona valid reference to the object be held for the duration of the
9064027e4dSRobert Watson(potentially lengthy) MAC API call.
9164027e4dSRobert WatsonUnder some circumstances, objects must be held in either a shared or
9264027e4dSRobert Watsonexclusive manner.
9364027e4dSRobert Watson.Ss API for Module Writers
9464027e4dSRobert WatsonEach module exports a structure describing the MAC API operations that
9564027e4dSRobert Watsonthe module chooses to implement, including initialization and destruction
9664027e4dSRobert WatsonAPI entry points, a variety of object creation and destruction calls,
9764027e4dSRobert Watsonand a large set of access control check points.
9864027e4dSRobert WatsonIn the future, additional audit entry points will also be present.
9964027e4dSRobert WatsonModule authors may choose to only implement a subset of the entry points,
1004ac17494SRuslan Ermilovsetting API function pointers in the description structure to
1014ac17494SRuslan Ermilov.Dv NULL ,
10264027e4dSRobert Watsonpermitting the framework to avoid calling into the module.
10364027e4dSRobert Watson.Ss Locking for Module Writers
10464027e4dSRobert WatsonModule writers must be aware of the locking semantics of entry points
10564027e4dSRobert Watsonthat they implement: MAC API entry points will have specific locking
10664027e4dSRobert Watsonor reference counting semantics for each argument, and modules must follow
10764027e4dSRobert Watsonthe locking and reference counting protocol or risk a variety of failure
10864027e4dSRobert Watsonmodes (including race conditions, inappropriate pointer dereferences,
10964027e4dSRobert Watsonetc).
11064027e4dSRobert Watson.Pp
11164027e4dSRobert WatsonMAC module writers must also be aware that MAC API entry points will
11264027e4dSRobert Watsonfrequently be invoked from deep in a kernel stack, and as such must be
11364027e4dSRobert Watsoncareful to avoid violating more global locking requirements, such as
11464027e4dSRobert Watsonglobal lock order requirements.
11564027e4dSRobert WatsonFor example, it may be inappropriate to lock additional objects not
11664027e4dSRobert Watsonspecifically maintained and ordered by the policy module, or the
11764027e4dSRobert Watsonpolicy module might violate a global ordering requirement relating
11864027e4dSRobert Watsonto those additional objects.
11964027e4dSRobert Watson.Pp
12064027e4dSRobert WatsonFinally, MAC API module implementors must be careful to avoid
12164027e4dSRobert Watsoninappropriately calling back into the MAC framework: the framework
12264027e4dSRobert Watsonmakes use of locking to prevent inconsistencies during policy module
12364027e4dSRobert Watsonattachment and detachment.
12464027e4dSRobert WatsonMAC API modules should avoid producing scenarios in which deadlocks
12564027e4dSRobert Watsonor inconsistencies might occur.
12664027e4dSRobert Watson.Ss Adding New MAC Entry Points
12764027e4dSRobert WatsonThe MAC API is intended to be easily expandable as new services are
12864027e4dSRobert Watsonadded to the kernel.
12964027e4dSRobert WatsonIn order that policies may be guaranteed the opportunity to ubiquitously
13064027e4dSRobert Watsonprotect system subjects and objects, it is important that kernel
13164027e4dSRobert Watsondevelopers maintain awareness of when security checks or relevant
13264027e4dSRobert Watsonsubject or object operations occur in newly written or modified kernel
13364027e4dSRobert Watsoncode.
13464027e4dSRobert WatsonNew entry points must be carefully documented so as to prevent any
13564027e4dSRobert Watsonconfusion regarding lock orders and semantics.
13664027e4dSRobert WatsonIntroducing new entry points requires four distinct pieces of work:
13764027e4dSRobert Watsonintroducing new MAC API entries reflecting the operation arguments,
13864027e4dSRobert Watsonscattering these MAC API entry points throughout the new or modified
13964027e4dSRobert Watsonkernel service, extending the front-end implementation of the MAC API
14064027e4dSRobert Watsonframework, and modifying appropriate modules to take advantage of
14164027e4dSRobert Watsonthe new entry points so that they may consistently enforce their
14264027e4dSRobert Watsonpolicies.
14364027e4dSRobert Watson.Sh ENTRY POINTS
1444ac17494SRuslan ErmilovSystem service and module authors should reference the
145b4b4e2e0SJoel Dahl.%T "FreeBSD Architecture Handbook"
1464ac17494SRuslan Ermilovfor information on the MAC Framework APIs.
14764027e4dSRobert Watson.Sh SEE ALSO
14864027e4dSRobert Watson.Xr acl 3 ,
14964027e4dSRobert Watson.Xr mac 3 ,
15064027e4dSRobert Watson.Xr posix1e 3 ,
151*0449bc24SMitchell Horne.Xr mac 4 ,
15264027e4dSRobert Watson.Xr ucred 9 ,
15364027e4dSRobert Watson.Xr vaccess 9 ,
15464027e4dSRobert Watson.Xr vaccess_acl_posix1e 9 ,
155a9f11355SRobert Watson.Xr VFS 9 ,
15632068667SChristian Brueffer.Xr VOP_SETLABEL 9
157bbc9e2b1SChris Costello.Rs
158ca5195cbSJoel Dahl.%T "The FreeBSD Architecture Handbook"
159c1a14887SCeri Davies.%U "https://docs.freebsd.org/en/books/arch-handbook/"
160bbc9e2b1SChris Costello.Re
1619cbda590SRuslan Ermilov.Sh HISTORY
1629cbda590SRuslan ErmilovThe
1639cbda590SRuslan Ermilov.Tn TrustedBSD
1649cbda590SRuslan ErmilovMAC Framework first appeared in
1659cbda590SRuslan Ermilov.Fx 5.0 .
16664027e4dSRobert Watson.Sh AUTHORS
167571dba6eSHiten PandyaThis manual page was written by
16864027e4dSRobert Watson.An Robert Watson .
16964027e4dSRobert WatsonThis software was contributed to the
17064027e4dSRobert Watson.Fx
17164027e4dSRobert WatsonProject by Network Associates Laboratories, the Security Research
1725203edcdSRuslan ErmilovDivision of Network Associates Inc.\& under DARPA/SPAWAR contract
1734ac17494SRuslan ErmilovN66001-01-C-8035
1744ac17494SRuslan Ermilov.Pq Dq CBOSS ,
1754ac17494SRuslan Ermilovas part of the DARPA CHATS research program.
17664027e4dSRobert Watson.Pp
17764027e4dSRobert Watson.An -nosplit
1784ac17494SRuslan ErmilovThe
1794ac17494SRuslan Ermilov.Tn TrustedBSD
1804ac17494SRuslan ErmilovMAC Framework was designed by
18164027e4dSRobert Watson.An Robert Watson ,
18264027e4dSRobert Watsonand implemented by the Network Associates Laboratories Network Security
18357bd0fc6SJens Schweikhardt(NETSEC), Secure Execution Environment (SEE), and Adaptive
18464027e4dSRobert WatsonNetwork Defense research groups.
18564027e4dSRobert WatsonNetwork Associates Laboratory staff contributing to the CBOSS Project
18664027e4dSRobert Watsoninclude (in alphabetical order):
18764027e4dSRobert Watson.An Lee Badger ,
18864027e4dSRobert Watson.An Brian Feldman ,
18957792dedSRobert Watson.An Hrishikesh Dandekar ,
19064027e4dSRobert Watson.An Tim Fraser ,
19164027e4dSRobert Watson.An Doug Kilpatrick ,
19264027e4dSRobert Watson.An Suresh Krishnaswamy ,
19364027e4dSRobert Watson.An Adam Migus ,
19464027e4dSRobert Watson.An Wayne Morrison ,
19557792dedSRobert Watson.An Andrew Reisse ,
19664027e4dSRobert Watson.An Chris Vance ,
19764027e4dSRobert Watsonand
19864027e4dSRobert Watson.An Robert Watson .
19964027e4dSRobert Watson.Pp
20064027e4dSRobert WatsonSub-contracted staff include:
20164027e4dSRobert Watson.An Chris Costello ,
20264027e4dSRobert Watson.An Poul-Henning Kamp ,
20364027e4dSRobert Watson.An Jonathan Lemon ,
20464027e4dSRobert Watson.An Kirk McKusick ,
20509e06539SDag-Erling Smørgrav.An Dag-Erling Sm\(/orgrav .
20664027e4dSRobert Watson.Pp
20764027e4dSRobert WatsonAdditional contributors include:
208bf7f20c2SRuslan Ermilov.An Pawel Dawidek ,
20964027e4dSRobert Watson.An Chris Faulhaber ,
21064027e4dSRobert Watson.An Ilmar Habibulin ,
21157792dedSRobert Watson.An Mike Halderman ,
21257792dedSRobert Watson.An Bosko Milekic ,
21364027e4dSRobert Watson.An Thomas Moestl ,
21457792dedSRobert Watson.An Andrew Reiter ,
21564027e4dSRobert Watsonand
21657792dedSRobert Watson.An Tim Robbins .
217bf139e97SRobert Watson.Sh BUGS
218bf139e97SRobert WatsonWhile the MAC Framework design is intended to support the containment of
2199759d0e4SChris Costellothe root user, not all attack channels are currently protected by entry
220bf139e97SRobert Watsonpoint checks.
221bf139e97SRobert WatsonAs such, MAC Framework policies should not be relied on, in isolation,
222bf139e97SRobert Watsonto protect against a malicious privileged user.
223