]>
Commit | Line | Data |
---|---|---|
2d21ac55 A |
1 | /* |
2 | * Copyright (c) 2006 Apple Computer, Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ | |
5 | * | |
6 | * This file contains Original Code and/or Modifications of Original Code | |
7 | * as defined in and that are subject to the Apple Public Source License | |
8 | * Version 2.0 (the 'License'). You may not use this file except in | |
9 | * compliance with the License. The rights granted to you under the License | |
10 | * may not be used to create, or enable the creation or redistribution of, | |
11 | * unlawful or unlicensed copies of an Apple operating system, or to | |
12 | * circumvent, violate, or enable the circumvention or violation of, any | |
13 | * terms of an Apple operating system software license agreement. | |
14 | * | |
15 | * Please obtain a copy of the License at | |
16 | * http://www.opensource.apple.com/apsl/ and read it before using this file. | |
17 | * | |
18 | * The Original Code and all software distributed under the License are | |
19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, | |
21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. | |
23 | * Please see the License for the specific language governing rights and | |
24 | * limitations under the License. | |
25 | * | |
26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ | |
27 | */ | |
28 | ||
29 | #ifndef _SYS_CODESIGN_H_ | |
30 | #define _SYS_CODESIGN_H_ | |
31 | ||
5ba3f43e A |
32 | #if KERNEL |
33 | #include <kern/cs_blobs.h> | |
34 | #else | |
35 | #include <System/kern/cs_blobs.h> | |
36 | #endif | |
2d21ac55 | 37 | |
c18c124e A |
38 | /* MAC flags used by F_ADDFILESIGS_* */ |
39 | #define MAC_VNODE_CHECK_DYLD_SIM 0x1 /* tells the MAC framework that dyld-sim is being loaded */ | |
40 | ||
2d21ac55 A |
41 | /* csops operations */ |
42 | #define CS_OPS_STATUS 0 /* return status */ | |
43 | #define CS_OPS_MARKINVALID 1 /* invalidate process */ | |
44 | #define CS_OPS_MARKHARD 2 /* set HARD flag */ | |
45 | #define CS_OPS_MARKKILL 3 /* set KILL flag (sticky) */ | |
39236c6e A |
46 | #ifdef KERNEL_PRIVATE |
47 | /* CS_OPS_PIDPATH 4 */ | |
48 | #endif | |
2d21ac55 | 49 | #define CS_OPS_CDHASH 5 /* get code directory hash */ |
b0d623f7 | 50 | #define CS_OPS_PIDOFFSET 6 /* get offset of active Mach-o slice */ |
6d2010ae A |
51 | #define CS_OPS_ENTITLEMENTS_BLOB 7 /* get entitlements blob */ |
52 | #define CS_OPS_MARKRESTRICT 8 /* set RESTRICT flag (sticky) */ | |
39236c6e A |
53 | #define CS_OPS_SET_STATUS 9 /* set codesign flags */ |
54 | #define CS_OPS_BLOB 10 /* get codesign blob */ | |
55 | #define CS_OPS_IDENTITY 11 /* get codesign identity */ | |
39037602 | 56 | #define CS_OPS_CLEARINSTALLER 12 /* clear INSTALLER flag */ |
5ba3f43e | 57 | #define CS_OPS_CLEARPLATFORM 13 /* clear platform binary status (DEVELOPMENT-only) */ |
39236c6e | 58 | |
5ba3f43e | 59 | #define CS_MAX_TEAMID_LEN 64 |
2d21ac55 A |
60 | |
61 | #ifndef KERNEL | |
62 | ||
39236c6e | 63 | #include <sys/types.h> |
fe8ab488 | 64 | #include <mach/message.h> |
2d21ac55 | 65 | |
39236c6e | 66 | __BEGIN_DECLS |
2d21ac55 A |
67 | /* code sign operations */ |
68 | int csops(pid_t pid, unsigned int ops, void * useraddr, size_t usersize); | |
316670eb | 69 | int csops_audittoken(pid_t pid, unsigned int ops, void * useraddr, size_t usersize, audit_token_t * token); |
39236c6e A |
70 | __END_DECLS |
71 | ||
72 | #else /* !KERNEL */ | |
73 | ||
39037602 A |
74 | #include <mach/vm_types.h> |
75 | ||
39236c6e | 76 | #include <sys/cdefs.h> |
fe8ab488 | 77 | #include <sys/_types/_off_t.h> |
39236c6e A |
78 | |
79 | struct vnode; | |
fe8ab488 A |
80 | struct cs_blob; |
81 | struct fileglob; | |
39236c6e | 82 | |
39236c6e | 83 | __BEGIN_DECLS |
39037602 | 84 | int cs_valid(struct proc *); |
39236c6e | 85 | int cs_enforcement(struct proc *); |
fe8ab488 | 86 | int cs_require_lv(struct proc *); |
39037602 | 87 | int cs_system_require_lv(void); |
fe8ab488 A |
88 | uint32_t cs_entitlement_flags(struct proc *p); |
89 | int cs_entitlements_blob_get(struct proc *, void **, size_t *); | |
3e170ce0 | 90 | int cs_restricted(struct proc *); |
39236c6e | 91 | uint8_t * cs_get_cdhash(struct proc *); |
2d21ac55 | 92 | |
3e170ce0 A |
93 | struct cs_blob * csproc_get_blob(struct proc *); |
94 | struct cs_blob * csvnode_get_blob(struct vnode *, off_t); | |
95 | void csvnode_print_debug(struct vnode *); | |
96 | ||
39037602 A |
97 | off_t csblob_get_base_offset(struct cs_blob *); |
98 | vm_size_t csblob_get_size(struct cs_blob *); | |
99 | vm_address_t csblob_get_addr(struct cs_blob *); | |
3e170ce0 A |
100 | const char * csblob_get_teamid(struct cs_blob *); |
101 | const char * csblob_get_identity(struct cs_blob *); | |
102 | const uint8_t * csblob_get_cdhash(struct cs_blob *); | |
39037602 | 103 | int csblob_get_platform_binary(struct cs_blob *); |
5ba3f43e A |
104 | unsigned int csblob_get_flags(struct cs_blob *); |
105 | uint8_t csblob_get_hashtype(struct cs_blob const *); | |
106 | unsigned int csblob_get_signer_type(struct cs_blob *); | |
107 | #if DEVELOPMENT || DEBUG | |
108 | void csproc_clear_platform_binary(struct proc *); | |
109 | #endif | |
39037602 | 110 | |
3e170ce0 | 111 | int csblob_get_entitlements(struct cs_blob *, void **, size_t *); |
39037602 | 112 | |
3e170ce0 A |
113 | const CS_GenericBlob * |
114 | csblob_find_blob(struct cs_blob *, uint32_t, uint32_t); | |
115 | const CS_GenericBlob * | |
116 | csblob_find_blob_bytes(const uint8_t *, size_t, uint32_t, uint32_t); | |
39037602 A |
117 | void * csblob_entitlements_dictionary_copy(struct cs_blob *csblob); |
118 | void csblob_entitlements_dictionary_set(struct cs_blob *csblob, void * entitlements); | |
3e170ce0 A |
119 | |
120 | /* | |
121 | * Mostly convenience functions below | |
122 | */ | |
fe8ab488 | 123 | |
fe8ab488 A |
124 | const char * csproc_get_teamid(struct proc *); |
125 | const char * csvnode_get_teamid(struct vnode *, off_t); | |
126 | int csproc_get_platform_binary(struct proc *); | |
743345f9 | 127 | int csproc_get_prod_signed(struct proc *); |
fe8ab488 A |
128 | const char * csfg_get_teamid(struct fileglob *); |
129 | int csfg_get_path(struct fileglob *, char *, int *); | |
130 | int csfg_get_platform_binary(struct fileglob *); | |
3e170ce0 | 131 | uint8_t * csfg_get_cdhash(struct fileglob *, uint64_t, size_t *); |
743345f9 | 132 | int csfg_get_prod_signed(struct fileglob *); |
5ba3f43e A |
133 | unsigned int csfg_get_signer_type(struct fileglob *); |
134 | unsigned int csproc_get_signer_type(struct proc *); | |
fe8ab488 | 135 | |
3e170ce0 | 136 | extern int cs_debug; |
2d21ac55 | 137 | |
39236c6e A |
138 | #ifdef XNU_KERNEL_PRIVATE |
139 | ||
140 | void cs_init(void); | |
141 | int cs_allow_invalid(struct proc *); | |
39037602 | 142 | int cs_invalid_page(addr64_t vaddr, boolean_t *cs_killed); |
3e170ce0 | 143 | int csproc_get_platform_path(struct proc *); |
39236c6e | 144 | |
39236c6e A |
145 | #if !SECURE_KERNEL |
146 | extern int cs_enforcement_panic; | |
147 | #endif | |
148 | ||
149 | #endif /* XNU_KERNEL_PRIVATE */ | |
150 | ||
3e170ce0 A |
151 | |
152 | __END_DECLS | |
153 | ||
154 | ||
155 | ||
39236c6e | 156 | #endif /* KERNEL */ |
2d21ac55 A |
157 | |
158 | #endif /* _SYS_CODESIGN_H_ */ |