1a5684034SChris Costello.\" Copyright (c) 2003 Networks Associates Technology, Inc. 2a5684034SChris Costello.\" All rights reserved. 3a5684034SChris Costello.\" 4a5684034SChris Costello.\" This software was developed for the FreeBSD Project by Chris Costello 5a5684034SChris Costello.\" at Safeport Network Services and Network Associates Labs, the 6a5684034SChris Costello.\" Security Research Division of Network Associates, Inc. under 7a5684034SChris Costello.\" DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the 8a5684034SChris Costello.\" DARPA CHATS research program. 9a5684034SChris Costello.\" 10a5684034SChris Costello.\" Redistribution and use in source and binary forms, with or without 11a5684034SChris Costello.\" modification, are permitted provided that the following conditions 12a5684034SChris Costello.\" are met: 13a5684034SChris Costello.\" 1. Redistributions of source code must retain the above copyright 14a5684034SChris Costello.\" notice, this list of conditions and the following disclaimer. 15a5684034SChris Costello.\" 2. Redistributions in binary form must reproduce the above copyright 16a5684034SChris Costello.\" notice, this list of conditions and the following disclaimer in the 17a5684034SChris Costello.\" documentation and/or other materials provided with the distribution. 18a5684034SChris Costello.\" 19a5684034SChris Costello.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND 20a5684034SChris Costello.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21a5684034SChris Costello.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22a5684034SChris Costello.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE 23a5684034SChris Costello.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24a5684034SChris Costello.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25a5684034SChris Costello.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26a5684034SChris Costello.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27a5684034SChris Costello.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28a5684034SChris Costello.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29a5684034SChris Costello.\" SUCH DAMAGE. 30a5684034SChris Costello.\" 31a5684034SChris Costello.\" $FreeBSD$ 323cc3bf52SRuslan Ermilov.\" 333cc3bf52SRuslan Ermilov.Dd January 8, 2003 34a5684034SChris Costello.Os 35a5684034SChris Costello.Dt MAC 4 36a5684034SChris Costello.Sh NAME 37a5684034SChris Costello.Nm mac 38a5684034SChris Costello.Nd Mandatory Access Control 39a5684034SChris Costello.Sh SYNOPSIS 40a5684034SChris Costello.Cd "options MAC" 41a5684034SChris Costello.Sh DESCRIPTION 42a5684034SChris Costello.Ss Introduction 43a5684034SChris CostelloThe Mandatory Access Control, or MAC, framework allows administrators to 44a5684034SChris Costellofinely control system security by providing for a loadable security policy 45a5684034SChris Costelloarchitecture. 46a5684034SChris CostelloIt is important to note that due to its nature, MAC security policies may 479c73007cSChris Costelloonly restrict access relative to one another and the base system policy; 483cc3bf52SRuslan Ermilovthey cannot override traditional 493cc3bf52SRuslan Ermilov.Ux 50a5684034SChris Costellosecurity provisions such as file permissions and superuser checks. 51a5684034SChris Costello.Pp 52a5684034SChris CostelloCurrently, the following MAC policy modules are shipped with 53a5684034SChris Costello.Fx : 54a5684034SChris Costello.Bl -column ".Xr mac_seeotheruids 4" "low-watermark mac policy" ".Em Labeling" "boot only" 55028c285dSChris Costello.It Sy Name Ta Sy Description Ta Sy Labeling Ta Sy "Load time" 56a5684034SChris Costello.It Xr mac_biba 4 Ta "Biba integrity policy" Ta yes Ta boot only 57a5684034SChris Costello.It Xr mac_bsdextended 4 Ta "File system firewall" Ta no Ta any time 58a5684034SChris Costello.It Xr mac_ifoff 4 Ta "Interface silencing" Ta no Ta any time 59a5684034SChris Costello.It Xr mac_lomac 4 Ta "Low-Watermark MAC policy" Ta yes Ta boot only 60a5684034SChris Costello.It Xr mac_mls 4 Ta "Confidentiality policy" Ta yes Ta boot only 61a5684034SChris Costello.It Xr mac_none 4 Ta "Sample no-op policy" Ta no Ta any time 62a5684034SChris Costello.It Xr mac_partition 4 Ta "Process partition policy" Ta yes Ta any time 630c6e926fSChris Costello.It Xr mac_portacl 4 Ta "Port bind(2) access control" Ta no Ta any time 64a5684034SChris Costello.It Xr mac_seeotheruids 4 Ta "See-other-UIDs policy" Ta no Ta any time 65a5684034SChris Costello.It Xr mac_test 4 Ta "MAC testing policy" Ta no Ta any time 66a5684034SChris Costello.El 679c73007cSChris Costello.Ss MAC Labels 689c73007cSChris CostelloEach system subject (processes, sockets, etc.) and each system object 699c73007cSChris Costello(file system objects, sockets, etc.) can carry with it a MAC label. 709c73007cSChris CostelloMAC labels contain data in an arbitrary format 719c73007cSChris Costellotaken into consideration in making access control decisions 729c73007cSChris Costellofor a given operation. 739c73007cSChris CostelloMost MAC labels on system subjects and objects 749c73007cSChris Costellocan be modified directly or indirectly by the system 759c73007cSChris Costelloadministrator. 769c73007cSChris CostelloThe format for a given policy's label may vary depending on the type 779c73007cSChris Costelloof object or subject being labeled. 789c73007cSChris CostelloMore information on the format for MAC labels can be found in the 799c73007cSChris Costello.Xr maclabel 7 809c73007cSChris Costelloman page. 81d29d42d8SChris Costello.Ss MAC Support for UFS2 File Systems 829c73007cSChris CostelloBy default, file system enforcement of labeled MAC policies relies on 839c73007cSChris Costelloa single file system label 84d29d42d8SChris Costello(see 85d29d42d8SChris Costello.Sx "MAC Labels" ) 86d29d42d8SChris Costelloin order to make access control decisions for all the files in a particular 87d29d42d8SChris Costellofile system. 889c73007cSChris CostelloWith some policies, this configuration may not allow administrators to take 899c73007cSChris Costellofull advantage of features. 909c73007cSChris CostelloIn order to enable support for labeling files on an individual basis 919c73007cSChris Costellofor a particular file system, 92d29d42d8SChris Costellothe 93d29d42d8SChris Costello.Dq multilabel 94d29d42d8SChris Costelloflag must be enabled on the file system. 95d29d42d8SChris CostelloTo set the 96d29d42d8SChris Costello.Dq multilabel 97d29d42d8SChris Costelloflag, drop to single-user mode and unmount the file system, 98d29d42d8SChris Costellothen execute the following command: 99d29d42d8SChris Costello.Pp 1003cc3bf52SRuslan Ermilov.Dl "tunefs -l enable" Ar filesystem 101d29d42d8SChris Costello.Pp 102d29d42d8SChris Costellowhere 1033cc3bf52SRuslan Ermilov.Ar filesystem 104d29d42d8SChris Costellois either the mount point 105d29d42d8SChris Costello(in 106d29d42d8SChris Costello.Xr fstab 5 ) 107d29d42d8SChris Costelloor the special file 108d29d42d8SChris Costello(in 109d29d42d8SChris Costello.Pa /dev ) 110d29d42d8SChris Costellocorresponding to the file system on which to enable multilabel support. 11158ce77d3SChris Costello.Ss Policy Enforcement 11258ce77d3SChris CostelloMAC can be configured to enforce only specific portions of 11358ce77d3SChris Costellopolicies 11458ce77d3SChris Costello(see 11558ce77d3SChris Costello.Sx "Runtime Configuration" ) . 11658ce77d3SChris CostelloPolicy enforcement is divided into the following areas of the system: 11758ce77d3SChris Costello.Bl -ohang 1183cc3bf52SRuslan Ermilov.It Sy "File System" 11958ce77d3SChris CostelloFile system mounts, modifying directories, modifying files, etc. 12058ce77d3SChris Costello.It Sy KLD 12158ce77d3SChris CostelloLoading, unloading, and retrieving statistics on loaded kernel modules 12258ce77d3SChris Costello.It Sy Network 12358ce77d3SChris CostelloNetwork interfaces, 1249c73007cSChris Costello.Xr bpf 4 , 1259c73007cSChris Costellopacket delivery and transmission, 1269c73007cSChris Costellointerface configuration 1279c73007cSChris Costello.Xr ( ioctl 2 , 1289c73007cSChris Costello.Xr ifconfig 8 ) 12958ce77d3SChris Costello.It Sy Pipes 13058ce77d3SChris CostelloCreation of and operation on 13158ce77d3SChris Costello.Xr pipe 2 13258ce77d3SChris Costelloobjects 13358ce77d3SChris Costello.It Sy Processes 13458ce77d3SChris CostelloDebugging 1353cc3bf52SRuslan Ermilov(e.g.\& 13658ce77d3SChris Costello.Xr ktrace 2 ) , 13758ce77d3SChris Costelloprocess visibility 1383cc3bf52SRuslan Ermilov.Pq Xr ps 1 , 13958ce77d3SChris Costelloprocess execution 1403cc3bf52SRuslan Ermilov.Pq Xr execve 2 , 14158ce77d3SChris Costellosignalling 1423cc3bf52SRuslan Ermilov.Pq Xr kill 2 14358ce77d3SChris Costello.It Sy Sockets 1449c73007cSChris CostelloCreation of and operation on 14558ce77d3SChris Costello.Xr socket 2 14658ce77d3SChris Costelloobjects 14758ce77d3SChris Costello.It Sy System 14858ce77d3SChris CostelloKernel environment 1493cc3bf52SRuslan Ermilov.Pq Xr kenv 1 , 15058ce77d3SChris Costellosystem accounting 1513cc3bf52SRuslan Ermilov.Pq Xr acct 2 , 15258ce77d3SChris Costello.Xr reboot 2 , 15358ce77d3SChris Costello.Xr settimeofday 2 , 15458ce77d3SChris Costello.Xr swapon 2 , 15558ce77d3SChris Costello.Xr sysctl 3 , 1563cc3bf52SRuslan Ermilov.Xr nfsd 8 Ns 1573cc3bf52SRuslan Ermilov-related operations 15858ce77d3SChris Costello.It Sy VM 1593cc3bf52SRuslan Ermilov.Xr mmap 2 Ns 1603cc3bf52SRuslan Ermilov-ed files 16158ce77d3SChris Costello.El 162b9e873d4SChris Costello.Ss Setting MAC Labels 163972f13bcSChris CostelloFrom the command line, each type of system object has its own means for setting 164a5684034SChris Costelloand modifying its MAC policy label. 1659c73007cSChris Costello.Bl -column "user (by login class)" "Xr setfmac 8 , Xr setfsmac 8" -offset indent 166028c285dSChris Costello.It Sy "Subject/Object" Ta Sy "Utility" 1679c73007cSChris Costello.It "File system object" Ta Xr setfmac 8 , Xr setfsmac 8 168a5684034SChris Costello.It "Network interface" Ta Xr ifconfig 8 169a5684034SChris Costello.It "TTY (by login class)" Ta Xr login.conf 5 170a5684034SChris Costello.It "User (by login class)" Ta Xr login.conf 5 171a5684034SChris Costello.El 172a5684034SChris Costello.Pp 173a5684034SChris CostelloAdditionally, the 1749c73007cSChris Costello.Xr su 1 1759c73007cSChris Costelloand 176a5684034SChris Costello.Xr setpmac 8 1779c73007cSChris Costelloutilities can be used to run a command with a different process label than 178a5684034SChris Costellothe shell's current label. 179a5684034SChris Costello.Ss Programming With MAC 180a5684034SChris CostelloMAC security enforcement itself is transparent to application 181a5684034SChris Costelloprograms, with the exception that some programs may need to be aware of 182a5684034SChris Costelloadditional 183a5684034SChris Costello.Xr errno 2 184a5684034SChris Costelloreturns from various system calls. 185a5684034SChris Costello.Pp 186a5684034SChris CostelloThe interface for retrieving, handling, and setting policy labels 187a5684034SChris Costellois documented in the 188a5684034SChris Costello.Xr mac 3 189a5684034SChris Costelloman page. 19058ce77d3SChris Costello.Ss Runtime Configuration 19158ce77d3SChris CostelloThe following 19258ce77d3SChris Costello.Xr sysctl 8 19358ce77d3SChris CostelloMIBs are available for fine-tuning the enforcement of MAC policies. 1943cc3bf52SRuslan ErmilovUnless specifically noted, all MIBs default to 1 19558ce77d3SChris Costello(that is, all areas are enforced by default): 1963cc3bf52SRuslan Ermilov.Bl -tag -width ".Va security.mac.enforce_network" 19758ce77d3SChris Costello.It Va security.mac.enforce_fs 1983cc3bf52SRuslan ErmilovEnforce MAC policies for file system accesses. 19958ce77d3SChris Costello.It Va security.mac.enforce_kld 20058ce77d3SChris CostelloEnforce MAC policies on 2013cc3bf52SRuslan Ermilov.Xr kld 4 . 20258ce77d3SChris Costello.It Va security.mac.enforce_network 2033cc3bf52SRuslan ErmilovEnforce MAC policies on network interfaces. 20458ce77d3SChris Costello.It Va security.mac.enforce_pipe 2053cc3bf52SRuslan ErmilovEnforce MAC policies on pipes. 20658ce77d3SChris Costello.It Va security.mac.enforce_process 20758ce77d3SChris CostelloEnforce MAC policies between system processes 2083cc3bf52SRuslan Ermilov(e.g.\& 20958ce77d3SChris Costello.Xr ps 1 , 2103cc3bf52SRuslan Ermilov.Xr ktrace 2 ) . 21158ce77d3SChris Costello.It Va security.mac.enforce_socket 2123cc3bf52SRuslan ErmilovEnforce MAC policies on sockets. 21358ce77d3SChris Costello.It Va security.mac.enforce_system 21458ce77d3SChris CostelloEnforce MAC policies on system-related items 2153cc3bf52SRuslan Ermilov(e.g.\& 21658ce77d3SChris Costello.Xr kenv 1 , 21758ce77d3SChris Costello.Xr acct 2 , 2183cc3bf52SRuslan Ermilov.Xr reboot 2 ) . 21958ce77d3SChris Costello.It Va security.mac.enforce_vm 22058ce77d3SChris CostelloEnforce MAC policies on 22158ce77d3SChris Costello.Xr mmap 2 22258ce77d3SChris Costelloand 2233cc3bf52SRuslan Ermilov.Xr mprotect 2 . 2249c73007cSChris Costello.\" *** XXX *** 2259c73007cSChris Costello.\" Support for this feature is poor and should not be encouraged. 2269c73007cSChris Costello.\" 2279c73007cSChris Costello.\" .It Va security.mac.mmap_revocation 2289c73007cSChris Costello.\" Revoke 2299c73007cSChris Costello.\" .Xr mmap 2 2303cc3bf52SRuslan Ermilov.\" access to files on subject relabel. 2319c73007cSChris Costello.\" .It Va security.mac.mmap_revocation_via_cow 2329c73007cSChris Costello.\" Revoke 2339c73007cSChris Costello.\" .Xr mmap 2 2349c73007cSChris Costello.\" access to files via copy-on-write semantics; 2359c73007cSChris Costello.\" mapped regions will still appear writable, but will no longer 2363cc3bf52SRuslan Ermilov.\" effect a change on the underlying vnode. 2373cc3bf52SRuslan Ermilov.\" (Default: 0). 23858ce77d3SChris Costello.El 239a5684034SChris Costello.Sh SEE ALSO 240a5684034SChris Costello.Xr mac 3 , 241a5684034SChris Costello.Xr mac_biba 4 , 242a5684034SChris Costello.Xr mac_bsdextended 4 , 243a5684034SChris Costello.Xr mac_ifoff 4 , 244a5684034SChris Costello.Xr mac_lomac 4 , 245a5684034SChris Costello.Xr mac_mls 4 , 246a5684034SChris Costello.Xr mac_none 4 , 247a5684034SChris Costello.Xr mac_partition 4 , 2480c6e926fSChris Costello.Xr mac_portacl 4 , 249a5684034SChris Costello.Xr mac_seeotheruids 4 , 250a5684034SChris Costello.Xr mac_test 4 , 2513cc3bf52SRuslan Ermilov.Xr login.conf 5 , 252a5684034SChris Costello.Xr maclabel 7 , 253a5684034SChris Costello.Xr getfmac 8 , 254a5684034SChris Costello.Xr getpmac 8 , 2553cc3bf52SRuslan Ermilov.Xr setfmac 8 , 256a5684034SChris Costello.Xr setpmac 8 , 257a5684034SChris Costello.Xr mac 9 258bc2c2a48SChris Costello.Rs 259bc2c2a48SChris Costello.%B "The FreeBSD Handbook" 260bc2c2a48SChris Costello.%T "Mandatory Access Control" 2613cc3bf52SRuslan Ermilov.%O http://www.FreeBSD.org/doc/en_US.ISO8859-1/books/handbook/mac.html 262bc2c2a48SChris Costello.Re 263a5684034SChris Costello.Sh HISTORY 264a5684034SChris CostelloThe 265a5684034SChris Costello.Nm 266a5684034SChris Costelloimplementation first appeared in 267a5684034SChris Costello.Fx 5.0 2683cc3bf52SRuslan Ermilovand was developed by the 2693cc3bf52SRuslan Ermilov.Tn TrustedBSD 2703cc3bf52SRuslan ErmilovProject. 271a5684034SChris Costello.Sh AUTHORS 272a5684034SChris CostelloThis software was contributed to the 273a5684034SChris Costello.Fx 274a5684034SChris CostelloProject by Network Associates Labs, 275a5684034SChris Costellothe Security Research Division of Network Associates 2765203edcdSRuslan ErmilovInc. 2775203edcdSRuslan Ermilovunder DARPA/SPAWAR contract N66001-01-C-8035 2783cc3bf52SRuslan Ermilov.Pq Dq CBOSS , 279a5684034SChris Costelloas part of the DARPA CHATS research program. 2809c73007cSChris Costello.Sh BUGS 2819c73007cSChris CostelloSee 2829c73007cSChris Costello.Xr mac 9 2839c73007cSChris Costelloconcerning appropriateness for production use. 2843cc3bf52SRuslan ErmilovThe 2853cc3bf52SRuslan Ermilov.Tn TrustedBSD 2863cc3bf52SRuslan ErmilovMAC Framework is considered experimental in 2879c73007cSChris Costello.Fx . 2889c73007cSChris Costello.Pp 2899c73007cSChris CostelloWhile the MAC Framework design is intended to support the containment of 2909c73007cSChris Costellothe root user, not all attack channels are currently protected by entry 2919c73007cSChris Costellopoint checks. 2929c73007cSChris CostelloAs such, MAC Framework policies should not be relied on, in isolation, 2939c73007cSChris Costelloto protect against a malicious privileged user. 294