)]}'
{
  "commit": "50a5c4f6b9ea8046f90aefdffb8170d1ffb790cd",
  "tree": "289568954873cbea5b58f3d3a0b026670482e342",
  "parents": [
    "cff0a460ae864505bc2a064c269ebe548aa35949"
  ],
  "author": {
    "name": "thetruestblue",
    "email": "bblueconway@gmail.com",
    "time": "Thu Jan 30 15:55:15 2025 -0800"
  },
  "committer": {
    "name": "GitHub",
    "email": "noreply@github.com",
    "time": "Thu Jan 30 15:55:15 2025 -0800"
  },
  "message": "[Sanitizers][Apple] Fix logic bugs that break RestrictMemoryToMaxAddress (#124712)\n\nThere are two logic bugs breaking RestrictMemoryToMaxAddress.\r\n1. adding left_padding within MapDynamicShadow.\r\n- RoundUpTo((uptr)free_begin + left_padding, alignment) already adjusts\r\nfor left padding. Adding this additionally within MapDynamicShadow\r\ncauses us to allocate a page larger than necessary.\r\n- This incorrect calculation also means RestrictMemoryToMaxAddress will\r\nnever find a big enough gap.\r\n\r\n\r\n2. There is also an issue with the expectation of hitting\r\nKERN_INVALID_ADDRESS when we are beyond the addressable regions.\r\n- For most embedded scenarios, we exceed vm_max_address without getting\r\nKREN_INVALID_ADDRESS so we setting max_occupied_address to a memory\r\nregion the process doesn\u0027t have access to, beyond the max address, and\r\nthat space is never marked as available so we never find a valid gap in\r\nthose regions.\r\n- At some point previous it seems the assumption was once we were beyond\r\nthe Max address we could expect KREN_INVALID_ADDRESS, which is no longer\r\ntrue up through the extended space not given to most processes.\r\n- Because of this, the check` if (new_max_vm \u003c max_occupied_addr)` will\r\nalways fail and we will never restrict the address on smaller devices.\r\n- Additionally because of the extra page added by adding left_padding,\r\nand how we only minimally restrict the vm, there\u0027s a chance we restrict\r\nthe vm only enough for the correctly calculated size of shadow. In these\r\ncases, restricting the vm max address and will always fail due to the\r\nextra page added to space size.\r\n\r\ncredit to @delcypher for the left_padding diagnosis, remembered his old\r\nradar and PR when investigating this. https://reviews.llvm.org/D85389\r\n\r\nWill monitor closely for fall out.\r\n\r\nrdar://66603866",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "d15f30c61b586334f60e4c7a51aec2abb917c357",
      "old_mode": 33188,
      "old_path": "compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp",
      "new_id": "0b8a75391136df8f97d41d17c31102ecdca32dcd",
      "new_mode": 33188,
      "new_path": "compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp"
    }
  ]
}
