Print this page
Code review comments from pmooney (sundry), and igork (screwups in zonecfg refactoring)


 298                 }
 299 
 300                 /*
 301                  * If randomization is requested, slew the allocation
 302                  * backwards, within the same gap, by a random amount.
 303                  */
 304                 if (flags & _MAP_RANDOMIZE) {
 305                         uint32_t slew;
 306                         uint32_t maxslew;
 307 
 308                         (void) random_get_pseudo_bytes((uint8_t *)&slew,
 309                             sizeof (slew));
 310 
 311                         maxslew = MIN(aslr_max_map_skew, (addr - base));
 312                         /*
 313                          * Don't allow ASLR to cause mappings to fail below
 314                          * because of SF erratum #57
 315                          */
 316                         maxslew = MIN(maxslew, (addr - errata57_limit));
 317 
 318                         slew = slew % MIN(MIN(aslr_max_map_skew, (addr - base)),
 319                             addr - errata57_limit);
 320                         addr -= P2ALIGN(slew, align_amount);
 321                 }
 322 
 323                 ASSERT(addr > base);
 324                 ASSERT(addr + len < base + slen);
 325                 ASSERT(((uintptr_t)addr & (align_amount - 1l)) ==
 326                     ((uintptr_t)(off)));
 327                 *addrp = addr;
 328 
 329 #if defined(SF_ERRATA_57)
 330                 if (AS_TYPE_64BIT(as) && addr < errata57_limit) {
 331                         *addrp = NULL;
 332                 }
 333 #endif
 334         } else {
 335                 *addrp = NULL;  /* no more virtual space */
 336         }
 337 }
 338 
 339 /*




 298                 }
 299 
 300                 /*
 301                  * If randomization is requested, slew the allocation
 302                  * backwards, within the same gap, by a random amount.
 303                  */
 304                 if (flags & _MAP_RANDOMIZE) {
 305                         uint32_t slew;
 306                         uint32_t maxslew;
 307 
 308                         (void) random_get_pseudo_bytes((uint8_t *)&slew,
 309                             sizeof (slew));
 310 
 311                         maxslew = MIN(aslr_max_map_skew, (addr - base));
 312                         /*
 313                          * Don't allow ASLR to cause mappings to fail below
 314                          * because of SF erratum #57
 315                          */
 316                         maxslew = MIN(maxslew, (addr - errata57_limit));
 317 
 318                         slew = slew % maxslew;

 319                         addr -= P2ALIGN(slew, align_amount);
 320                 }
 321 
 322                 ASSERT(addr > base);
 323                 ASSERT(addr + len < base + slen);
 324                 ASSERT(((uintptr_t)addr & (align_amount - 1l)) ==
 325                     ((uintptr_t)(off)));
 326                 *addrp = addr;
 327 
 328 #if defined(SF_ERRATA_57)
 329                 if (AS_TYPE_64BIT(as) && addr < errata57_limit) {
 330                         *addrp = NULL;
 331                 }
 332 #endif
 333         } else {
 334                 *addrp = NULL;  /* no more virtual space */
 335         }
 336 }
 337 
 338 /*