xref: /freebsd/share/man/man9/mac.9 (revision bf139e9706ee36667c08a6264209a628f019321b)
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.\"
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.Os
3864027e4dSRobert Watson.Dt MAC 9
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
5164027e4dSRobert WatsonThe TrustedBSD mandatory 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).
63bf139e97SRobert Watson.Ss Note on appropriateness for production use
64bf139e97SRobert WatsonThe TrustedBSD MAC Framework included in
65bf139e97SRobert Watson.Fx 5.0
66bf139e97SRobert Watsonis considered experimental, and should not be deployed in production
67bf139e97SRobert Watsonenvironments without careful consideration of the risks associated with
68bf139e97SRobert Watsonthe use of experimental operating system features.
6964027e4dSRobert Watson.Ss Kernel objects supported by the framework
7064027e4dSRobert WatsonThe MAC framework manages labels on a variety of types of in-kernel
7164027e4dSRobert Watsonobjects, including process credentials, vnodes, devfs_dirents, mount
7264027e4dSRobert Watsonpoints, sockets, mbufs, bpf descriptors, network interfaces, ip fragment
7364027e4dSRobert Watsonqueues, and pipes.
7464027e4dSRobert WatsonLabel data on kernel objects, represented by struct label, is
7564027e4dSRobert Watsonpolicy-unaware, and may be used in the manner seen fit by policy modules.
7664027e4dSRobert Watson.Ss API for Consumers
7764027e4dSRobert WatsonThe MAC API provides a large set of entry points, too broad to specifically
7864027e4dSRobert Watsondocument here.
7964027e4dSRobert WatsonIn general, these entry points represent an access control check or other
8064027e4dSRobert WatsonMAC-relevant operations, accept one or more subjects (credentials)
8164027e4dSRobert Watsonauthorizing the activity, a set of objects on which the operation
8264027e4dSRobert Watsonis to be performed, and a set of operation arguments providing information
8364027e4dSRobert Watsonabout the type of operation being requested.
8464027e4dSRobert Watson.Ss Locking for Consumers
8564027e4dSRobert WatsonConsumers of the MAC API must be aware of the locking requirements for
8664027e4dSRobert Watsoneach API entry point: generally, appropriate locks must be held over each
8764027e4dSRobert Watsonsubject or object being passed into the call, so that MAC modules may
8864027e4dSRobert Watsonmake use of various aspects of the object for access control purposes.
8964027e4dSRobert WatsonFor example, vnode locks are frequently required in order that the MAC
9064027e4dSRobert Watsonframework and modules may retrieve security labels and attributes from the
9164027e4dSRobert Watsonvnodes for the purposes of access control.
9264027e4dSRobert WatsonSimilarly, the caller must be aware of the reference counting semantics
9364027e4dSRobert Watsonof any subject or object passed into the MAC API: all calls require that
9464027e4dSRobert Watsona valid reference to the object be held for the duration of the
9564027e4dSRobert Watson(potentially lengthy) MAC API call.
9664027e4dSRobert WatsonUnder some circumstances, objects must be held in either a shared or
9764027e4dSRobert Watsonexclusive manner.
9864027e4dSRobert Watson.Ss API for Module Writers
9964027e4dSRobert WatsonEach module exports a structure describing the MAC API operations that
10064027e4dSRobert Watsonthe module chooses to implement, including initialization and destruction
10164027e4dSRobert WatsonAPI entry points, a variety of object creation and destruction calls,
10264027e4dSRobert Watsonand a large set of access control check points.
10364027e4dSRobert WatsonIn the future, additional audit entry points will also be present.
10464027e4dSRobert WatsonModule authors may choose to only implement a subset of the entry points,
10564027e4dSRobert Watsonsetting API function pointers in the description structure to NULL,
10664027e4dSRobert Watsonpermitting the framework to avoid calling into the module.
10764027e4dSRobert Watson.Ss Locking for Module Writers
10864027e4dSRobert WatsonModule writers must be aware of the locking semantics of entry points
10964027e4dSRobert Watsonthat they implement: MAC API entry points will have specific locking
11064027e4dSRobert Watsonor reference counting semantics for each argument, and modules must follow
11164027e4dSRobert Watsonthe locking and reference counting protocol or risk a variety of failure
11264027e4dSRobert Watsonmodes (including race conditions, inappropriate pointer dereferences,
11364027e4dSRobert Watsonetc).
11464027e4dSRobert Watson.Pp
11564027e4dSRobert WatsonMAC module writers must also be aware that MAC API entry points will
11664027e4dSRobert Watsonfrequently be invoked from deep in a kernel stack, and as such must be
11764027e4dSRobert Watsoncareful to avoid violating more global locking requirements, such as
11864027e4dSRobert Watsonglobal lock order requirements.
11964027e4dSRobert WatsonFor example, it may be inappropriate to lock additional objects not
12064027e4dSRobert Watsonspecifically maintained and ordered by the policy module, or the
12164027e4dSRobert Watsonpolicy module might violate a global ordering requirement relating
12264027e4dSRobert Watsonto those additional objects.
12364027e4dSRobert Watson.Pp
12464027e4dSRobert WatsonFinally, MAC API module implementors must be careful to avoid
12564027e4dSRobert Watsoninappropriately calling back into the MAC framework: the framework
12664027e4dSRobert Watsonmakes use of locking to prevent inconsistencies during policy module
12764027e4dSRobert Watsonattachment and detachment.
12864027e4dSRobert WatsonMAC API modules should avoid producing scenarios in which deadlocks
12964027e4dSRobert Watsonor inconsistencies might occur.
13064027e4dSRobert Watson.Ss Adding New MAC Entry Points
13164027e4dSRobert WatsonThe MAC API is intended to be easily expandable as new services are
13264027e4dSRobert Watsonadded to the kernel.
13364027e4dSRobert WatsonIn order that policies may be guaranteed the opportunity to ubiquitously
13464027e4dSRobert Watsonprotect system subjects and objects, it is important that kernel
13564027e4dSRobert Watsondevelopers maintain awareness of when security checks or relevant
13664027e4dSRobert Watsonsubject or object operations occur in newly written or modified kernel
13764027e4dSRobert Watsoncode.
13864027e4dSRobert WatsonNew entry points must be carefully documented so as to prevent any
13964027e4dSRobert Watsonconfusion regarding lock orders and semantics.
14064027e4dSRobert WatsonIntroducing new entry points requires four distinct pieces of work:
14164027e4dSRobert Watsonintroducing new MAC API entries reflecting the operation arguments,
14264027e4dSRobert Watsonscattering these MAC API entry points throughout the new or modified
14364027e4dSRobert Watsonkernel service, extending the front-end implementation of the MAC API
14464027e4dSRobert Watsonframework, and modifying appropriate modules to take advantage of
14564027e4dSRobert Watsonthe new entry points so that they may consistently enforce their
14664027e4dSRobert Watsonpolicies.
14764027e4dSRobert Watson.Sh ENTRY POINTS
14864027e4dSRobert WatsonSystem service and module authors should reference the FreeBSD
14964027e4dSRobert WatsonDeveloper's Handbook for information on the MAC Framework APIs.
15064027e4dSRobert Watson.Pp
15164027e4dSRobert Watson.Sh SEE ALSO
15264027e4dSRobert Watson.Xr acl 3 ,
15364027e4dSRobert Watson.Xr cap 3 ,
15464027e4dSRobert Watson.Xr mac 3 ,
15564027e4dSRobert Watson.Xr lomac 4 ,
15664027e4dSRobert Watson.Xr posix1e 3 ,
15764027e4dSRobert Watson.Xr ucred 9 ,
15864027e4dSRobert Watson.Xr vaccess 9 ,
15964027e4dSRobert Watson.Xr vaccess_acl_posix1e 9 ,
16064027e4dSRobert Watson.Xr VFS 9 ,
16164027e4dSRobert Watson.Sh AUTHORS
16264027e4dSRobert WatsonThis man page was written by
16364027e4dSRobert Watson.An Robert Watson .
16464027e4dSRobert WatsonThis software was contributed to the
16564027e4dSRobert Watson.Fx
16664027e4dSRobert WatsonProject by Network Associates Laboratories, the Security Research
16764027e4dSRobert WatsonDivision of Network Associates Inc. under DARPA/SPAWAR contract
16864027e4dSRobert WatsonN66001-01-C-8035 ("CBOSS"), as part of the DARPA CHATS research program.
16964027e4dSRobert Watson.Pp
17064027e4dSRobert Watson.An -nosplit
17164027e4dSRobert WatsonThe TrustedBSD MAC Framework was designed by
17264027e4dSRobert Watson.An Robert Watson ,
17364027e4dSRobert Watsonand implemented by the Network Associates Laboratories Network Security
17464027e4dSRobert Watson(NETSEC), Secure Execution Environement (SEE), and Adaptive
17564027e4dSRobert WatsonNetwork Defense research groups.
17664027e4dSRobert WatsonNetwork Associates Laboratory staff contributing to the CBOSS Project
17764027e4dSRobert Watsoninclude (in alphabetical order):
17864027e4dSRobert Watson.An Lee Badger ,
17964027e4dSRobert Watson.An Brian Feldman ,
18064027e4dSRobert Watson.An Tim Fraser ,
18164027e4dSRobert Watson.An Doug Kilpatrick ,
18264027e4dSRobert Watson.An Suresh Krishnaswamy ,
18364027e4dSRobert Watson.An Adam Migus ,
18464027e4dSRobert Watson.An Wayne Morrison ,
18564027e4dSRobert Watson.An Chris Vance ,
18664027e4dSRobert Watsonand
18764027e4dSRobert Watson.An Robert Watson .
18864027e4dSRobert Watson.Pp
18964027e4dSRobert WatsonSub-contracted staff include:
19064027e4dSRobert Watson.An Chris Costello ,
19164027e4dSRobert Watson.An Poul-Henning Kamp ,
19264027e4dSRobert Watson.An Jonathan Lemon ,
19364027e4dSRobert Watson.An Kirk McKusick ,
19464027e4dSRobert Watson.An Dag-Erling Smorgrav .
19564027e4dSRobert Watson.Pp
19664027e4dSRobert WatsonAdditional contributors include:
19764027e4dSRobert Watson.An Chris Faulhaber ,
19864027e4dSRobert Watson.An Ilmar Habibulin ,
19964027e4dSRobert Watson.An Thomas Moestl ,
20064027e4dSRobert Watsonand
20164027e4dSRobert Watson.An Andrew Reiter .
202bf139e97SRobert Watson.Sh HISTORY
203bf139e97SRobert WatsonThe TrustedBSD MAC Framework first appeared in
204bf139e97SRobert Watson.Fx 5.0
205bf139e97SRobert Watson.Sh BUGS
206bf139e97SRobert WatsonSee the earlier section in this document concerning appropriateness
207bf139e97SRobert Watsonfor production use.
208bf139e97SRobert WatsonThe TrustedBSD MAC Framework is considered experimental in
209bf139e97SRobert Watson.Fx .
210bf139e97SRobert Watson.Pp
211bf139e97SRobert WatsonWhile the MAC Framework design is intended to support the containment of
212bf139e97SRobert Watsonthe root user, not all attack channels are current protected by entry
213bf139e97SRobert Watsonpoint checks.
214bf139e97SRobert WatsonAs such, MAC Framework policies should not be relied on, in isolation,
215bf139e97SRobert Watsonto protect against a malicious privileged user.
216