1*4d495c6eSApple OSS Distributions# Guard-object allocation policy 2*4d495c6eSApple OSS Distributions 3*4d495c6eSApple OSS DistributionsThe contemporary techniques we use to group and protect smaller allocations, 4*4d495c6eSApple OSS Distributionssuch as zalloc and kalloc_type, are premised around type-isolation and VA 5*4d495c6eSApple OSS Distributionssequestering. These techniques are impractical for larger allocations because 6*4d495c6eSApple OSS Distributionsthey consume outsized chunks of virtual address space, and could lead to 7*4d495c6eSApple OSS Distributionsexhaustion. We therefore use a different strategy for larger allocations, which 8*4d495c6eSApple OSS Distributionswe call guard objects. 9*4d495c6eSApple OSS Distributions 10*4d495c6eSApple OSS Distributions 11*4d495c6eSApple OSS Distributions## Algorithm 12*4d495c6eSApple OSS Distributions 13*4d495c6eSApple OSS DistributionsAllocation policies are assigned to particular regions of kernel address space. 14*4d495c6eSApple OSS DistributionsThe strategy specified by this document is used by regions such as the various 15*4d495c6eSApple OSS Distributionspointer ranges of `kmem_alloc()`, which previously used a first-fit allocator. 16*4d495c6eSApple OSS DistributionsUnder the guard-objects policy, the virtual address space is divided in 17*4d495c6eSApple OSS Distributions*chunks*. A chunk has a size class of the form $2^k \times \mathtt{PAGE\_SIZE}$, 18*4d495c6eSApple OSS Distributionsand is made of $\mathcal{S}$ *slots* of that size. $\mathcal{S}$ varies with the 19*4d495c6eSApple OSS Distributionssize class: smaller size-classes will have more slots, and larger size classes 20*4d495c6eSApple OSS Distributionswill have fewer. Chunks are also configured to have $\mathcal{G}$ _guards_ and 21*4d495c6eSApple OSS Distributionsup to $\mathcal{Q}$ _quarantines_. 22*4d495c6eSApple OSS Distributions 23*4d495c6eSApple OSS DistributionsChunks maintain several other important pieces of information, such as: 24*4d495c6eSApple OSS Distributions 25*4d495c6eSApple OSS Distributions* which slots are allocated and which slots are free; 26*4d495c6eSApple OSS Distributions* a dynamic count of quarantined slots within $[0, \mathcal{Q})$; 27*4d495c6eSApple OSS Distributions* a count of *available* slots, which are the number of free slots in excess 28*4d495c6eSApple OSS Distributions of guards $\mathcal{G}$ and the number of currently quarantined slots. 29*4d495c6eSApple OSS Distributions 30*4d495c6eSApple OSS DistributionsA chunk can be in three states: *empty* if all its slots are free, *partial* if 31*4d495c6eSApple OSS Distributionsit has at least one available slot, *full* if it has no available slots. Chunks 32*4d495c6eSApple OSS Distributionsare maintained in lists segregated by size class and state. 33*4d495c6eSApple OSS Distributions 34*4d495c6eSApple OSS Distributions### Allocating memory 35*4d495c6eSApple OSS Distributions 36*4d495c6eSApple OSS DistributionsMemory requests for a given size are rounded up to the next size class of the 37*4d495c6eSApple OSS Distributionsform $2^k$. The allocator must first select an appropriate chunk. Partial chunks 38*4d495c6eSApple OSS Distributionsare preferred, and if no partial chunk exists, an empty chunk is allocated from 39*4d495c6eSApple OSS Distributionsunused virtual address space. 40*4d495c6eSApple OSS Distributions 41*4d495c6eSApple OSS DistributionsA random slot is then chosen from any of the free slots in that chunk, and the 42*4d495c6eSApple OSS Distributionsavailable count of the chunk is decremented. If the chunk has now exhausted its 43*4d495c6eSApple OSS Distributionsavailable slots — only quarantined slots and guards are left — it's placed on 44*4d495c6eSApple OSS Distributionsits corresponding size class's full list. 45*4d495c6eSApple OSS Distributions 46*4d495c6eSApple OSS DistributionsVisually, let’s consider an example with two partial chunks A and B, with 8 47*4d495c6eSApple OSS Distributionsslots each, for $\mathcal{G} = \mathcal{Q} = 2$: 48*4d495c6eSApple OSS Distributions 49*4d495c6eSApple OSS Distributions``` 50*4d495c6eSApple OSS Distributions A───────────────┬─┬─┬─┬─┐ B───────────────┬─┬─┬─┬─┐ 51*4d495c6eSApple OSS Distributions │ Available: 1 │X│ │ │X│ │ Available: 4 │ │ │X│ │ 52*4d495c6eSApple OSS Distributions ┌─▶│ Quarantine: 0 ├─┼─┼─┼─┤────▶│ Quarantine: 0 ├─┼─┼─┼─┤ 53*4d495c6eSApple OSS Distributions┌─────────┐ │ │ Guards: 2 │X│X│X│ │ │ Guards: 2 │ │X│ │ │ 54*4d495c6eSApple OSS Distributions│ partial │──┘ └───────────────┴─┴─┴─┴─┘ └───────────────┴─┴─┴─┴─┘ 55*4d495c6eSApple OSS Distributions├─────────┤ 56*4d495c6eSApple OSS Distributions│ full │ 57*4d495c6eSApple OSS Distributions└─────────┘ 58*4d495c6eSApple OSS Distributions 59*4d495c6eSApple OSS DistributionsLegend: 60*4d495c6eSApple OSS Distributions┌─┐ ┌─┐ 61*4d495c6eSApple OSS Distributions│ │ free slot │X│ allocated slot 62*4d495c6eSApple OSS Distributions└─┘ └─┘ 63*4d495c6eSApple OSS Distributions``` 64*4d495c6eSApple OSS Distributions 65*4d495c6eSApple OSS DistributionsThe first allocation will be performed from chunk A, using its last available 66*4d495c6eSApple OSS Distributionsslot and moving it to the full list: 67*4d495c6eSApple OSS Distributions 68*4d495c6eSApple OSS Distributions``` 69*4d495c6eSApple OSS Distributions B───────────────┬─┬─┬─┬─┐ 70*4d495c6eSApple OSS Distributions │ Available: 4 │ │ │X│ │ 71*4d495c6eSApple OSS Distributions ┌─▶│ Quarantine: 0 ├─┼─┼─┼─┤ 72*4d495c6eSApple OSS Distributions┌─────────┐ │ │ Guards: 2 │ │X│ │ │ 73*4d495c6eSApple OSS Distributions│ partial │──┘ └───────────────┴─┴─┴─┴─┘ 74*4d495c6eSApple OSS Distributions├─────────┤ 75*4d495c6eSApple OSS Distributions│ full │──┐ A───────────────┬─┬─┬─┬─┐ 76*4d495c6eSApple OSS Distributions└─────────┘ │ │ Available: 0 │X│ │X│X│ 77*4d495c6eSApple OSS Distributions └─▶│ Quarantine: 0 ├─┼─┼─┼─┤ 78*4d495c6eSApple OSS Distributions │ Guards: 2 │X│X│X│ │ 79*4d495c6eSApple OSS Distributions └───────────────┴─┴─┴─┴─┘ 80*4d495c6eSApple OSS Distributions``` 81*4d495c6eSApple OSS Distributions 82*4d495c6eSApple OSS DistributionsWhen the next allocation request in this size class arrives, the allocator will 83*4d495c6eSApple OSS Distributionsselect B because A is now full: 84*4d495c6eSApple OSS Distributions 85*4d495c6eSApple OSS Distributions``` 86*4d495c6eSApple OSS Distributions B───────────────┬─┬─┬─┬─┐ 87*4d495c6eSApple OSS Distributions │ Available: 3 │ │ │X│ │ 88*4d495c6eSApple OSS Distributions ┌─▶│ Quarantine: 0 ├─┼─┼─┼─┤ 89*4d495c6eSApple OSS Distributions┌─────────┐ │ │ Guards: 2 │ │X│X│ │ 90*4d495c6eSApple OSS Distributions│ partial │──┘ └───────────────┴─┴─┴─┴─┘ 91*4d495c6eSApple OSS Distributions├─────────┤ 92*4d495c6eSApple OSS Distributions│ full │──┐ A───────────────┬─┬─┬─┬─┐ 93*4d495c6eSApple OSS Distributions└─────────┘ │ │ Available: 0 │X│ │X│X│ 94*4d495c6eSApple OSS Distributions └─▶│ Quarantine: 0 ├─┼─┼─┼─┤ 95*4d495c6eSApple OSS Distributions │ Guards: 2 │X│X│X│ │ 96*4d495c6eSApple OSS Distributions └───────────────┴─┴─┴─┴─┘ 97*4d495c6eSApple OSS Distributions``` 98*4d495c6eSApple OSS Distributions 99*4d495c6eSApple OSS Distributions### Deallocating memory 100*4d495c6eSApple OSS Distributions 101*4d495c6eSApple OSS DistributionsDeallocating a virtual memory range works in reverse. First, we evaluate which 102*4d495c6eSApple OSS Distributionschunk and slot correspond to the range being freed. Since the semantics of the 103*4d495c6eSApple OSS Distributionsvirtual memory subsystem mandate that we must support partial deallocations, we 104*4d495c6eSApple OSS Distributionsnext consider whether the slot has become only partially free. If so, we have 105*4d495c6eSApple OSS Distributionsnothing more to do for now; the slot remains in use. 106*4d495c6eSApple OSS Distributions 107*4d495c6eSApple OSS DistributionsIf however the slot is now entirely free, then the quarantine count of the chunk 108*4d495c6eSApple OSS Distributionsis incremented. If at least $\mathcal{G} + \mathcal{Q}$ are free, then the 109*4d495c6eSApple OSS Distributionsquarantine is cleared. The idea behind this policy is that maintaining a good 110*4d495c6eSApple OSS Distributionsentropy requires enough free slots to choose from. As a result, once the free 111*4d495c6eSApple OSS Distributionsslot count dips below $\mathcal{G} + \mathcal{Q}$, freed slots are quarantined 112*4d495c6eSApple OSS Distributionsrather than made immediately available. 113*4d495c6eSApple OSS Distributions 114*4d495c6eSApple OSS DistributionsFinally, we evaluate whether the chunk needs to be moved: 115*4d495c6eSApple OSS Distributions 116*4d495c6eSApple OSS Distributions* if a chunk's slots are all fully free, the chunk is marked as empty, and is 117*4d495c6eSApple OSS Distributions typically returned to the system as free space; 118*4d495c6eSApple OSS Distributions* if the chunk previously had no slots available, but has any available now, 119*4d495c6eSApple OSS Distributions the chunk is moved to the partially-free chunks list. 120*4d495c6eSApple OSS Distributions 121*4d495c6eSApple OSS DistributionsVisually, let’s consider an example with a chunk using 16 slots, 122*4d495c6eSApple OSS Distributionsunder a configuration in which $\mathcal{G} = \mathcal{Q} = 4$: 123*4d495c6eSApple OSS Distributions 124*4d495c6eSApple OSS Distributions``` 125*4d495c6eSApple OSS Distributions A───────────────┬─┬─┬─┬─┬─┬─┬─┬─┐ 126*4d495c6eSApple OSS Distributions┌─────────┐ │ Available: 1 │ │X│X│X│ │ │X│ │ 127*4d495c6eSApple OSS Distributions│ partial │─────▶│ Quarantine: 1 ├─┼─┼─┼─┼─┼─┼─┼─┤ 128*4d495c6eSApple OSS Distributions├─────────┤ │ Guards: 4 │ │X│X│X│X│X│ │X│ 129*4d495c6eSApple OSS Distributions│ full │ └───────────────┴─┴─┴─┴─┴─┴─┴─┴─┘ 130*4d495c6eSApple OSS Distributions└─────────┘ 131*4d495c6eSApple OSS Distributions 132*4d495c6eSApple OSS DistributionsLegend: 133*4d495c6eSApple OSS Distributions┌─┐ ┌─┐ 134*4d495c6eSApple OSS Distributions│ │ free slot │X│ allocated slot 135*4d495c6eSApple OSS Distributions└─┘ └─┘ 136*4d495c6eSApple OSS Distributions``` 137*4d495c6eSApple OSS Distributions 138*4d495c6eSApple OSS DistributionsIf we now free an element, its slot is marked free, and the quarantine count 139*4d495c6eSApple OSS Distributionsis increased: 140*4d495c6eSApple OSS Distributions 141*4d495c6eSApple OSS Distributions``` 142*4d495c6eSApple OSS Distributions A───────────────┬─┬─┬─┬─┬─┬─┬─┬─┐ 143*4d495c6eSApple OSS Distributions┌─────────┐ │ Available: 1 │ │X│X│X│ │ │X│ │ 144*4d495c6eSApple OSS Distributions│ partial │─────▶│ Quarantine: 2 ├─┼─┼─┼─┼─┼─┼─┼─┤ 145*4d495c6eSApple OSS Distributions├─────────┤ │ Guards: 4 │ │X│X│ │X│X│ │X│ 146*4d495c6eSApple OSS Distributions│ full │ └───────────────┴─┴─┴─┴─┴─┴─┴─┴─┘ 147*4d495c6eSApple OSS Distributions└─────────┘ 148*4d495c6eSApple OSS Distributions``` 149*4d495c6eSApple OSS Distributions 150*4d495c6eSApple OSS DistributionsIf we allocate the last available element, a slot is now marked used, 151*4d495c6eSApple OSS Distributionsthe available count drops to 0, and causes the chunk to now be full, 152*4d495c6eSApple OSS Distributionsand the quarantine stays untouched: 153*4d495c6eSApple OSS Distributions 154*4d495c6eSApple OSS Distributions``` 155*4d495c6eSApple OSS Distributions┌─────────┐ 156*4d495c6eSApple OSS Distributions│ partial │ A───────────────┬─┬─┬─┬─┬─┬─┬─┬─┐ 157*4d495c6eSApple OSS Distributions├─────────┤ │ Available: 0 │X│X│X│X│ │ │X│ │ 158*4d495c6eSApple OSS Distributions│ full │─────▶│ Quarantine: 2 ├─┼─┼─┼─┼─┼─┼─┼─┤ 159*4d495c6eSApple OSS Distributions└─────────┘ │ Guards: 4 │ │X│X│ │X│X│ │X│ 160*4d495c6eSApple OSS Distributions └───────────────┴─┴─┴─┴─┴─┴─┴─┴─┘ 161*4d495c6eSApple OSS Distributions``` 162*4d495c6eSApple OSS Distributions 163*4d495c6eSApple OSS DistributionsFreeing just one element would return just one slot, and bump the quarantine 164*4d495c6eSApple OSS Distributionscount to 3. It takes freeing two elements for more than $\mathcal{G} + 165*4d495c6eSApple OSS Distributions\mathcal{Q}$ slots to be free, leading to clearing the quarantine: 166*4d495c6eSApple OSS Distributions 167*4d495c6eSApple OSS Distributions``` 168*4d495c6eSApple OSS Distributions A───────────────┬─┬─┬─┬─┬─┬─┬─┬─┐ 169*4d495c6eSApple OSS Distributions┌─────────┐ │ Available: 4 │X│X│X│X│ │ │X│ │ 170*4d495c6eSApple OSS Distributions│ partial │─────▶│ Quarantine: 0 ├─┼─┼─┼─┼─┼─┼─┼─┤ 171*4d495c6eSApple OSS Distributions├─────────┤ │ Guards: 4 │ │X│X│ │ │ │ │X│ 172*4d495c6eSApple OSS Distributions│ full │ └───────────────┴─┴─┴─┴─┴─┴─┴─┴─┘ 173*4d495c6eSApple OSS Distributions└─────────┘ 174*4d495c6eSApple OSS Distributions``` 175*4d495c6eSApple OSS Distributions 176*4d495c6eSApple OSS Distributions### Operation clamping to a slot 177*4d495c6eSApple OSS Distributions 178*4d495c6eSApple OSS DistributionsAs long as a VM operation does not exceed slot bounds, any VM call is permitted, 179*4d495c6eSApple OSS Distributionswhether it is configuration altering calls such as `vm_protect()` or 180*4d495c6eSApple OSS Distributions`vm_inherit()`, taking copies of the range with `mach_make_memory_entry()`, or 181*4d495c6eSApple OSS Distributionsreplacing part of the mapping with `vm_allocate(..., VM_FLAGS_FIXED | 182*4d495c6eSApple OSS DistributionsVM_FLAGS_OVERWRITE)`. 183*4d495c6eSApple OSS Distributions 184*4d495c6eSApple OSS DistributionsHowever, operations that cross a slot boundary are not permitted, and lead to 185*4d495c6eSApple OSS Distributionstermination. When guard object policies are in effect, allocations are 186*4d495c6eSApple OSS Distributionsrandomized, and even in a single threaded context, clients can't assume that 187*4d495c6eSApple OSS Distributionsconsecutive allocations will be served in address order, and as a result, 188*4d495c6eSApple OSS Distributionsoperations crossing slot boundaries are always bugs. 189*4d495c6eSApple OSS Distributions 190*4d495c6eSApple OSS Distributions 191*4d495c6eSApple OSS Distributions## Security motivation 192*4d495c6eSApple OSS Distributions 193*4d495c6eSApple OSS DistributionsWith the algorithm explanation, the “guard object” moniker should start to make 194*4d495c6eSApple OSS Distributionssense: the goal is that unused free slots are object-sized guards — in the 195*4d495c6eSApple OSS Distributionsguard-page sense. Unlike usage of traditional guard pages, which only protect 196*4d495c6eSApple OSS Distributionsagainst linear buffer overflows, this scheme also adds a probabilistic 197*4d495c6eSApple OSS Distributionsmitigation against use-after-free or non-linear buffer overflows, forcing 198*4d495c6eSApple OSS Distributionsattackers to contend with a high probability of hitting these guards. 199*4d495c6eSApple OSS Distributions 200*4d495c6eSApple OSS DistributionsDue to visible timing differences, it is assumed that an attacker can observe 201*4d495c6eSApple OSS Distributionswhen a chunk is being allocated or freed. However, this doesn't give them an 202*4d495c6eSApple OSS Distributionsedge because the system maintains a guarantee that at least 203*4d495c6eSApple OSS Distributions$\mathcal{G}/\mathcal{S}$ of the address space causes a crash when accessed at 204*4d495c6eSApple OSS Distributionsany given time. This is why we can let go of any form of sequestering of the 205*4d495c6eSApple OSS Distributionsaddress space for ranges managed with the guard-object allocation policy. 206*4d495c6eSApple OSS Distributions 207*4d495c6eSApple OSS Distributions### Use-after-Free exploitation strategies and failure rates 208*4d495c6eSApple OSS Distributions 209*4d495c6eSApple OSS DistributionsAttackers attempting to exploit a use-after-free will be able to cause an 210*4d495c6eSApple OSS Distributionselement to be freed, knowing that a dangling pointer to it remains. They will 211*4d495c6eSApple OSS Distributionsthen try to replace this freed element with another one of a different type 212*4d495c6eSApple OSS Distributionsthat they control, creating a type confusion. 213*4d495c6eSApple OSS Distributions 214*4d495c6eSApple OSS DistributionsBecause allocating new chunks causes visible timing differences, we can assume 215*4d495c6eSApple OSS Distributionsthat attackers are able to fill chunks with all slots corresponding to elements 216*4d495c6eSApple OSS Distributionsthat they control. They also know which elements are in the same chunk, but 217*4d495c6eSApple OSS Distributionsdon't know which element corresponds to which slot. 218*4d495c6eSApple OSS Distributions 219*4d495c6eSApple OSS Distributions**In the absence of the quarantine**, the best strategy for attackers trying to 220*4d495c6eSApple OSS Distributionsexploit a use-after free is to perform $\mathcal{S} − \mathcal{G}$ rounds 221*4d495c6eSApple OSS Distributionsof freeing then reallocating each element in the chunk, where the first free is 222*4d495c6eSApple OSS Distributionsto the element they are trying to use-after-free, so that they retain a dangling 223*4d495c6eSApple OSS Distributionspointer to the original slot. Each round, the allocator will choose one slot 224*4d495c6eSApple OSS Distributionsamong $\mathcal{G} + 1$, when only one corresponds to the slot that was freed by 225*4d495c6eSApple OSS Distributionstriggering the bug. The failure rate the attackers face with this strategy is 226*4d495c6eSApple OSS Distributions 227*4d495c6eSApple OSS Distributions$$failure\_rate = \left( 228*4d495c6eSApple OSS Distributions\frac{\mathcal{G}}{\mathcal{G+1}}\right)^{\mathcal{S} - \mathcal{G}}$$ 229*4d495c6eSApple OSS Distributions 230*4d495c6eSApple OSS Distributions* $\mathcal{S} = 8, \mathcal{G} = 2$ yields a 8.8% failure rate; 231*4d495c6eSApple OSS Distributions* $\mathcal{S} = 16, \mathcal{G} = 4$ yields a 6.9 failure rate. 232*4d495c6eSApple OSS Distributions 233*4d495c6eSApple OSS Distributions**Using the quarantine** further reduces an attacker's odds of success. Unlike 234*4d495c6eSApple OSS Distributionsbefore, they need to free at least $\mathcal{Q}$ elements before elements are 235*4d495c6eSApple OSS Distributionsmade available for allocations again. As a result, a round now needs to be 236*4d495c6eSApple OSS Distributions$\mathcal{Q}$ deallocations followed by $\mathcal{Q}$ allocations. As before, 237*4d495c6eSApple OSS Distributionsthe very first deallocation is to the element the attacker tries to 238*4d495c6eSApple OSS Distributionsuse-after-free. A round gives attackers $\frac{\mathcal{G}}{ 239*4d495c6eSApple OSS Distributions\mathcal{G}+\mathcal{Q}}$ chances of failure. The aggregate failure rate for 240*4d495c6eSApple OSS Distributionsthis strategy is 241*4d495c6eSApple OSS Distributions 242*4d495c6eSApple OSS Distributions$$failure\_rate =\left( 1 - \frac{(\mathcal{S} - \mathcal{G)} \bmod \mathcal{Q} 243*4d495c6eSApple OSS Distributions}{\mathcal{G} + \mathcal{Q}} \right) 244*4d495c6eSApple OSS Distributions\left(\frac{\mathcal{G}}{\mathcal{G} + \mathcal{Q}}\right)^{ 245*4d495c6eSApple OSS Distributions\left\lfloor \frac{\mathcal{S} -\mathcal{G}}{\mathcal{Q}} \right\rfloor}$$ 246*4d495c6eSApple OSS Distributions 247*4d495c6eSApple OSS Distributions* $\mathcal{S}=8, \mathcal{G}=1, \mathcal{Q}=4$ yields a 8% failure rate; 248*4d495c6eSApple OSS Distributions* $\mathcal{S}=8, \mathcal{G}=2, \mathcal{Q}=2$ yields a 12.5% failure rate; 249*4d495c6eSApple OSS Distributions* $\mathcal{S}=16, \mathcal{G}=4, \mathcal{Q}=3$ yields a 10.7% failure rate; 250*4d495c6eSApple OSS Distributions* $\mathcal{S}=16, \mathcal{G}=4, \mathcal{Q}=4$ yields a 12.5% failure rate. 251*4d495c6eSApple OSS Distributions 252*4d495c6eSApple OSS Distributions### Out-of-bound exploitation strategies 253*4d495c6eSApple OSS Distributions 254*4d495c6eSApple OSS DistributionsExploiting out-of-bound bugs requires knowing the distance between allocated 255*4d495c6eSApple OSS Distributionsobjects, which an attacker a priori doesn’t know without some information leak. 256*4d495c6eSApple OSS DistributionsThe regions protected by guard objects are coarsely randomized in the address 257*4d495c6eSApple OSS Distributionsspace, so that attackers can’t predict how far an allocation is from other juicy 258*4d495c6eSApple OSS Distributionsexploitation targets in the address space such as the `__DATA` segment. Lastly, 259*4d495c6eSApple OSS Distributionsguard objects are combined in XNU with type isolation and allocation fronts. It 260*4d495c6eSApple OSS Distributionsmakes cross-type attacks unreliable and unpredictable — as the various buckets 261*4d495c6eSApple OSS Distributionsof types are randomized per boot. 262*4d495c6eSApple OSS Distributions 263*4d495c6eSApple OSS DistributionsThe last remaining avenue of attack targets types that fall in the same 264*4d495c6eSApple OSS Distributionsallocation front. However, attackers still have to contend with the uniform 265*4d495c6eSApple OSS Distributions$\mathcal{G}/\mathcal{S}$ density of holes, making out-of-bound unreliable with 266*4d495c6eSApple OSS Distributionsa probability of failure close to $\mathcal{G}/\mathcal{S}$. This probability of 267*4d495c6eSApple OSS Distributionsfailure is typically worse than use-after-free for attackers, and intuitively, 268*4d495c6eSApple OSS Distributionsthis is precisely because they need to know more information — the distance 269*4d495c6eSApple OSS Distributionsbetween objects — unlike use-after-free where that distance is obviously known 270*4d495c6eSApple OSS Distributionsto be zero. 271*4d495c6eSApple OSS Distributions 272*4d495c6eSApple OSS Distributions### Choice of parameters 273*4d495c6eSApple OSS Distributions 274*4d495c6eSApple OSS DistributionsIn the actual implementation, $\mathcal{S}$ scales up with the size of the 275*4d495c6eSApple OSS Distributionsallocations going up — as a way to limit the amount of metadata needed. 276*4d495c6eSApple OSS DistributionsMaintaining the $\mathcal{G}/\mathcal{S}$ and $\mathcal{Q}/\mathcal{S}$ ratios 277*4d495c6eSApple OSS Distributionsconstant for any $\mathcal{S}$ allows for all probabilities to become 278*4d495c6eSApple OSS Distributionsindependent of $\mathcal{S}$. 279*4d495c6eSApple OSS Distributions 280*4d495c6eSApple OSS DistributionsOur goal is to make attackers face at least 10% chance of failure — in the 281*4d495c6eSApple OSS Distributionsabsence of information disclosure — which is why we chose numbers where 282*4d495c6eSApple OSS Distributions$\mathcal{G} = \mathcal{Q} = \mathcal{S}/4$, yielding: 283*4d495c6eSApple OSS Distributions 284*4d495c6eSApple OSS Distributions* 25% failure rates for out-of-bound exploitation; 285*4d495c6eSApple OSS Distributions* 12.5% failure rates for use-after-free exploitation. 286*4d495c6eSApple OSS Distributions 287