1ecf88982SRobert Watson.\" Copyright (c) 2001, 2003 Networks Associates Technology, Inc. 23a67af38SRobert Watson.\" Copyright (c) 2009 Robert N. M. Watson 3d97fcfceSRobert Watson.\" All rights reserved. 4d97fcfceSRobert Watson.\" 5d97fcfceSRobert Watson.\" This software was developed for the FreeBSD Project by Chris 6ec05f17eSRobert Watson.\" Costello at Safeport Network Services and Network Associates 7ec05f17eSRobert Watson.\" Laboratories, the Security Research Division of Network Associates, 8ec05f17eSRobert Watson.\" Inc. under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part 9ec05f17eSRobert Watson.\" of the DARPA CHATS research program. 10d97fcfceSRobert Watson.\" 11d97fcfceSRobert Watson.\" Redistribution and use in source and binary forms, with or without 12d97fcfceSRobert Watson.\" modification, are permitted provided that the following conditions 13d97fcfceSRobert Watson.\" are met: 14d97fcfceSRobert Watson.\" 1. Redistributions of source code must retain the above copyright 15d97fcfceSRobert Watson.\" notice, this list of conditions and the following disclaimer. 16d97fcfceSRobert Watson.\" 2. Redistributions in binary form must reproduce the above copyright 17d97fcfceSRobert Watson.\" notice, this list of conditions and the following disclaimer in the 18d97fcfceSRobert Watson.\" documentation and/or other materials provided with the distribution. 19d97fcfceSRobert Watson.\" 20d97fcfceSRobert Watson.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND 21d97fcfceSRobert Watson.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22d97fcfceSRobert Watson.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23d97fcfceSRobert Watson.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE 24d97fcfceSRobert Watson.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25d97fcfceSRobert Watson.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26d97fcfceSRobert Watson.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27d97fcfceSRobert Watson.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28d97fcfceSRobert Watson.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29d97fcfceSRobert Watson.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30d97fcfceSRobert Watson.\" SUCH DAMAGE. 31d97fcfceSRobert Watson.\" 32d97fcfceSRobert Watson.\" $FreeBSD$ 333b296920SRuslan Ermilov.\" 343a67af38SRobert Watson.Dd August 7, 2009 35d97fcfceSRobert Watson.Dt MAC 3 36051bb54bSRuslan Ermilov.Os 37d97fcfceSRobert Watson.Sh NAME 38d97fcfceSRobert Watson.Nm mac 393a5146d9SRuslan Ermilov.Nd introduction to the MAC security API 40d97fcfceSRobert Watson.Sh LIBRARY 41d97fcfceSRobert Watson.Lb libc 42d97fcfceSRobert Watson.Sh SYNOPSIS 43d97fcfceSRobert Watson.In sys/mac.h 44d97fcfceSRobert Watson.Pp 45d97fcfceSRobert WatsonIn the kernel configuration file: 46d97fcfceSRobert Watson.Cd "options MAC" 47d97fcfceSRobert Watson.Sh DESCRIPTION 483a67af38SRobert WatsonMandatory Access Control labels describe confidentiality, integrity, and 493a67af38SRobert Watsonother security attributes of operating system objects, overriding 503a67af38SRobert Watsondiscretionary access control. 513a67af38SRobert WatsonNot all system objects support MAC labeling, and MAC policies must be 523a67af38SRobert Watsonexplicitly enabled by the administrator. 533a67af38SRobert WatsonThis API, based on POSIX.1e, includes routines to retrieve, manipulate, set, 543a67af38SRobert Watsonand convert to and from text the MAC labels on files and processes. 55d97fcfceSRobert Watson.Pp 563a67af38SRobert WatsonMAC labels consist of a set of (name, value) tuples, representing security 573a67af38SRobert Watsonattributes from MAC policies. 583a67af38SRobert WatsonFor example, this label contains security labels defined by two policies, 593a67af38SRobert Watson.Xr mac_biba 4 603a67af38SRobert Watsonand 613a67af38SRobert Watson.Xr mac_mls 4 : 623a67af38SRobert Watson.Bd -literal -offset indent 633a67af38SRobert Watsonbiba/low,mls/low 643a67af38SRobert Watson.Ed 65d97fcfceSRobert Watson.Pp 663a67af38SRobert WatsonFurther syntax and semantics of MAC labels may be found in 673a67af38SRobert Watson.Xr maclabel 7 . 683a67af38SRobert Watson.Pp 693a67af38SRobert WatsonApplications operate on labels stored in 703a67af38SRobert Watson.Vt mac_t , 713a67af38SRobert Watsonbut can convert between this internal format and a text format for the 723a67af38SRobert Watsonpurposes of presentation to uses or external storage. 733a67af38SRobert WatsonWhen querying a label on an object, a 743a67af38SRobert Watson.Vt mac_t 753a67af38SRobert Watsonmust first be prepared using the interfaces described in 7623408b00SRobert Watson.Xr mac_prepare 3 , 77*edfa427cSJoel Dahlallowing the application to declare which policies it wishes to interrogate. 783a67af38SRobert WatsonThe application writer can also rely on default label names declared in 793a67af38SRobert Watson.Xr mac.conf 5 . 803a67af38SRobert Watson.Pp 813a67af38SRobert WatsonWhen finished with a 823a67af38SRobert Watson.Vt mac_t , 833a67af38SRobert Watsonthe application must call 843a67af38SRobert Watson.Xr mac_free 3 853a67af38SRobert Watsonto release its storage. 863a67af38SRobert Watson.Pp 873a67af38SRobert WatsonThe following functions are defined: 883a67af38SRobert Watson.Bl -tag -width indent 893a67af38SRobert Watson.It Fn mac_is_present 903a67af38SRobert WatsonThis function, described in 913a67af38SRobert Watson.Xr mac_is_present 3 , 923a67af38SRobert Watsonallows applications to test whether MAC is configured, as well as whether 933a67af38SRobert Watsonspecific policies are configured. 943a67af38SRobert Watson.It Fn mac_get_fd , Fn mac_get_file , Fn mac_get_link , Fn mac_get_peer 953a67af38SRobert WatsonThese functions, described in 963a67af38SRobert Watson.Xr mac_get 3 , 973a67af38SRobert Watsonretrieve the MAC labels associated with file descriptors, files, and socket 983a67af38SRobert Watsonpeers. 993a67af38SRobert Watson.It Fn mac_get_pid , Fn mac_get_proc 1003a67af38SRobert WatsonThese functions, described in 1013a67af38SRobert Watson.Xr mac_get 3 , 1023a67af38SRobert Watsonretrieve the MAC labels associated with processes. 1033a67af38SRobert Watson.It Fn mac_set_fd , Fn mac_set_file , Fn mac_set_link 1043a67af38SRobert WatsonThese functions, described in 1053a67af38SRobert Watson.Xr mac_set 3 , 1063a67af38SRobert Watsonset the MAC labels associated with file descriptors and files. 1073a67af38SRobert Watson.It Fn mac_set_proc 1083a67af38SRobert WatsonThis function, described in 1093a67af38SRobert Watson.Xr mac_set 3 , 1103a67af38SRobert Watsonsets the MAC label associated with the current process. 1113a67af38SRobert Watson.It Fn mac_free 112*edfa427cSJoel DahlThis function, described in 1133a67af38SRobert Watson.Xr mac_free 3 , 1143a67af38SRobert Watsonfrees working MAC label storage. 1153a67af38SRobert Watson.It Fn mac_from_text 1163a67af38SRobert WatsonThis function, described in 1173a67af38SRobert Watson.Xr mac_text 3 , 1183a67af38SRobert Watsonconverts a text-form MAC label into working MAC label storage, 1193a67af38SRobert Watson.Vt mac_t . 1203a67af38SRobert Watson.It Fn mac_prepare , Fn mac_prepare_file_label , Fn mac_prepare_ifnet_label , Fn mac_prepare_process_label , Fn mac_prepare_type 1213a67af38SRobert WatsonThese functions, described in 1223a67af38SRobert Watson.Xr mac_prepare 3 , 1233a67af38SRobert Watsonallocate working storage for MAC label operations. 12423408b00SRobert Watson.Xr mac_prepare 3 12523408b00SRobert Watsonprepares a label based on caller-specified label names; the other calls 12623408b00SRobert Watsonrely on the default configuration specified in 12723408b00SRobert Watson.Xr mac.conf 5 . 128d97fcfceSRobert Watson.It Fn mac_to_text 129d97fcfceSRobert WatsonThis function is described in 130d97fcfceSRobert Watson.Xr mac_text 3 , 131d97fcfceSRobert Watsonand may be used to convert a 132d97fcfceSRobert Watson.Vt mac_t 133d97fcfceSRobert Watsoninto a text-form MAC label. 134d97fcfceSRobert Watson.El 1358aa884cbSRobert Watson.Sh FILES 1368aa884cbSRobert Watson.Bl -tag -width ".Pa /etc/mac.conf" -compact 1378aa884cbSRobert Watson.It Pa /etc/mac.conf 1388aa884cbSRobert WatsonMAC library configuration file, documented in 1398aa884cbSRobert Watson.Xr mac.conf 5 . 1408aa884cbSRobert WatsonProvides default behavior for applications aware of MAC labels on 1418aa884cbSRobert Watsonsystem objects, but without policy-specific knowledge. 1428aa884cbSRobert Watson.El 143d97fcfceSRobert Watson.Sh SEE ALSO 144d97fcfceSRobert Watson.Xr mac_free 3 , 145d97fcfceSRobert Watson.Xr mac_get 3 , 1463a67af38SRobert Watson.Xr mac_is_present 3 , 14776a829fdSChris Costello.Xr mac_prepare 3 , 148d97fcfceSRobert Watson.Xr mac_set 3 , 14919eab74aSRobert Watson.Xr mac_text 3 , 1503a67af38SRobert Watson.Xr posix1e 3 , 1518f8690e7SChris Costello.Xr mac 4 , 1528aa884cbSRobert Watson.Xr mac.conf 5 , 15319eab74aSRobert Watson.Xr mac 9 154d97fcfceSRobert Watson.Sh STANDARDS 1553a67af38SRobert WatsonThese APIs are loosely based on the APIs described in POSIX.1e, as described 1563a67af38SRobert Watsonin IEEE POSIX.1e draft 17. 157*edfa427cSJoel DahlHowever, the resemblance of these APIs to the POSIX APIs is loose, as the 158e5bc56aeSTom RhodesPOSIX APIs were unable to express some notions required for flexible and 1593a67af38SRobert Watsonextensible access control. 160ec05f17eSRobert Watson.Sh HISTORY 161ec05f17eSRobert WatsonSupport for Mandatory Access Control was introduced in 162ec05f17eSRobert Watson.Fx 5.0 1633b296920SRuslan Ermilovas part of the 1643b296920SRuslan Ermilov.Tn TrustedBSD 1653b296920SRuslan ErmilovProject. 166443ab2a0SRobert Watson.Sh BUGS 1673b296920SRuslan ErmilovThe 1683b296920SRuslan Ermilov.Tn TrustedBSD 1693b296920SRuslan ErmilovMAC Framework and associated policies, interfaces, and 170443ab2a0SRobert Watsonapplications are considered to be an experimental feature in 171443ab2a0SRobert Watson.Fx . 172443ab2a0SRobert WatsonSites considering production deployment should keep the experimental 173443ab2a0SRobert Watsonstatus of these services in mind during any deployment process. 174443ab2a0SRobert WatsonSee also 175443ab2a0SRobert Watson.Xr mac 9 176443ab2a0SRobert Watsonfor related considerations regarding the kernel framework. 177