Skip to content

Comments

[EventPipe] Fix user_events metadata label scope#118474

Merged
mdh1418 merged 1 commit intodotnet:mainfrom
mdh1418:ep_fix_user_events_metadata_label
Aug 7, 2025
Merged

[EventPipe] Fix user_events metadata label scope#118474
mdh1418 merged 1 commit intodotnet:mainfrom
mdh1418:ep_fix_user_events_metadata_label

Conversation

@mdh1418
Copy link
Member

@mdh1418 mdh1418 commented Aug 7, 2025

Alternate internal testing showed that the first 5 bytes of the metadata extension were zeroed out. I missed that the stack allocated variable corresponding to the metadata label + metadata size would be out of scope during the writev, and thus prone to corruption.

The corruption never occurred during my manual testing which read the values from sys/kernel/tracing/trace.

@mdh1418 mdh1418 requested review from lateralusX and noahfalk August 7, 2025 02:00
@github-actions github-actions bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Aug 7, 2025
@mdh1418 mdh1418 marked this pull request as ready for review August 7, 2025 02:24
Copilot AI review requested due to automatic review settings August 7, 2025 02:24
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a critical memory corruption bug in the EventPipe session tracepoint writing functionality. The issue was caused by a stack-allocated variable going out of scope during a writev operation, leading to potential data corruption in the first 5 bytes of metadata extensions.

Key changes:

  • Move stack variable declaration to correct scope to prevent memory corruption
  • Ensure metadata extension buffer remains valid during writev system call

@mdh1418 mdh1418 merged commit 0bb2f6e into dotnet:main Aug 7, 2025
126 checks passed
@mdh1418 mdh1418 deleted the ep_fix_user_events_metadata_label branch August 11, 2025 21:30
@github-actions github-actions bot locked and limited conversation to collaborators Sep 11, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants