xref: /illumos-gate/usr/src/uts/common/xen/public/xsm/acm.h (revision 55fea89dcaa64928bed4327112404dcb3e07b79f)
1*349b53ddSStuart Maybee /*
2*349b53ddSStuart Maybee  * acm.h: Xen access control module interface defintions
3*349b53ddSStuart Maybee  *
4*349b53ddSStuart Maybee  * Permission is hereby granted, free of charge, to any person obtaining a copy
5*349b53ddSStuart Maybee  * of this software and associated documentation files (the "Software"), to
6*349b53ddSStuart Maybee  * deal in the Software without restriction, including without limitation the
7*349b53ddSStuart Maybee  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8*349b53ddSStuart Maybee  * sell copies of the Software, and to permit persons to whom the Software is
9*349b53ddSStuart Maybee  * furnished to do so, subject to the following conditions:
10*349b53ddSStuart Maybee  *
11*349b53ddSStuart Maybee  * The above copyright notice and this permission notice shall be included in
12*349b53ddSStuart Maybee  * all copies or substantial portions of the Software.
13*349b53ddSStuart Maybee  *
14*349b53ddSStuart Maybee  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15*349b53ddSStuart Maybee  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16*349b53ddSStuart Maybee  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17*349b53ddSStuart Maybee  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18*349b53ddSStuart Maybee  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19*349b53ddSStuart Maybee  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20*349b53ddSStuart Maybee  * DEALINGS IN THE SOFTWARE.
21*349b53ddSStuart Maybee  *
22*349b53ddSStuart Maybee  * Reiner Sailer <sailer@watson.ibm.com>
23*349b53ddSStuart Maybee  * Copyright (c) 2005, International Business Machines Corporation.
24*349b53ddSStuart Maybee  */
25*349b53ddSStuart Maybee 
26*349b53ddSStuart Maybee #ifndef _XEN_PUBLIC_ACM_H
27*349b53ddSStuart Maybee #define _XEN_PUBLIC_ACM_H
28*349b53ddSStuart Maybee 
29*349b53ddSStuart Maybee #include "../xen.h"
30*349b53ddSStuart Maybee 
31*349b53ddSStuart Maybee /* default ssid reference value if not supplied */
32*349b53ddSStuart Maybee #define ACM_DEFAULT_SSID  0x0
33*349b53ddSStuart Maybee #define ACM_DEFAULT_LOCAL_SSID  0x0
34*349b53ddSStuart Maybee 
35*349b53ddSStuart Maybee /* Internal ACM ERROR types */
36*349b53ddSStuart Maybee #define ACM_OK     0
37*349b53ddSStuart Maybee #define ACM_UNDEF   -1
38*349b53ddSStuart Maybee #define ACM_INIT_SSID_ERROR  -2
39*349b53ddSStuart Maybee #define ACM_INIT_SOID_ERROR  -3
40*349b53ddSStuart Maybee #define ACM_ERROR          -4
41*349b53ddSStuart Maybee 
42*349b53ddSStuart Maybee /* External ACCESS DECISIONS */
43*349b53ddSStuart Maybee #define ACM_ACCESS_PERMITTED        0
44*349b53ddSStuart Maybee #define ACM_ACCESS_DENIED           -111
45*349b53ddSStuart Maybee #define ACM_NULL_POINTER_ERROR      -200
46*349b53ddSStuart Maybee 
47*349b53ddSStuart Maybee /*
48*349b53ddSStuart Maybee    Error codes reported in when trying to test for a new policy
49*349b53ddSStuart Maybee    These error codes are reported in an array of tuples where
50*349b53ddSStuart Maybee    each error code is followed by a parameter describing the error
51*349b53ddSStuart Maybee    more closely, such as a domain id.
52*349b53ddSStuart Maybee */
53*349b53ddSStuart Maybee #define ACM_EVTCHN_SHARING_VIOLATION       0x100
54*349b53ddSStuart Maybee #define ACM_GNTTAB_SHARING_VIOLATION       0x101
55*349b53ddSStuart Maybee #define ACM_DOMAIN_LOOKUP                  0x102
56*349b53ddSStuart Maybee #define ACM_CHWALL_CONFLICT                0x103
57*349b53ddSStuart Maybee #define ACM_SSIDREF_IN_USE                 0x104
58*349b53ddSStuart Maybee 
59*349b53ddSStuart Maybee 
60*349b53ddSStuart Maybee /* primary policy in lower 4 bits */
61*349b53ddSStuart Maybee #define ACM_NULL_POLICY 0
62*349b53ddSStuart Maybee #define ACM_CHINESE_WALL_POLICY 1
63*349b53ddSStuart Maybee #define ACM_SIMPLE_TYPE_ENFORCEMENT_POLICY 2
64*349b53ddSStuart Maybee #define ACM_POLICY_UNDEFINED 15
65*349b53ddSStuart Maybee 
66*349b53ddSStuart Maybee /* combinations have secondary policy component in higher 4bit */
67*349b53ddSStuart Maybee #define ACM_CHINESE_WALL_AND_SIMPLE_TYPE_ENFORCEMENT_POLICY \
68*349b53ddSStuart Maybee     ((ACM_SIMPLE_TYPE_ENFORCEMENT_POLICY << 4) | ACM_CHINESE_WALL_POLICY)
69*349b53ddSStuart Maybee 
70*349b53ddSStuart Maybee /* policy: */
71*349b53ddSStuart Maybee #define ACM_POLICY_NAME(X) \
72*349b53ddSStuart Maybee  ((X) == (ACM_NULL_POLICY)) ? "NULL" :                        \
73*349b53ddSStuart Maybee     ((X) == (ACM_CHINESE_WALL_POLICY)) ? "CHINESE WALL" :        \
74*349b53ddSStuart Maybee     ((X) == (ACM_SIMPLE_TYPE_ENFORCEMENT_POLICY)) ? "SIMPLE TYPE ENFORCEMENT" : \
75*349b53ddSStuart Maybee     ((X) == (ACM_CHINESE_WALL_AND_SIMPLE_TYPE_ENFORCEMENT_POLICY)) ? "CHINESE WALL AND SIMPLE TYPE ENFORCEMENT" : \
76*349b53ddSStuart Maybee      "UNDEFINED"
77*349b53ddSStuart Maybee 
78*349b53ddSStuart Maybee /* the following policy versions must be increased
79*349b53ddSStuart Maybee  * whenever the interpretation of the related
80*349b53ddSStuart Maybee  * policy's data structure changes
81*349b53ddSStuart Maybee  */
82*349b53ddSStuart Maybee #define ACM_POLICY_VERSION 4
83*349b53ddSStuart Maybee #define ACM_CHWALL_VERSION 1
84*349b53ddSStuart Maybee #define ACM_STE_VERSION  1
85*349b53ddSStuart Maybee 
86*349b53ddSStuart Maybee /* defines a ssid reference used by xen */
87*349b53ddSStuart Maybee typedef uint32_t ssidref_t;
88*349b53ddSStuart Maybee 
89*349b53ddSStuart Maybee /* hooks that are known to domains */
90*349b53ddSStuart Maybee #define ACMHOOK_none          0
91*349b53ddSStuart Maybee #define ACMHOOK_sharing       1
92*349b53ddSStuart Maybee #define ACMHOOK_authorization 2
93*349b53ddSStuart Maybee #define ACMHOOK_conflictset   3
94*349b53ddSStuart Maybee 
95*349b53ddSStuart Maybee /* -------security policy relevant type definitions-------- */
96*349b53ddSStuart Maybee 
97*349b53ddSStuart Maybee /* type identifier; compares to "equal" or "not equal" */
98*349b53ddSStuart Maybee typedef uint16_t domaintype_t;
99*349b53ddSStuart Maybee 
100*349b53ddSStuart Maybee /* CHINESE WALL POLICY DATA STRUCTURES
101*349b53ddSStuart Maybee  *
102*349b53ddSStuart Maybee  * current accumulated conflict type set:
103*349b53ddSStuart Maybee  * When a domain is started and has a type that is in
104*349b53ddSStuart Maybee  * a conflict set, the conflicting types are incremented in
105*349b53ddSStuart Maybee  * the aggregate set. When a domain is destroyed, the
106*349b53ddSStuart Maybee  * conflicting types to its type are decremented.
107*349b53ddSStuart Maybee  * If a domain has multiple types, this procedure works over
108*349b53ddSStuart Maybee  * all those types.
109*349b53ddSStuart Maybee  *
110*349b53ddSStuart Maybee  * conflict_aggregate_set[i] holds the number of
111*349b53ddSStuart Maybee  *   running domains that have a conflict with type i.
112*349b53ddSStuart Maybee  *
113*349b53ddSStuart Maybee  * running_types[i] holds the number of running domains
114*349b53ddSStuart Maybee  *        that include type i in their ssidref-referenced type set
115*349b53ddSStuart Maybee  *
116*349b53ddSStuart Maybee  * conflict_sets[i][j] is "0" if type j has no conflict
117*349b53ddSStuart Maybee  *    with type i and is "1" otherwise.
118*349b53ddSStuart Maybee  */
119*349b53ddSStuart Maybee /* high-16 = version, low-16 = check magic */
120*349b53ddSStuart Maybee #define ACM_MAGIC  0x0001debc
121*349b53ddSStuart Maybee 
122*349b53ddSStuart Maybee /* size of the SHA1 hash identifying the XML policy from which the
123*349b53ddSStuart Maybee    binary policy was created */
124*349b53ddSStuart Maybee #define ACM_SHA1_HASH_SIZE    20
125*349b53ddSStuart Maybee 
126*349b53ddSStuart Maybee /* each offset in bytes from start of the struct they
127*349b53ddSStuart Maybee  * are part of */
128*349b53ddSStuart Maybee 
129*349b53ddSStuart Maybee /* V3 of the policy buffer aded a version structure */
130*349b53ddSStuart Maybee struct acm_policy_version
131*349b53ddSStuart Maybee {
132*349b53ddSStuart Maybee     uint32_t major;
133*349b53ddSStuart Maybee     uint32_t minor;
134*349b53ddSStuart Maybee };
135*349b53ddSStuart Maybee 
136*349b53ddSStuart Maybee 
137*349b53ddSStuart Maybee /* each buffer consists of all policy information for
138*349b53ddSStuart Maybee  * the respective policy given in the policy code
139*349b53ddSStuart Maybee  *
140*349b53ddSStuart Maybee  * acm_policy_buffer, acm_chwall_policy_buffer,
141*349b53ddSStuart Maybee  * and acm_ste_policy_buffer need to stay 32-bit aligned
142*349b53ddSStuart Maybee  * because we create binary policies also with external
143*349b53ddSStuart Maybee  * tools that assume packed representations (e.g. the java tool)
144*349b53ddSStuart Maybee  */
145*349b53ddSStuart Maybee struct acm_policy_buffer {
146*349b53ddSStuart Maybee     uint32_t magic;
147*349b53ddSStuart Maybee     uint32_t policy_version; /* ACM_POLICY_VERSION */
148*349b53ddSStuart Maybee     uint32_t len;
149*349b53ddSStuart Maybee     uint32_t policy_reference_offset;
150*349b53ddSStuart Maybee     uint32_t primary_policy_code;
151*349b53ddSStuart Maybee     uint32_t primary_buffer_offset;
152*349b53ddSStuart Maybee     uint32_t secondary_policy_code;
153*349b53ddSStuart Maybee     uint32_t secondary_buffer_offset;
154*349b53ddSStuart Maybee     struct acm_policy_version xml_pol_version; /* add in V3 */
155*349b53ddSStuart Maybee     uint8_t xml_policy_hash[ACM_SHA1_HASH_SIZE]; /* added in V4 */
156*349b53ddSStuart Maybee };
157*349b53ddSStuart Maybee 
158*349b53ddSStuart Maybee 
159*349b53ddSStuart Maybee struct acm_policy_reference_buffer {
160*349b53ddSStuart Maybee     uint32_t len;
161*349b53ddSStuart Maybee };
162*349b53ddSStuart Maybee 
163*349b53ddSStuart Maybee struct acm_chwall_policy_buffer {
164*349b53ddSStuart Maybee     uint32_t policy_version; /* ACM_CHWALL_VERSION */
165*349b53ddSStuart Maybee     uint32_t policy_code;
166*349b53ddSStuart Maybee     uint32_t chwall_max_types;
167*349b53ddSStuart Maybee     uint32_t chwall_max_ssidrefs;
168*349b53ddSStuart Maybee     uint32_t chwall_max_conflictsets;
169*349b53ddSStuart Maybee     uint32_t chwall_ssid_offset;
170*349b53ddSStuart Maybee     uint32_t chwall_conflict_sets_offset;
171*349b53ddSStuart Maybee     uint32_t chwall_running_types_offset;
172*349b53ddSStuart Maybee     uint32_t chwall_conflict_aggregate_offset;
173*349b53ddSStuart Maybee };
174*349b53ddSStuart Maybee 
175*349b53ddSStuart Maybee struct acm_ste_policy_buffer {
176*349b53ddSStuart Maybee     uint32_t policy_version; /* ACM_STE_VERSION */
177*349b53ddSStuart Maybee     uint32_t policy_code;
178*349b53ddSStuart Maybee     uint32_t ste_max_types;
179*349b53ddSStuart Maybee     uint32_t ste_max_ssidrefs;
180*349b53ddSStuart Maybee     uint32_t ste_ssid_offset;
181*349b53ddSStuart Maybee };
182*349b53ddSStuart Maybee 
183*349b53ddSStuart Maybee struct acm_stats_buffer {
184*349b53ddSStuart Maybee     uint32_t magic;
185*349b53ddSStuart Maybee     uint32_t len;
186*349b53ddSStuart Maybee     uint32_t primary_policy_code;
187*349b53ddSStuart Maybee     uint32_t primary_stats_offset;
188*349b53ddSStuart Maybee     uint32_t secondary_policy_code;
189*349b53ddSStuart Maybee     uint32_t secondary_stats_offset;
190*349b53ddSStuart Maybee };
191*349b53ddSStuart Maybee 
192*349b53ddSStuart Maybee struct acm_ste_stats_buffer {
193*349b53ddSStuart Maybee     uint32_t ec_eval_count;
194*349b53ddSStuart Maybee     uint32_t gt_eval_count;
195*349b53ddSStuart Maybee     uint32_t ec_denied_count;
196*349b53ddSStuart Maybee     uint32_t gt_denied_count;
197*349b53ddSStuart Maybee     uint32_t ec_cachehit_count;
198*349b53ddSStuart Maybee     uint32_t gt_cachehit_count;
199*349b53ddSStuart Maybee };
200*349b53ddSStuart Maybee 
201*349b53ddSStuart Maybee struct acm_ssid_buffer {
202*349b53ddSStuart Maybee     uint32_t len;
203*349b53ddSStuart Maybee     ssidref_t ssidref;
204*349b53ddSStuart Maybee     uint32_t policy_reference_offset;
205*349b53ddSStuart Maybee     uint32_t primary_policy_code;
206*349b53ddSStuart Maybee     uint32_t primary_max_types;
207*349b53ddSStuart Maybee     uint32_t primary_types_offset;
208*349b53ddSStuart Maybee     uint32_t secondary_policy_code;
209*349b53ddSStuart Maybee     uint32_t secondary_max_types;
210*349b53ddSStuart Maybee     uint32_t secondary_types_offset;
211*349b53ddSStuart Maybee };
212*349b53ddSStuart Maybee 
213*349b53ddSStuart Maybee #endif
214*349b53ddSStuart Maybee 
215*349b53ddSStuart Maybee /*
216*349b53ddSStuart Maybee  * Local variables:
217*349b53ddSStuart Maybee  * mode: C
218*349b53ddSStuart Maybee  * c-set-style: "BSD"
219*349b53ddSStuart Maybee  * c-basic-offset: 4
220*349b53ddSStuart Maybee  * tab-width: 4
221*349b53ddSStuart Maybee  * indent-tabs-mode: nil
222*349b53ddSStuart Maybee  * End:
223*349b53ddSStuart Maybee  */
224