/*-1* Copyright (c) 1999-2002 Robert N. M. Watson2* Copyright (c) 2001-2004 Networks Associates Technology, Inc.3* All rights reserved.4*5* This software was developed by Robert Watson for the TrustedBSD Project.6*7* This software was developed for the FreeBSD Project in part by Network8* Associates Laboratories, the Security Research Division of Network9* Associates, Inc. under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"),10* as part of the DARPA CHATS research program.11*12* Redistribution and use in source and binary forms, with or without13* modification, are permitted provided that the following conditions14* are met:15* 1. Redistributions of source code must retain the above copyright16* notice, this list of conditions and the following disclaimer.17* 2. Redistributions in binary form must reproduce the above copyright18* notice, this list of conditions and the following disclaimer in the19* documentation and/or other materials provided with the distribution.20*21* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND22* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE23* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE24* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE25* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL26* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS27* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)28* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT29* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY30* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF31* SUCH DAMAGE.32*/33/*34* Definitions for the TrustedBSD MLS confidentiality policy module.35*/36#ifndef _SYS_SECURITY_MAC_MLS_H37#define _SYS_SECURITY_MAC_MLS_H3839#define MAC_MLS_EXTATTR_NAMESPACE EXTATTR_NAMESPACE_SYSTEM40#define MAC_MLS_EXTATTR_NAME "mac_mls"4142#define MAC_MLS_LABEL_NAME "mls"4344#define MAC_MLS_FLAG_EFFECTIVE 0x00000001 /* mm_effective initialized */45#define MAC_MLS_FLAG_RANGE 0x00000002 /* mm_range* initialized */46#define MAC_MLS_FLAGS_BOTH (MAC_MLS_FLAG_EFFECTIVE | MAC_MLS_FLAG_RANGE)4748#define MAC_MLS_TYPE_UNDEF 0 /* Undefined */49#define MAC_MLS_TYPE_LEVEL 1 /* Hierarchal level with mm_level. */50#define MAC_MLS_TYPE_LOW 2 /* Dominated by any51* MAC_MLS_TYPE_LABEL. */52#define MAC_MLS_TYPE_HIGH 3 /* Dominates any53* MAC_MLS_TYPE_LABEL. */54#define MAC_MLS_TYPE_EQUAL 4 /* Equivalent to any55* MAC_MLS_TYPE_LABEL. */5657/*58* Structures and constants associated with a Multi-Level Security policy.59* mac_mls represents an MLS label, with mm_type determining its properties,60* and mm_level represents the hierarchal sensitivity level if valid for the61* current mm_type. If compartments are used, the same semantics apply as62* long as the suject is in every compartment the object is in. LOW, EQUAL63* and HIGH cannot be in compartments.64*/6566/*67* MLS compartments bit set size (in bits).68*/69#define MAC_MLS_MAX_COMPARTMENTS 2567071struct mac_mls_element {72u_short mme_type;73u_short mme_level;74u_char mme_compartments[MAC_MLS_MAX_COMPARTMENTS >> 3];75};7677/*78* MLS labels consist of two components: an effective label, and a label79* range. Depending on the context, one or both may be used; the mb_flags80* field permits the provider to indicate what fields are intended for81* use.82*/83struct mac_mls {84int mm_flags;85struct mac_mls_element mm_effective;86struct mac_mls_element mm_rangelow, mm_rangehigh;87};8889/*90* MLS compartments bit test/set macros.91* The range is 1 to MAC_MLS_MAX_COMPARTMENTS.92*/93#define MAC_MLS_BIT_TEST(b, w) \94((w)[(((b) - 1) >> 3)] & (1 << (((b) - 1) & 7)))95#define MAC_MLS_BIT_SET(b, w) \96((w)[(((b) - 1) >> 3)] |= (1 << (((b) - 1) & 7)))97#define MAC_MLS_BIT_SET_EMPTY(set) mls_bit_set_empty(set)9899#endif /* !_SYS_SECURITY_MAC_MLS_H */100101102