xref: /freebsd/sys/security/mac_biba/mac_biba.h (revision 51a9219f5780e61e1437d25220bf8750d9df7f8b)
1 /*-
2  * Copyright (c) 1999, 2000, 2001, 2002 Robert N. M. Watson
3  * Copyright (c) 2001, 2002 Networks Associates Technology, Inc.
4  * All rights reserved.
5  *
6  * This software was developed by Robert Watson for the TrustedBSD Project.
7  *
8  * This software was developed for the FreeBSD Project in part by NAI Labs,
9  * the Security Research Division of Network Associates, Inc. under
10  * DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the DARPA
11  * CHATS research program.
12  *
13  * Redistribution and use in source and binary forms, with or without
14  * modification, are permitted provided that the following conditions
15  * are met:
16  * 1. Redistributions of source code must retain the above copyright
17  *    notice, this list of conditions and the following disclaimer.
18  * 2. Redistributions in binary form must reproduce the above copyright
19  *    notice, this list of conditions and the following disclaimer in the
20  *    documentation and/or other materials provided with the distribution.
21  * 3. The names of the authors may not be used to endorse or promote
22  *    products derived from this software without specific prior written
23  *    permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
26  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
29  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35  * SUCH DAMAGE.
36  *
37  * $FreeBSD$
38  */
39 /*
40  * Definitions for the TrustedBSD Biba integrity policy module.
41  */
42 #ifndef _SYS_SECURITY_MAC_BIBA_H
43 #define	_SYS_SECURITY_MAC_BIBA_H
44 
45 #define	MAC_BIBA_EXTATTR_NAMESPACE	EXTATTR_NAMESPACE_SYSTEM
46 #define	MAC_BIBA_EXTATTR_NAME		"mac_biba"
47 
48 #define	MAC_BIBA_LABEL_NAME		"biba"
49 
50 #define	MAC_BIBA_FLAG_SINGLE	0x00000001	/* mb_single initialized */
51 #define	MAC_BIBA_FLAG_RANGE	0x00000002	/* mb_range* initialized */
52 #define	MAC_BIBA_FLAGS_BOTH	(MAC_BIBA_FLAG_SINGLE | MAC_BIBA_FLAG_RANGE)
53 
54 #define	MAC_BIBA_TYPE_UNDEF	0	/* Undefined */
55 #define	MAC_BIBA_TYPE_GRADE	1	/* Hierarchal grade with mb_grade. */
56 #define	MAC_BIBA_TYPE_LOW	2	/* Dominated by any
57 					 * MAC_BIBA_TYPE_LABEL. */
58 #define	MAC_BIBA_TYPE_HIGH	3	/* Dominates any
59 					 * MAC_BIBA_TYPE_LABEL. */
60 #define	MAC_BIBA_TYPE_EQUAL	4	/* Equivilent to any
61 					 * MAC_BIBA_TYPE_LABEL. */
62 
63 /*
64  * Biba compartments bit test/set macros.
65  * The range is 1 to MAC_BIBA_MAX_COMPARTMENTS.
66  */
67 #define	MAC_BIBA_BIT_TEST(b, w) \
68 	((w)[(((b) - 1) >> 3)] & (1 << (((b) - 1) & 7)))
69 #define	MAC_BIBA_BIT_SET(b, w) \
70 	((w)[(((b) - 1) >> 3)] |= (1 << (((b) - 1) & 7)))
71 #define	MAC_BIBA_BIT_SET_EMPTY(set)	biba_bit_set_empty(set)
72 
73 #endif /* !_SYS_SECURITY_MAC_BIBA_H */
74