xref: /freebsd/sys/security/mac_lomac/mac_lomac.h (revision c66ec88fed842fbaad62c30d510644ceb7bd2d71)
1 /*-
2  * Copyright (c) 1999-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  *
22  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
23  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
26  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32  * SUCH DAMAGE.
33  *
34  * $FreeBSD$
35  */
36 /*
37  * Definitions for the TrustedBSD LOMAC integrity policy module.
38  */
39 #ifndef _SYS_SECURITY_MAC_LOMAC_H
40 #define	_SYS_SECURITY_MAC_LOMAC_H
41 
42 #define	MAC_LOMAC_EXTATTR_NAMESPACE	EXTATTR_NAMESPACE_SYSTEM
43 #define	MAC_LOMAC_EXTATTR_NAME		"mac_lomac"
44 
45 #define	MAC_LOMAC_LABEL_NAME		"lomac"
46 
47 #define	MAC_LOMAC_FLAG_SINGLE	0x00000001	/* ml_single initialized */
48 #define	MAC_LOMAC_FLAG_RANGE	0x00000002	/* ml_range* initialized */
49 #define	MAC_LOMAC_FLAG_AUX	0x00000004	/* ml_auxsingle initialized */
50 #define	MAC_LOMAC_FLAGS_BOTH	(MAC_LOMAC_FLAG_SINGLE | MAC_LOMAC_FLAG_RANGE)
51 #define	MAC_LOMAC_FLAG_UPDATE	0x00000008	/* must demote this process */
52 
53 #define	MAC_LOMAC_TYPE_UNDEF	0	/* Undefined */
54 #define	MAC_LOMAC_TYPE_GRADE	1	/* Hierarchal grade with mb_grade. */
55 #define	MAC_LOMAC_TYPE_LOW	2	/* Dominated by any
56 					 * MAC_LOMAC_TYPE_LABEL. */
57 #define	MAC_LOMAC_TYPE_HIGH	3	/* Dominates any
58 					 * MAC_LOMAC_TYPE_LABEL. */
59 #define	MAC_LOMAC_TYPE_EQUAL	4	/* Equivalent to any
60 					 * MAC_LOMAC_TYPE_LABEL. */
61 
62 /*
63  * Structures and constants associated with a LOMAC Integrity policy.
64  * mac_lomac represents a LOMAC label, with mb_type determining its properties,
65  * and mb_grade represents the hierarchal grade if valid for the current
66  * mb_type.
67  */
68 
69 struct mac_lomac_element {
70 	u_short	mle_type;
71 	u_short	mle_grade;
72 };
73 
74 /*
75  * LOMAC labels start with two components: a single label, and a label
76  * range.  Depending on the context, one or both may be used; the ml_flags
77  * field permits the provider to indicate what fields are intended for
78  * use.  The auxiliary label works the same way, but is only valid on
79  * filesystem objects to provide inheritance semantics on directories
80  * and "non-demoting" execution on executable files.
81  */
82 struct mac_lomac {
83 	int				ml_flags;
84 	struct mac_lomac_element	ml_single;
85 	struct mac_lomac_element	ml_rangelow, ml_rangehigh;
86 	struct mac_lomac_element	ml_auxsingle;
87 };
88 
89 #endif /* !_SYS_SECURITY_MAC_LOMAC_H */
90