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