xref: /freebsd/share/man/man9/mac.9 (revision c1a148873d6488f1dac1cfb207a5927cef89888e)
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.\"
36*c1a14887SCeri Davies.Dd May 20, 2021
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 Kernel Objects Supported by the Framework
6664027e4dSRobert WatsonThe MAC framework manages labels on a variety of types of in-kernel
6764027e4dSRobert Watsonobjects, including process credentials, vnodes, devfs_dirents, mount
684ac17494SRuslan Ermilovpoints, sockets, mbufs, bpf descriptors, network interfaces, IP fragment
6964027e4dSRobert Watsonqueues, and pipes.
704ac17494SRuslan ErmilovLabel data on kernel objects, represented by
714ac17494SRuslan Ermilov.Vt "struct label" ,
724ac17494SRuslan Ermilovis policy-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,
1024ac17494SRuslan Ermilovsetting API function pointers in the description structure to
1034ac17494SRuslan Ermilov.Dv NULL ,
10464027e4dSRobert Watsonpermitting the framework to avoid calling into the module.
10564027e4dSRobert Watson.Ss Locking for Module Writers
10664027e4dSRobert WatsonModule writers must be aware of the locking semantics of entry points
10764027e4dSRobert Watsonthat they implement: MAC API entry points will have specific locking
10864027e4dSRobert Watsonor reference counting semantics for each argument, and modules must follow
10964027e4dSRobert Watsonthe locking and reference counting protocol or risk a variety of failure
11064027e4dSRobert Watsonmodes (including race conditions, inappropriate pointer dereferences,
11164027e4dSRobert Watsonetc).
11264027e4dSRobert Watson.Pp
11364027e4dSRobert WatsonMAC module writers must also be aware that MAC API entry points will
11464027e4dSRobert Watsonfrequently be invoked from deep in a kernel stack, and as such must be
11564027e4dSRobert Watsoncareful to avoid violating more global locking requirements, such as
11664027e4dSRobert Watsonglobal lock order requirements.
11764027e4dSRobert WatsonFor example, it may be inappropriate to lock additional objects not
11864027e4dSRobert Watsonspecifically maintained and ordered by the policy module, or the
11964027e4dSRobert Watsonpolicy module might violate a global ordering requirement relating
12064027e4dSRobert Watsonto those additional objects.
12164027e4dSRobert Watson.Pp
12264027e4dSRobert WatsonFinally, MAC API module implementors must be careful to avoid
12364027e4dSRobert Watsoninappropriately calling back into the MAC framework: the framework
12464027e4dSRobert Watsonmakes use of locking to prevent inconsistencies during policy module
12564027e4dSRobert Watsonattachment and detachment.
12664027e4dSRobert WatsonMAC API modules should avoid producing scenarios in which deadlocks
12764027e4dSRobert Watsonor inconsistencies might occur.
12864027e4dSRobert Watson.Ss Adding New MAC Entry Points
12964027e4dSRobert WatsonThe MAC API is intended to be easily expandable as new services are
13064027e4dSRobert Watsonadded to the kernel.
13164027e4dSRobert WatsonIn order that policies may be guaranteed the opportunity to ubiquitously
13264027e4dSRobert Watsonprotect system subjects and objects, it is important that kernel
13364027e4dSRobert Watsondevelopers maintain awareness of when security checks or relevant
13464027e4dSRobert Watsonsubject or object operations occur in newly written or modified kernel
13564027e4dSRobert Watsoncode.
13664027e4dSRobert WatsonNew entry points must be carefully documented so as to prevent any
13764027e4dSRobert Watsonconfusion regarding lock orders and semantics.
13864027e4dSRobert WatsonIntroducing new entry points requires four distinct pieces of work:
13964027e4dSRobert Watsonintroducing new MAC API entries reflecting the operation arguments,
14064027e4dSRobert Watsonscattering these MAC API entry points throughout the new or modified
14164027e4dSRobert Watsonkernel service, extending the front-end implementation of the MAC API
14264027e4dSRobert Watsonframework, and modifying appropriate modules to take advantage of
14364027e4dSRobert Watsonthe new entry points so that they may consistently enforce their
14464027e4dSRobert Watsonpolicies.
14564027e4dSRobert Watson.Sh ENTRY POINTS
1464ac17494SRuslan ErmilovSystem service and module authors should reference the
147b4b4e2e0SJoel Dahl.%T "FreeBSD Architecture Handbook"
1484ac17494SRuslan Ermilovfor information on the MAC Framework APIs.
14964027e4dSRobert Watson.Sh SEE ALSO
15064027e4dSRobert Watson.Xr acl 3 ,
15164027e4dSRobert Watson.Xr mac 3 ,
15264027e4dSRobert Watson.Xr posix1e 3 ,
15312cfff28SChris Costello.Xr mac_biba 4 ,
15412cfff28SChris Costello.Xr mac_bsdextended 4 ,
15512cfff28SChris Costello.Xr mac_ifoff 4 ,
15682e9524eSChristian Brueffer.Xr mac_lomac 4 ,
15712cfff28SChris Costello.Xr mac_mls 4 ,
15812cfff28SChris Costello.Xr mac_none 4 ,
15912cfff28SChris Costello.Xr mac_partition 4 ,
16012cfff28SChris Costello.Xr mac_seeotheruids 4 ,
16112cfff28SChris Costello.Xr mac_test 4 ,
16264027e4dSRobert Watson.Xr ucred 9 ,
16364027e4dSRobert Watson.Xr vaccess 9 ,
16464027e4dSRobert Watson.Xr vaccess_acl_posix1e 9 ,
165a9f11355SRobert Watson.Xr VFS 9 ,
166a9f11355SRobert Watson.Xr VOP_SETLABEL 9 .
167bbc9e2b1SChris Costello.Rs
168ca5195cbSJoel Dahl.%T "The FreeBSD Architecture Handbook"
169*c1a14887SCeri Davies.%U "https://docs.freebsd.org/en/books/arch-handbook/"
170bbc9e2b1SChris Costello.Re
1719cbda590SRuslan Ermilov.Sh HISTORY
1729cbda590SRuslan ErmilovThe
1739cbda590SRuslan Ermilov.Tn TrustedBSD
1749cbda590SRuslan ErmilovMAC Framework first appeared in
1759cbda590SRuslan Ermilov.Fx 5.0 .
17664027e4dSRobert Watson.Sh AUTHORS
177571dba6eSHiten PandyaThis manual page was written by
17864027e4dSRobert Watson.An Robert Watson .
17964027e4dSRobert WatsonThis software was contributed to the
18064027e4dSRobert Watson.Fx
18164027e4dSRobert WatsonProject by Network Associates Laboratories, the Security Research
1825203edcdSRuslan ErmilovDivision of Network Associates Inc.\& under DARPA/SPAWAR contract
1834ac17494SRuslan ErmilovN66001-01-C-8035
1844ac17494SRuslan Ermilov.Pq Dq CBOSS ,
1854ac17494SRuslan Ermilovas part of the DARPA CHATS research program.
18664027e4dSRobert Watson.Pp
18764027e4dSRobert Watson.An -nosplit
1884ac17494SRuslan ErmilovThe
1894ac17494SRuslan Ermilov.Tn TrustedBSD
1904ac17494SRuslan ErmilovMAC Framework was designed by
19164027e4dSRobert Watson.An Robert Watson ,
19264027e4dSRobert Watsonand implemented by the Network Associates Laboratories Network Security
19357bd0fc6SJens Schweikhardt(NETSEC), Secure Execution Environment (SEE), and Adaptive
19464027e4dSRobert WatsonNetwork Defense research groups.
19564027e4dSRobert WatsonNetwork Associates Laboratory staff contributing to the CBOSS Project
19664027e4dSRobert Watsoninclude (in alphabetical order):
19764027e4dSRobert Watson.An Lee Badger ,
19864027e4dSRobert Watson.An Brian Feldman ,
19957792dedSRobert Watson.An Hrishikesh Dandekar ,
20064027e4dSRobert Watson.An Tim Fraser ,
20164027e4dSRobert Watson.An Doug Kilpatrick ,
20264027e4dSRobert Watson.An Suresh Krishnaswamy ,
20364027e4dSRobert Watson.An Adam Migus ,
20464027e4dSRobert Watson.An Wayne Morrison ,
20557792dedSRobert Watson.An Andrew Reisse ,
20664027e4dSRobert Watson.An Chris Vance ,
20764027e4dSRobert Watsonand
20864027e4dSRobert Watson.An Robert Watson .
20964027e4dSRobert Watson.Pp
21064027e4dSRobert WatsonSub-contracted staff include:
21164027e4dSRobert Watson.An Chris Costello ,
21264027e4dSRobert Watson.An Poul-Henning Kamp ,
21364027e4dSRobert Watson.An Jonathan Lemon ,
21464027e4dSRobert Watson.An Kirk McKusick ,
21509e06539SDag-Erling Smørgrav.An Dag-Erling Sm\(/orgrav .
21664027e4dSRobert Watson.Pp
21764027e4dSRobert WatsonAdditional contributors include:
218bf7f20c2SRuslan Ermilov.An Pawel Dawidek ,
21964027e4dSRobert Watson.An Chris Faulhaber ,
22064027e4dSRobert Watson.An Ilmar Habibulin ,
22157792dedSRobert Watson.An Mike Halderman ,
22257792dedSRobert Watson.An Bosko Milekic ,
22364027e4dSRobert Watson.An Thomas Moestl ,
22457792dedSRobert Watson.An Andrew Reiter ,
22564027e4dSRobert Watsonand
22657792dedSRobert Watson.An Tim Robbins .
227bf139e97SRobert Watson.Sh BUGS
228bf139e97SRobert WatsonWhile the MAC Framework design is intended to support the containment of
2299759d0e4SChris Costellothe root user, not all attack channels are currently protected by entry
230bf139e97SRobert Watsonpoint checks.
231bf139e97SRobert WatsonAs such, MAC Framework policies should not be relied on, in isolation,
232bf139e97SRobert Watsonto protect against a malicious privileged user.
233