mac_biba.h revision 106393
1161197Simp/*- 2161197Simp * Copyright (c) 1999, 2000, 2001, 2002 Robert N. M. Watson 3161197Simp * Copyright (c) 2001, 2002 Networks Associates Technology, Inc. 4161197Simp * All rights reserved. 5161197Simp * 6161197Simp * This software was developed by Robert Watson for the TrustedBSD Project. 7161197Simp * 8161197Simp * This software was developed for the FreeBSD Project in part by Network 9161197Simp * Associates Laboratories, the Security Research Division of Network 10161197Simp * Associates, Inc. under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), 11161197Simp * as part of the DARPA CHATS research program. 12161197Simp * 13161197Simp * Redistribution and use in source and binary forms, with or without 14161197Simp * modification, are permitted provided that the following conditions 15161197Simp * are met: 16161197Simp * 1. Redistributions of source code must retain the above copyright 17161197Simp * notice, this list of conditions and the following disclaimer. 18161197Simp * 2. Redistributions in binary form must reproduce the above copyright 19161197Simp * notice, this list of conditions and the following disclaimer in the 20161197Simp * documentation and/or other materials provided with the distribution. 21161197Simp * 22161197Simp * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 23161197Simp * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24161197Simp * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25161197Simp * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 26161197Simp * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27161197Simp * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28161197Simp * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29161197Simp * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30161197Simp * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31161197Simp * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32161197Simp * SUCH DAMAGE. 33161197Simp * 34161197Simp * $FreeBSD: head/sys/security/mac_biba/mac_biba.h 106393 2002-11-04 01:53:12Z rwatson $ 35161197Simp */ 36161197Simp/* 37161197Simp * Definitions for the TrustedBSD Biba integrity policy module. 38161197Simp */ 39161197Simp#ifndef _SYS_SECURITY_MAC_BIBA_H 40161197Simp#define _SYS_SECURITY_MAC_BIBA_H 41161197Simp 42161197Simp#define MAC_BIBA_EXTATTR_NAMESPACE EXTATTR_NAMESPACE_SYSTEM 43161197Simp#define MAC_BIBA_EXTATTR_NAME "mac_biba" 44161197Simp 45161197Simp#define MAC_BIBA_LABEL_NAME "biba" 46161197Simp 47161197Simp#define MAC_BIBA_FLAG_SINGLE 0x00000001 /* mb_single initialized */ 48161197Simp#define MAC_BIBA_FLAG_RANGE 0x00000002 /* mb_range* initialized */ 49161197Simp#define MAC_BIBA_FLAGS_BOTH (MAC_BIBA_FLAG_SINGLE | MAC_BIBA_FLAG_RANGE) 50161197Simp 51161197Simp#define MAC_BIBA_TYPE_UNDEF 0 /* Undefined */ 52161197Simp#define MAC_BIBA_TYPE_GRADE 1 /* Hierarchal grade with mb_grade. */ 53161197Simp#define MAC_BIBA_TYPE_LOW 2 /* Dominated by any 54161197Simp * MAC_BIBA_TYPE_LABEL. */ 55161197Simp#define MAC_BIBA_TYPE_HIGH 3 /* Dominates any 56161197Simp * MAC_BIBA_TYPE_LABEL. */ 57161197Simp#define MAC_BIBA_TYPE_EQUAL 4 /* Equivilent to any 58161197Simp * MAC_BIBA_TYPE_LABEL. */ 59161197Simp 60161197Simp/* 61161197Simp * Structures and constants associated with a Biba Integrity policy. 62161197Simp * mac_biba represents a Biba label, with mb_type determining its properties, 63161197Simp * and mb_grade represents the hierarchal grade if valid for the current 64161197Simp * mb_type. 65161197Simp */ 66161197Simp 67161197Simp#define MAC_BIBA_MAX_COMPARTMENTS 256 68161197Simp 69161197Simpstruct mac_biba_element { 70161197Simp u_short mbe_type; 71161197Simp u_short mbe_grade; 72161197Simp u_char mbe_compartments[MAC_BIBA_MAX_COMPARTMENTS >> 3]; 73161197Simp}; 74161197Simp 75161197Simp/* 76161197Simp * Biba labels consist of two components: a single label, and a label 77161197Simp * range. Depending on the context, one or both may be used; the mb_flags 78161197Simp * field permits the provider to indicate what fields are intended for 79161197Simp * use. 80161197Simp */ 81161197Simpstruct mac_biba { 82161197Simp int mb_flags; 83161197Simp struct mac_biba_element mb_single; 84161197Simp struct mac_biba_element mb_rangelow, mb_rangehigh; 85161197Simp}; 86161197Simp 87161197Simp/* 88161197Simp * Biba compartments bit test/set macros. 89161197Simp * The range is 1 to MAC_BIBA_MAX_COMPARTMENTS. 90161197Simp */ 91161197Simp#define MAC_BIBA_BIT_TEST(b, w) \ 92161197Simp ((w)[(((b) - 1) >> 3)] & (1 << (((b) - 1) & 7))) 93161197Simp#define MAC_BIBA_BIT_SET(b, w) \ 94161197Simp ((w)[(((b) - 1) >> 3)] |= (1 << (((b) - 1) & 7))) 95161197Simp#define MAC_BIBA_BIT_SET_EMPTY(set) biba_bit_set_empty(set) 96161197Simp 97161197Simp#endif /* !_SYS_SECURITY_MAC_BIBA_H */ 98161197Simp