Fix stack buffer overflow in macOS mach_smi collector - #22553
Conversation
|
|
|
There was a problem hiding this comment.
Pull request overview
Fixes a stack buffer overflow crash in the macOS mach_smi collector by passing the correct element count (Mach _COUNT macros, expressed in mach_msg_type_number_t units of 4 bytes) to host_statistics64/host_statistics, instead of sizeof(...) which overstates the buffer by 4x and triggers the stack canary on return.
Changes:
- Replace
sizeof(vm_statistics64_data_t)withHOST_VM_INFO64_COUNTfor thehost_statistics64call. - Replace
sizeof(vm_statistics_data_t)withHOST_VM_INFO_COUNTfor the legacyhost_statisticscall.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@artem, thanks! |
(cherry picked from commit 64ceb9c)



Summary
Fix stack buffer overflow in macOS mach_smi collector
Fixes #22552
Test Plan
Additional Information
For users: How does this change affect me?
Summary by cubic
Fixed a stack buffer overflow in the macOS
mach_smicollector by passing the correct element count to the VM stats APIs. This prevents crashes and memory corruption during RAM/swap/page-fault collection.HOST_VM_INFO64_COUNTandHOST_VM_INFO_COUNTinstead ofsizeof(...)when callinghost_statistics64/host_statistics.Written for commit 96e162c. Summary will update on new commits. Review in cubic