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.\" 32*208a8b95SEdward Tomasz Napierala.Dd July 25, 2015 33d97fcfceSRobert Watson.Dt MAC 3 34051bb54bSRuslan Ermilov.Os 35d97fcfceSRobert Watson.Sh NAME 36d97fcfceSRobert Watson.Nm mac 373a5146d9SRuslan Ermilov.Nd introduction to the MAC security API 38d97fcfceSRobert Watson.Sh LIBRARY 39d97fcfceSRobert Watson.Lb libc 40d97fcfceSRobert Watson.Sh SYNOPSIS 41d97fcfceSRobert Watson.In sys/mac.h 42d97fcfceSRobert Watson.Pp 43d97fcfceSRobert WatsonIn the kernel configuration file: 44d97fcfceSRobert Watson.Cd "options MAC" 45d97fcfceSRobert Watson.Sh DESCRIPTION 463a67af38SRobert WatsonMandatory Access Control labels describe confidentiality, integrity, and 473a67af38SRobert Watsonother security attributes of operating system objects, overriding 483a67af38SRobert Watsondiscretionary access control. 493a67af38SRobert WatsonNot all system objects support MAC labeling, and MAC policies must be 503a67af38SRobert Watsonexplicitly enabled by the administrator. 513a67af38SRobert WatsonThis API, based on POSIX.1e, includes routines to retrieve, manipulate, set, 523a67af38SRobert Watsonand convert to and from text the MAC labels on files and processes. 53d97fcfceSRobert Watson.Pp 543a67af38SRobert WatsonMAC labels consist of a set of (name, value) tuples, representing security 553a67af38SRobert Watsonattributes from MAC policies. 563a67af38SRobert WatsonFor example, this label contains security labels defined by two policies, 573a67af38SRobert Watson.Xr mac_biba 4 583a67af38SRobert Watsonand 593a67af38SRobert Watson.Xr mac_mls 4 : 603a67af38SRobert Watson.Bd -literal -offset indent 613a67af38SRobert Watsonbiba/low,mls/low 623a67af38SRobert Watson.Ed 63d97fcfceSRobert Watson.Pp 643a67af38SRobert WatsonFurther syntax and semantics of MAC labels may be found in 653a67af38SRobert Watson.Xr maclabel 7 . 663a67af38SRobert Watson.Pp 673a67af38SRobert WatsonApplications operate on labels stored in 683a67af38SRobert Watson.Vt mac_t , 693a67af38SRobert Watsonbut can convert between this internal format and a text format for the 703a67af38SRobert Watsonpurposes of presentation to uses or external storage. 713a67af38SRobert WatsonWhen querying a label on an object, a 723a67af38SRobert Watson.Vt mac_t 733a67af38SRobert Watsonmust first be prepared using the interfaces described in 7423408b00SRobert Watson.Xr mac_prepare 3 , 75edfa427cSJoel Dahlallowing the application to declare which policies it wishes to interrogate. 763a67af38SRobert WatsonThe application writer can also rely on default label names declared in 773a67af38SRobert Watson.Xr mac.conf 5 . 783a67af38SRobert Watson.Pp 793a67af38SRobert WatsonWhen finished with a 803a67af38SRobert Watson.Vt mac_t , 813a67af38SRobert Watsonthe application must call 823a67af38SRobert Watson.Xr mac_free 3 833a67af38SRobert Watsonto release its storage. 843a67af38SRobert Watson.Pp 853a67af38SRobert WatsonThe following functions are defined: 863a67af38SRobert Watson.Bl -tag -width indent 873a67af38SRobert Watson.It Fn mac_is_present 883a67af38SRobert WatsonThis function, described in 893a67af38SRobert Watson.Xr mac_is_present 3 , 903a67af38SRobert Watsonallows applications to test whether MAC is configured, as well as whether 913a67af38SRobert Watsonspecific policies are configured. 923a67af38SRobert Watson.It Fn mac_get_fd , Fn mac_get_file , Fn mac_get_link , Fn mac_get_peer 933a67af38SRobert WatsonThese functions, described in 943a67af38SRobert Watson.Xr mac_get 3 , 953a67af38SRobert Watsonretrieve the MAC labels associated with file descriptors, files, and socket 963a67af38SRobert Watsonpeers. 973a67af38SRobert Watson.It Fn mac_get_pid , Fn mac_get_proc 983a67af38SRobert WatsonThese functions, described in 993a67af38SRobert Watson.Xr mac_get 3 , 1003a67af38SRobert Watsonretrieve the MAC labels associated with processes. 1013a67af38SRobert Watson.It Fn mac_set_fd , Fn mac_set_file , Fn mac_set_link 1023a67af38SRobert WatsonThese functions, described in 1033a67af38SRobert Watson.Xr mac_set 3 , 1043a67af38SRobert Watsonset the MAC labels associated with file descriptors and files. 1053a67af38SRobert Watson.It Fn mac_set_proc 1063a67af38SRobert WatsonThis function, described in 1073a67af38SRobert Watson.Xr mac_set 3 , 1083a67af38SRobert Watsonsets the MAC label associated with the current process. 1093a67af38SRobert Watson.It Fn mac_free 110edfa427cSJoel DahlThis function, described in 1113a67af38SRobert Watson.Xr mac_free 3 , 1123a67af38SRobert Watsonfrees working MAC label storage. 1133a67af38SRobert Watson.It Fn mac_from_text 1143a67af38SRobert WatsonThis function, described in 1153a67af38SRobert Watson.Xr mac_text 3 , 1163a67af38SRobert Watsonconverts a text-form MAC label into working MAC label storage, 1173a67af38SRobert Watson.Vt mac_t . 1183a67af38SRobert Watson.It Fn mac_prepare , Fn mac_prepare_file_label , Fn mac_prepare_ifnet_label , Fn mac_prepare_process_label , Fn mac_prepare_type 1193a67af38SRobert WatsonThese functions, described in 1203a67af38SRobert Watson.Xr mac_prepare 3 , 1213a67af38SRobert Watsonallocate working storage for MAC label operations. 12223408b00SRobert Watson.Xr mac_prepare 3 12323408b00SRobert Watsonprepares a label based on caller-specified label names; the other calls 12423408b00SRobert Watsonrely on the default configuration specified in 12523408b00SRobert Watson.Xr mac.conf 5 . 126d97fcfceSRobert Watson.It Fn mac_to_text 127d97fcfceSRobert WatsonThis function is described in 128d97fcfceSRobert Watson.Xr mac_text 3 , 129d97fcfceSRobert Watsonand may be used to convert a 130d97fcfceSRobert Watson.Vt mac_t 131d97fcfceSRobert Watsoninto a text-form MAC label. 132d97fcfceSRobert Watson.El 1338aa884cbSRobert Watson.Sh FILES 1348aa884cbSRobert Watson.Bl -tag -width ".Pa /etc/mac.conf" -compact 1358aa884cbSRobert Watson.It Pa /etc/mac.conf 1368aa884cbSRobert WatsonMAC library configuration file, documented in 1378aa884cbSRobert Watson.Xr mac.conf 5 . 1388aa884cbSRobert WatsonProvides default behavior for applications aware of MAC labels on 1398aa884cbSRobert Watsonsystem objects, but without policy-specific knowledge. 1408aa884cbSRobert Watson.El 141d97fcfceSRobert Watson.Sh SEE ALSO 142d97fcfceSRobert Watson.Xr mac_free 3 , 143d97fcfceSRobert Watson.Xr mac_get 3 , 1443a67af38SRobert Watson.Xr mac_is_present 3 , 14576a829fdSChris Costello.Xr mac_prepare 3 , 146d97fcfceSRobert Watson.Xr mac_set 3 , 14719eab74aSRobert Watson.Xr mac_text 3 , 1483a67af38SRobert Watson.Xr posix1e 3 , 1498f8690e7SChris Costello.Xr mac 4 , 1508aa884cbSRobert Watson.Xr mac.conf 5 , 15119eab74aSRobert Watson.Xr mac 9 152d97fcfceSRobert Watson.Sh STANDARDS 1533a67af38SRobert WatsonThese APIs are loosely based on the APIs described in POSIX.1e, as described 1543a67af38SRobert Watsonin IEEE POSIX.1e draft 17. 155edfa427cSJoel DahlHowever, the resemblance of these APIs to the POSIX APIs is loose, as the 156e5bc56aeSTom RhodesPOSIX APIs were unable to express some notions required for flexible and 1573a67af38SRobert Watsonextensible access control. 158ec05f17eSRobert Watson.Sh HISTORY 159ec05f17eSRobert WatsonSupport for Mandatory Access Control was introduced in 160ec05f17eSRobert Watson.Fx 5.0 1613b296920SRuslan Ermilovas part of the 1623b296920SRuslan Ermilov.Tn TrustedBSD 1633b296920SRuslan ErmilovProject. 164