1*d4514f0bSApple OSS Distributions /*===---- ptrauth.h - Pointer authentication -------------------------------=== 2*d4514f0bSApple OSS Distributions * 3*d4514f0bSApple OSS Distributions * Permission is hereby granted, free of charge, to any person obtaining a copy 4*d4514f0bSApple OSS Distributions * of this software and associated documentation files (the "Software"), to deal 5*d4514f0bSApple OSS Distributions * in the Software without restriction, including without limitation the rights 6*d4514f0bSApple OSS Distributions * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7*d4514f0bSApple OSS Distributions * copies of the Software, and to permit persons to whom the Software is 8*d4514f0bSApple OSS Distributions * furnished to do so, subject to the following conditions: 9*d4514f0bSApple OSS Distributions * 10*d4514f0bSApple OSS Distributions * The above copyright notice and this permission notice shall be included in 11*d4514f0bSApple OSS Distributions * all copies or substantial portions of the Software. 12*d4514f0bSApple OSS Distributions * 13*d4514f0bSApple OSS Distributions * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14*d4514f0bSApple OSS Distributions * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15*d4514f0bSApple OSS Distributions * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16*d4514f0bSApple OSS Distributions * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17*d4514f0bSApple OSS Distributions * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18*d4514f0bSApple OSS Distributions * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19*d4514f0bSApple OSS Distributions * THE SOFTWARE. 20*d4514f0bSApple OSS Distributions * 21*d4514f0bSApple OSS Distributions *===-----------------------------------------------------------------------=== 22*d4514f0bSApple OSS Distributions */ 23*d4514f0bSApple OSS Distributions 24*d4514f0bSApple OSS Distributions #ifndef __PTRAUTH_H 25*d4514f0bSApple OSS Distributions #define __PTRAUTH_H 26*d4514f0bSApple OSS Distributions 27*d4514f0bSApple OSS Distributions #include <stdint.h> 28*d4514f0bSApple OSS Distributions 29*d4514f0bSApple OSS Distributions typedef enum { 30*d4514f0bSApple OSS Distributions ptrauth_key_asia = 0, 31*d4514f0bSApple OSS Distributions ptrauth_key_asib = 1, 32*d4514f0bSApple OSS Distributions ptrauth_key_asda = 2, 33*d4514f0bSApple OSS Distributions ptrauth_key_asdb = 3, 34*d4514f0bSApple OSS Distributions 35*d4514f0bSApple OSS Distributions /* A process-independent key which can be used to sign code pointers. 36*d4514f0bSApple OSS Distributions Signing and authenticating with this key is a no-op in processes 37*d4514f0bSApple OSS Distributions which disable ABI pointer authentication. */ 38*d4514f0bSApple OSS Distributions ptrauth_key_process_independent_code = ptrauth_key_asia, 39*d4514f0bSApple OSS Distributions 40*d4514f0bSApple OSS Distributions /* A process-specific key which can be used to sign code pointers. 41*d4514f0bSApple OSS Distributions Signing and authenticating with this key is enforced even in processes 42*d4514f0bSApple OSS Distributions which disable ABI pointer authentication. */ 43*d4514f0bSApple OSS Distributions ptrauth_key_process_dependent_code = ptrauth_key_asib, 44*d4514f0bSApple OSS Distributions 45*d4514f0bSApple OSS Distributions /* A process-independent key which can be used to sign data pointers. 46*d4514f0bSApple OSS Distributions Signing and authenticating with this key is a no-op in processes 47*d4514f0bSApple OSS Distributions which disable ABI pointer authentication. */ 48*d4514f0bSApple OSS Distributions ptrauth_key_process_independent_data = ptrauth_key_asda, 49*d4514f0bSApple OSS Distributions 50*d4514f0bSApple OSS Distributions /* A process-specific key which can be used to sign data pointers. 51*d4514f0bSApple OSS Distributions Signing and authenticating with this key is a no-op in processes 52*d4514f0bSApple OSS Distributions which disable ABI pointer authentication. */ 53*d4514f0bSApple OSS Distributions ptrauth_key_process_dependent_data = ptrauth_key_asdb, 54*d4514f0bSApple OSS Distributions 55*d4514f0bSApple OSS Distributions /* The key used to sign C function pointers. 56*d4514f0bSApple OSS Distributions The extra data is always 0. */ 57*d4514f0bSApple OSS Distributions ptrauth_key_function_pointer = ptrauth_key_process_independent_code, 58*d4514f0bSApple OSS Distributions 59*d4514f0bSApple OSS Distributions /* The key used to sign return addresses on the stack. 60*d4514f0bSApple OSS Distributions The extra data is based on the storage address of the return address. 61*d4514f0bSApple OSS Distributions On ARM64, that is always the storage address of the return address plus 8 62*d4514f0bSApple OSS Distributions (or, in other words, the value of the stack pointer on function entry) */ 63*d4514f0bSApple OSS Distributions ptrauth_key_return_address = ptrauth_key_process_dependent_code, 64*d4514f0bSApple OSS Distributions 65*d4514f0bSApple OSS Distributions /* The key used to sign frame pointers on the stack. 66*d4514f0bSApple OSS Distributions The extra data is based on the storage address of the frame pointer. 67*d4514f0bSApple OSS Distributions On ARM64, that is always the storage address of the frame pointer plus 16 68*d4514f0bSApple OSS Distributions (or, in other words, the value of the stack pointer on function entry) */ 69*d4514f0bSApple OSS Distributions ptrauth_key_frame_pointer = ptrauth_key_process_dependent_data, 70*d4514f0bSApple OSS Distributions 71*d4514f0bSApple OSS Distributions /* The key used to sign block function pointers, including: 72*d4514f0bSApple OSS Distributions invocation functions, 73*d4514f0bSApple OSS Distributions block object copy functions, 74*d4514f0bSApple OSS Distributions block object destroy functions, 75*d4514f0bSApple OSS Distributions __block variable copy functions, and 76*d4514f0bSApple OSS Distributions __block variable destroy functions. 77*d4514f0bSApple OSS Distributions The extra data is always the address at which the function pointer 78*d4514f0bSApple OSS Distributions is stored. 79*d4514f0bSApple OSS Distributions 80*d4514f0bSApple OSS Distributions Note that block object pointers themselves (i.e. the direct 81*d4514f0bSApple OSS Distributions representations of values of block-pointer type) are not signed. */ 82*d4514f0bSApple OSS Distributions ptrauth_key_block_function = ptrauth_key_asia, 83*d4514f0bSApple OSS Distributions 84*d4514f0bSApple OSS Distributions /* The key used to sign C++ v-table pointers. 85*d4514f0bSApple OSS Distributions The extra data is always 0. */ 86*d4514f0bSApple OSS Distributions ptrauth_key_cxx_vtable_pointer = ptrauth_key_asda, 87*d4514f0bSApple OSS Distributions 88*d4514f0bSApple OSS Distributions /* Other pointers signed under the ABI use private ABI rules. */ 89*d4514f0bSApple OSS Distributions 90*d4514f0bSApple OSS Distributions } ptrauth_key; 91*d4514f0bSApple OSS Distributions 92*d4514f0bSApple OSS Distributions /* An integer type of the appropriate size for an extra-data argument. */ 93*d4514f0bSApple OSS Distributions typedef uintptr_t ptrauth_extra_data_t; 94*d4514f0bSApple OSS Distributions 95*d4514f0bSApple OSS Distributions /* An integer type of the appropriate size for a generic signature. */ 96*d4514f0bSApple OSS Distributions typedef uintptr_t ptrauth_generic_signature_t; 97*d4514f0bSApple OSS Distributions 98*d4514f0bSApple OSS Distributions /* A signed pointer value embeds the original pointer together with 99*d4514f0bSApple OSS Distributions a signature that attests to the validity of that pointer. Because 100*d4514f0bSApple OSS Distributions this signature must use only "spare" bits of the pointer, a 101*d4514f0bSApple OSS Distributions signature's validity is probabilistic in practice: it is unlikely 102*d4514f0bSApple OSS Distributions but still plausible that an invalidly-derived signature will 103*d4514f0bSApple OSS Distributions somehow equal the correct signature and therefore successfully 104*d4514f0bSApple OSS Distributions authenticate. Nonetheless, this scheme provides a strong degree 105*d4514f0bSApple OSS Distributions of protection against certain kinds of attacks. */ 106*d4514f0bSApple OSS Distributions 107*d4514f0bSApple OSS Distributions /* Authenticating a pointer that was not signed with the given key 108*d4514f0bSApple OSS Distributions and extra-data value will (likely) fail. However, an 109*d4514f0bSApple OSS Distributions authentication failure will not lead immediately to a trap. 110*d4514f0bSApple OSS Distributions Instead, it will yield a value which is guaranteed to trap 111*d4514f0bSApple OSS Distributions if actually dereferenced. */ 112*d4514f0bSApple OSS Distributions 113*d4514f0bSApple OSS Distributions /* The null function pointer is always the all-zero bit pattern. 114*d4514f0bSApple OSS Distributions Signing an all-zero bit pattern will embed a (likely) non-zero 115*d4514f0bSApple OSS Distributions signature in the result, and so the result will not seem to be 116*d4514f0bSApple OSS Distributions a null function pointer. Authenticating this value will yield 117*d4514f0bSApple OSS Distributions a null function pointer back. However, authenticating an 118*d4514f0bSApple OSS Distributions all-zero bit pattern will probably fail, because the 119*d4514f0bSApple OSS Distributions authentication will expect a (likely) non-zero signature to 120*d4514f0bSApple OSS Distributions embedded in the value. 121*d4514f0bSApple OSS Distributions 122*d4514f0bSApple OSS Distributions Because of this, if a pointer may validly be null, you should 123*d4514f0bSApple OSS Distributions check for null before attempting to authenticate it. */ 124*d4514f0bSApple OSS Distributions 125*d4514f0bSApple OSS Distributions #ifdef __PTRAUTH_INTRINSICS__ 126*d4514f0bSApple OSS Distributions 127*d4514f0bSApple OSS Distributions /* Strip the signature from a value without authenticating it. 128*d4514f0bSApple OSS Distributions 129*d4514f0bSApple OSS Distributions If the value is a function pointer, the result will not be a 130*d4514f0bSApple OSS Distributions legal function pointer because of the missing signature, and 131*d4514f0bSApple OSS Distributions attempting to call it will result in an authentication failure. 132*d4514f0bSApple OSS Distributions 133*d4514f0bSApple OSS Distributions The value must be an expression of pointer type. 134*d4514f0bSApple OSS Distributions The key must be a constant expression of type ptrauth_key. 135*d4514f0bSApple OSS Distributions The result will have the same type as the original value. */ 136*d4514f0bSApple OSS Distributions #define ptrauth_strip(__value, __key) \ 137*d4514f0bSApple OSS Distributions __builtin_ptrauth_strip(__value, __key) 138*d4514f0bSApple OSS Distributions 139*d4514f0bSApple OSS Distributions /* Blend a pointer and a small integer to form a new extra-data 140*d4514f0bSApple OSS Distributions discriminator. Not all bits of the inputs are guaranteed to 141*d4514f0bSApple OSS Distributions contribute to the result. 142*d4514f0bSApple OSS Distributions 143*d4514f0bSApple OSS Distributions On ARM64, only the low 16 bits of the integer will be considered. 144*d4514f0bSApple OSS Distributions 145*d4514f0bSApple OSS Distributions For the purposes of ptrauth_sign_constant, the result of calling 146*d4514f0bSApple OSS Distributions this function is considered a constant expression if the arguments 147*d4514f0bSApple OSS Distributions are constant. Some restrictions may be imposed on the pointer. 148*d4514f0bSApple OSS Distributions 149*d4514f0bSApple OSS Distributions The first argument must be an expression of pointer type. 150*d4514f0bSApple OSS Distributions The second argument must be an expression of integer type. 151*d4514f0bSApple OSS Distributions The result will have type uintptr_t. */ 152*d4514f0bSApple OSS Distributions #define ptrauth_blend_discriminator(__pointer, __integer) \ 153*d4514f0bSApple OSS Distributions __builtin_ptrauth_blend_discriminator(__pointer, __integer) 154*d4514f0bSApple OSS Distributions 155*d4514f0bSApple OSS Distributions /* Compute the 16-bit integer discriminator of the given type. 156*d4514f0bSApple OSS Distributions 157*d4514f0bSApple OSS Distributions The argument must be a type. 158*d4514f0bSApple OSS Distributions */ 159*d4514f0bSApple OSS Distributions #if __has_builtin(__builtin_ptrauth_type_discriminator) 160*d4514f0bSApple OSS Distributions #define ptrauth_type_discriminator(__type) \ 161*d4514f0bSApple OSS Distributions __builtin_ptrauth_type_discriminator(__type) 162*d4514f0bSApple OSS Distributions #else 163*d4514f0bSApple OSS Distributions #define ptrauth_type_discriminator(__type) ((uintptr_t)0) 164*d4514f0bSApple OSS Distributions #endif 165*d4514f0bSApple OSS Distributions 166*d4514f0bSApple OSS Distributions /* Compute the constant discriminator used by Clang to sign pointers with the 167*d4514f0bSApple OSS Distributions given C function pointer type. 168*d4514f0bSApple OSS Distributions 169*d4514f0bSApple OSS Distributions A call to this function is an integer constant expression*/ 170*d4514f0bSApple OSS Distributions #if __has_feature(ptrauth_function_pointer_type_discrimination) 171*d4514f0bSApple OSS Distributions #define ptrauth_function_pointer_type_discriminator(__type) \ 172*d4514f0bSApple OSS Distributions __builtin_ptrauth_type_discriminator(__type) 173*d4514f0bSApple OSS Distributions #else 174*d4514f0bSApple OSS Distributions #define ptrauth_function_pointer_type_discriminator(__type) ((uintptr_t)0) 175*d4514f0bSApple OSS Distributions #endif 176*d4514f0bSApple OSS Distributions 177*d4514f0bSApple OSS Distributions /* Add a signature to the given pointer value using a specific key, 178*d4514f0bSApple OSS Distributions using the given extra data as a salt to the signing process. 179*d4514f0bSApple OSS Distributions 180*d4514f0bSApple OSS Distributions The value must be a constant expression of pointer type. 181*d4514f0bSApple OSS Distributions The key must be a constant expression of type ptrauth_key. 182*d4514f0bSApple OSS Distributions The extra data must be a constant expression of pointer or integer type; 183*d4514f0bSApple OSS Distributions if an integer, it will be coerced to ptrauth_extra_data_t. 184*d4514f0bSApple OSS Distributions The result will have the same type as the original value. 185*d4514f0bSApple OSS Distributions 186*d4514f0bSApple OSS Distributions This is a constant expression if the extra data is an integer or 187*d4514f0bSApple OSS Distributions null pointer constant. */ 188*d4514f0bSApple OSS Distributions #define ptrauth_sign_constant(__value, __key, __data) \ 189*d4514f0bSApple OSS Distributions __builtin_ptrauth_sign_constant(__value, __key, __data) 190*d4514f0bSApple OSS Distributions 191*d4514f0bSApple OSS Distributions /* Add a signature to the given pointer value using a specific key, 192*d4514f0bSApple OSS Distributions using the given extra data as a salt to the signing process. 193*d4514f0bSApple OSS Distributions 194*d4514f0bSApple OSS Distributions This operation does not authenticate the original value and is 195*d4514f0bSApple OSS Distributions therefore potentially insecure if an attacker could possibly 196*d4514f0bSApple OSS Distributions control that value. 197*d4514f0bSApple OSS Distributions 198*d4514f0bSApple OSS Distributions The value must be an expression of pointer type. 199*d4514f0bSApple OSS Distributions The key must be a constant expression of type ptrauth_key. 200*d4514f0bSApple OSS Distributions The extra data must be an expression of pointer or integer type; 201*d4514f0bSApple OSS Distributions if an integer, it will be coerced to ptrauth_extra_data_t. 202*d4514f0bSApple OSS Distributions The result will have the same type as the original value. */ 203*d4514f0bSApple OSS Distributions #define ptrauth_sign_unauthenticated(__value, __key, __data) \ 204*d4514f0bSApple OSS Distributions __builtin_ptrauth_sign_unauthenticated(__value, __key, __data) 205*d4514f0bSApple OSS Distributions 206*d4514f0bSApple OSS Distributions /* Authenticate a pointer using one scheme and resign it using another. 207*d4514f0bSApple OSS Distributions 208*d4514f0bSApple OSS Distributions If the result is subsequently authenticated using the new scheme, that 209*d4514f0bSApple OSS Distributions authentication is guaranteed to fail if and only if the initial 210*d4514f0bSApple OSS Distributions authentication failed. 211*d4514f0bSApple OSS Distributions 212*d4514f0bSApple OSS Distributions The value must be an expression of pointer type. 213*d4514f0bSApple OSS Distributions The key must be a constant expression of type ptrauth_key. 214*d4514f0bSApple OSS Distributions The extra data must be an expression of pointer or integer type; 215*d4514f0bSApple OSS Distributions if an integer, it will be coerced to ptrauth_extra_data_t. 216*d4514f0bSApple OSS Distributions The result will have the same type as the original value. 217*d4514f0bSApple OSS Distributions 218*d4514f0bSApple OSS Distributions This operation is guaranteed to not leave the intermediate value 219*d4514f0bSApple OSS Distributions available for attack before it is re-signed. 220*d4514f0bSApple OSS Distributions 221*d4514f0bSApple OSS Distributions Do not pass a null pointer to this function. A null pointer 222*d4514f0bSApple OSS Distributions will not successfully authenticate. */ 223*d4514f0bSApple OSS Distributions #define ptrauth_auth_and_resign(__value, __old_key, __old_data, __new_key, __new_data) \ 224*d4514f0bSApple OSS Distributions __builtin_ptrauth_auth_and_resign(__value, __old_key, __old_data, __new_key, __new_data) 225*d4514f0bSApple OSS Distributions 226*d4514f0bSApple OSS Distributions /* Authenticate a pointer using one scheme and resign it as a C 227*d4514f0bSApple OSS Distributions function pointer. 228*d4514f0bSApple OSS Distributions 229*d4514f0bSApple OSS Distributions If the result is subsequently authenticated using the new scheme, that 230*d4514f0bSApple OSS Distributions authentication is guaranteed to fail if and only if the initial 231*d4514f0bSApple OSS Distributions authentication failed. 232*d4514f0bSApple OSS Distributions 233*d4514f0bSApple OSS Distributions The value must be an expression of function pointer type. 234*d4514f0bSApple OSS Distributions The key must be a constant expression of type ptrauth_key. 235*d4514f0bSApple OSS Distributions The extra data must be an expression of pointer or integer type; 236*d4514f0bSApple OSS Distributions if an integer, it will be coerced to ptrauth_extra_data_t. 237*d4514f0bSApple OSS Distributions The result will have the same type as the original value. 238*d4514f0bSApple OSS Distributions 239*d4514f0bSApple OSS Distributions This operation is guaranteed to not leave the intermediate value 240*d4514f0bSApple OSS Distributions available for attack before it is re-signed. Additionally, if this 241*d4514f0bSApple OSS Distributions expression is used syntactically as the function expression in a 242*d4514f0bSApple OSS Distributions call, only a single authentication will be performed. */ 243*d4514f0bSApple OSS Distributions #define ptrauth_auth_function(__value, __old_key, __old_data) \ 244*d4514f0bSApple OSS Distributions ptrauth_auth_and_resign(__value, __old_key, __old_data, ptrauth_key_function_pointer, 0) 245*d4514f0bSApple OSS Distributions 246*d4514f0bSApple OSS Distributions /* Cast a pointer to the given type without changing any signature. 247*d4514f0bSApple OSS Distributions 248*d4514f0bSApple OSS Distributions The type must have the same size as a pointer type. 249*d4514f0bSApple OSS Distributions The type of value must have the same size as a pointer type, and will be 250*d4514f0bSApple OSS Distributions converted to an rvalue prior to the cast. 251*d4514f0bSApple OSS Distributions The result has type given by the first argument. 252*d4514f0bSApple OSS Distributions 253*d4514f0bSApple OSS Distributions The result has an identical bit-pattern to the input pointer. */ 254*d4514f0bSApple OSS Distributions #define ptrauth_nop_cast(__type, __value) \ 255*d4514f0bSApple OSS Distributions ({ union { \ 256*d4514f0bSApple OSS Distributions typeof(__value) __fptr; \ 257*d4514f0bSApple OSS Distributions typeof(__type) __opaque; \ 258*d4514f0bSApple OSS Distributions } __storage; \ 259*d4514f0bSApple OSS Distributions __storage.__fptr = (__value); \ 260*d4514f0bSApple OSS Distributions __storage.__opaque; }) 261*d4514f0bSApple OSS Distributions 262*d4514f0bSApple OSS Distributions /* Authenticate a data pointer. 263*d4514f0bSApple OSS Distributions 264*d4514f0bSApple OSS Distributions The value must be an expression of non-function pointer type. 265*d4514f0bSApple OSS Distributions The key must be a constant expression of type ptrauth_key. 266*d4514f0bSApple OSS Distributions The extra data must be an expression of pointer or integer type; 267*d4514f0bSApple OSS Distributions if an integer, it will be coerced to ptrauth_extra_data_t. 268*d4514f0bSApple OSS Distributions The result will have the same type as the original value. 269*d4514f0bSApple OSS Distributions 270*d4514f0bSApple OSS Distributions If the authentication fails, dereferencing the resulting pointer 271*d4514f0bSApple OSS Distributions will fail. */ 272*d4514f0bSApple OSS Distributions #define ptrauth_auth_data(__value, __old_key, __old_data) \ 273*d4514f0bSApple OSS Distributions __builtin_ptrauth_auth(__value, __old_key, __old_data) 274*d4514f0bSApple OSS Distributions 275*d4514f0bSApple OSS Distributions /* Return an extra-discriminator value which can validly be used 276*d4514f0bSApple OSS Distributions as the second argument to ptrauth_blend_discriminator or the 277*d4514f0bSApple OSS Distributions third argument to the __ptrauth qualifier. 278*d4514f0bSApple OSS Distributions 279*d4514f0bSApple OSS Distributions The argument must be a string literal. 280*d4514f0bSApple OSS Distributions A call to this function is an integer constant expression. */ 281*d4514f0bSApple OSS Distributions #define ptrauth_string_discriminator(__string) \ 282*d4514f0bSApple OSS Distributions __builtin_ptrauth_string_discriminator(__string) 283*d4514f0bSApple OSS Distributions 284*d4514f0bSApple OSS Distributions /* Compute a full pointer-width generic signature for the given 285*d4514f0bSApple OSS Distributions value, using the given data as a salt. 286*d4514f0bSApple OSS Distributions 287*d4514f0bSApple OSS Distributions This generic signature is process-independent, but may not be 288*d4514f0bSApple OSS Distributions consistent across reboots. 289*d4514f0bSApple OSS Distributions 290*d4514f0bSApple OSS Distributions This can be used to validate the integrity of arbitrary data 291*d4514f0bSApple OSS Distributions by storing a signature for that data together with it. Because 292*d4514f0bSApple OSS Distributions the signature is pointer-sized, if the stored signature matches 293*d4514f0bSApple OSS Distributions the result of re-signing the current data, a match provides very 294*d4514f0bSApple OSS Distributions strong evidence that the data has not been corrupted. 295*d4514f0bSApple OSS Distributions 296*d4514f0bSApple OSS Distributions The value must be an expression of pointer or integer type; if 297*d4514f0bSApple OSS Distributions an integer, it will be coerced to uintptr_t. 298*d4514f0bSApple OSS Distributions The extra data must be an expression of pointer or integer type; 299*d4514f0bSApple OSS Distributions if an integer, it will be coerced to ptrauth_extra_data_t. 300*d4514f0bSApple OSS Distributions The result will have type ptrauth_generic_signature_t. 301*d4514f0bSApple OSS Distributions 302*d4514f0bSApple OSS Distributions This operation will compute a meaningful signature even in processes 303*d4514f0bSApple OSS Distributions which disable ABI pointer authentication. */ 304*d4514f0bSApple OSS Distributions #define ptrauth_sign_generic_data(__value, __data) \ 305*d4514f0bSApple OSS Distributions __builtin_ptrauth_sign_generic_data(__value, __data) 306*d4514f0bSApple OSS Distributions 307*d4514f0bSApple OSS Distributions 308*d4514f0bSApple OSS Distributions /* Define some standard __ptrauth qualifiers used in the ABI. */ 309*d4514f0bSApple OSS Distributions #define __ptrauth_function_pointer \ 310*d4514f0bSApple OSS Distributions __ptrauth(ptrauth_key_function_pointer,0,0) 311*d4514f0bSApple OSS Distributions #define __ptrauth_return_address \ 312*d4514f0bSApple OSS Distributions __ptrauth(ptrauth_key_return_address,1,0) 313*d4514f0bSApple OSS Distributions #define __ptrauth_block_invocation_pointer \ 314*d4514f0bSApple OSS Distributions __ptrauth(ptrauth_key_function_pointer,1,0) 315*d4514f0bSApple OSS Distributions #define __ptrauth_block_copy_helper \ 316*d4514f0bSApple OSS Distributions __ptrauth(ptrauth_key_function_pointer,1,0) 317*d4514f0bSApple OSS Distributions #define __ptrauth_block_destroy_helper \ 318*d4514f0bSApple OSS Distributions __ptrauth(ptrauth_key_function_pointer,1,0) 319*d4514f0bSApple OSS Distributions #define __ptrauth_block_byref_copy_helper \ 320*d4514f0bSApple OSS Distributions __ptrauth(ptrauth_key_function_pointer,1,0) 321*d4514f0bSApple OSS Distributions #define __ptrauth_block_byref_destroy_helper \ 322*d4514f0bSApple OSS Distributions __ptrauth(ptrauth_key_function_pointer,1,0) 323*d4514f0bSApple OSS Distributions #define __ptrauth_objc_method_list_imp \ 324*d4514f0bSApple OSS Distributions __ptrauth(ptrauth_key_function_pointer,1,0) 325*d4514f0bSApple OSS Distributions #define __ptrauth_cxx_vtable_pointer \ 326*d4514f0bSApple OSS Distributions __ptrauth(ptrauth_key_cxx_vtable_pointer,0,0) 327*d4514f0bSApple OSS Distributions #define __ptrauth_cxx_vtt_vtable_pointer \ 328*d4514f0bSApple OSS Distributions __ptrauth(ptrauth_key_cxx_vtable_pointer,0,0) 329*d4514f0bSApple OSS Distributions #define __ptrauth_swift_heap_object_destructor \ 330*d4514f0bSApple OSS Distributions __ptrauth(ptrauth_key_function_pointer,1,0xbbbf) 331*d4514f0bSApple OSS Distributions 332*d4514f0bSApple OSS Distributions /* Some situations in the C++ and Swift ABIs use declaration-specific 333*d4514f0bSApple OSS Distributions or type-specific extra discriminators. */ 334*d4514f0bSApple OSS Distributions #define __ptrauth_cxx_virtual_function_pointer(__declkey) \ 335*d4514f0bSApple OSS Distributions __ptrauth(ptrauth_key_function_pointer,1,__declkey) 336*d4514f0bSApple OSS Distributions #define __ptrauth_swift_function_pointer(__typekey) \ 337*d4514f0bSApple OSS Distributions __ptrauth(ptrauth_key_function_pointer,0,__typekey) 338*d4514f0bSApple OSS Distributions #define __ptrauth_swift_class_method_pointer(__declkey) \ 339*d4514f0bSApple OSS Distributions __ptrauth(ptrauth_key_function_pointer,1,__declkey) 340*d4514f0bSApple OSS Distributions #define __ptrauth_swift_protocol_witness_function_pointer(__declkey) \ 341*d4514f0bSApple OSS Distributions __ptrauth(ptrauth_key_function_pointer,1,__declkey) 342*d4514f0bSApple OSS Distributions #define __ptrauth_swift_value_witness_function_pointer(__key) \ 343*d4514f0bSApple OSS Distributions __ptrauth(ptrauth_key_function_pointer,1,__key) 344*d4514f0bSApple OSS Distributions 345*d4514f0bSApple OSS Distributions #else 346*d4514f0bSApple OSS Distributions 347*d4514f0bSApple OSS Distributions #define ptrauth_strip(__value, __key) ({ (void)__key; __value; }) 348*d4514f0bSApple OSS Distributions #define ptrauth_blend_discriminator(__pointer, __integer) ({ (void)__pointer; (void)__integer; (uintptr_t)0; }) 349*d4514f0bSApple OSS Distributions #define ptrauth_type_discriminator(__type) ((uintptr_t)0) 350*d4514f0bSApple OSS Distributions #define ptrauth_function_pointer_type_discriminator(__type) ((uintptr_t)0) 351*d4514f0bSApple OSS Distributions #define ptrauth_sign_constant(__value, __key, __data) ({ (void)__key; (void)__data; __value; }) 352*d4514f0bSApple OSS Distributions #define ptrauth_sign_unauthenticated(__value, __key, __data) ({ (void)__key; (void)__data; __value; }) 353*d4514f0bSApple OSS Distributions #define ptrauth_auth_and_resign(__value, __old_key, __old_data, __new_key, __new_data) ({ \ 354*d4514f0bSApple OSS Distributions (void)__old_key; \ 355*d4514f0bSApple OSS Distributions (void)__old_data; \ 356*d4514f0bSApple OSS Distributions (void)__new_key; \ 357*d4514f0bSApple OSS Distributions (void)__new_data; \ 358*d4514f0bSApple OSS Distributions __value; }) 359*d4514f0bSApple OSS Distributions #define ptrauth_auth_function(__value, __old_key, __old_data) ({ (void)__old_key; (void)__old_data; __value; }) 360*d4514f0bSApple OSS Distributions #define ptrauth_nop_cast(__type, __value) ((__type)__value) 361*d4514f0bSApple OSS Distributions #define ptrauth_auth_data(__value, __old_key, __old_data) ({ (void)__old_key; (void)__old_data; __value; }) 362*d4514f0bSApple OSS Distributions #define ptrauth_string_discriminator(__string) ({ (void)__string; (int)0; }) 363*d4514f0bSApple OSS Distributions #define ptrauth_sign_generic_data(__value, __data) ({ (void)__value; (void)__data; (ptrauth_generic_signature_t)0; }) 364*d4514f0bSApple OSS Distributions 365*d4514f0bSApple OSS Distributions #define __ptrauth_function_pointer 366*d4514f0bSApple OSS Distributions #define __ptrauth_return_address 367*d4514f0bSApple OSS Distributions #define __ptrauth_block_invocation_pointer 368*d4514f0bSApple OSS Distributions #define __ptrauth_block_copy_helper 369*d4514f0bSApple OSS Distributions #define __ptrauth_block_destroy_helper 370*d4514f0bSApple OSS Distributions #define __ptrauth_block_byref_copy_helper 371*d4514f0bSApple OSS Distributions #define __ptrauth_block_byref_destroy_helper 372*d4514f0bSApple OSS Distributions #define __ptrauth_objc_method_list_imp 373*d4514f0bSApple OSS Distributions #define __ptrauth_cxx_vtable_pointer 374*d4514f0bSApple OSS Distributions #define __ptrauth_cxx_vtt_vtable_pointer 375*d4514f0bSApple OSS Distributions #define __ptrauth_swift_heap_object_destructor 376*d4514f0bSApple OSS Distributions #define __ptrauth_cxx_virtual_function_pointer(__declkey) 377*d4514f0bSApple OSS Distributions #define __ptrauth_swift_function_pointer(__typekey) 378*d4514f0bSApple OSS Distributions #define __ptrauth_swift_class_method_pointer(__declkey) 379*d4514f0bSApple OSS Distributions #define __ptrauth_swift_protocol_witness_function_pointer(__declkey) 380*d4514f0bSApple OSS Distributions #define __ptrauth_swift_value_witness_function_pointer(__key) 381*d4514f0bSApple OSS Distributions 382*d4514f0bSApple OSS Distributions #endif /* __PTRAUTH_INTRINSICS__ */ 383*d4514f0bSApple OSS Distributions 384*d4514f0bSApple OSS Distributions #endif /* __PTRAUTH_H */ 385