Skip to content

Fix stack buffer overflow in macOS mach_smi collector - #22553

Merged
ilyam8 merged 1 commit into
netdata:masterfrom
artem:fix-overflow
May 25, 2026
Merged

Fix stack buffer overflow in macOS mach_smi collector#22553
ilyam8 merged 1 commit into
netdata:masterfrom
artem:fix-overflow

Conversation

@artem

@artem artem commented May 24, 2026

Copy link
Copy Markdown
Contributor
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_smi collector by passing the correct element count to the VM stats APIs. This prevents crashes and memory corruption during RAM/swap/page-fault collection.

  • Bug Fixes
    • Use HOST_VM_INFO64_COUNT and HOST_VM_INFO_COUNT instead of sizeof(...) when calling host_statistics64/host_statistics.

Written for commit 96e162c. Summary will update on new commits. Review in cubic

@artem
artem requested a review from thiagoftsm as a code owner May 24, 2026 00:34
@CLAassistant

CLAassistant commented May 24, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@github-actions github-actions Bot added area/collectors Everything related to data collection collectors/macos labels May 24, 2026

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Re-trigger cubic

@sonarqubecloud

Copy link
Copy Markdown

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) with HOST_VM_INFO64_COUNT for the host_statistics64 call.
  • Replace sizeof(vm_statistics_data_t) with HOST_VM_INFO_COUNT for the legacy host_statistics call.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ilyam8
ilyam8 enabled auto-merge (squash) May 25, 2026 08:19
@ilyam8
ilyam8 merged commit 64ceb9c into netdata:master May 25, 2026
152 of 158 checks passed
@ilyam8

ilyam8 commented May 25, 2026

Copy link
Copy Markdown
Member

@artem, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/collectors Everything related to data collection collectors/macos

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Stack buffer overflow crash in do_macos_mach_smi on Apple Silicon

5 participants