Skip to content

Bound process name buffer in crash dump handler#40274

Merged
benhillis merged 1 commit intomasterfrom
crashdump-bound-buffer
Apr 22, 2026
Merged

Bound process name buffer in crash dump handler#40274
benhillis merged 1 commit intomasterfrom
crashdump-bound-buffer

Conversation

@benhillis
Copy link
Copy Markdown
Member

CollectCrashDumps casts the LX_PROCESS_CRASH flexible array member Buffer to const char* without verifying NUL-termination. If the buffer is not NUL-terminated (e.g. a truncated or malformed message), this could read past the intended bounds.

This PR:

  • Uses the response span from Receive() to compute the exact buffer size
  • Constructs a bounded std::string via strnlen instead of using a raw const char*
  • Fixes undefined behavior in std::isalnum when called with negative char values by casting to unsigned char

CollectCrashDumps cast the LX_PROCESS_CRASH flexible array member
Buffer to const char* without verifying NUL-termination. Use the
response span from Receive() to compute the exact buffer size, then
construct a bounded std::string via strnlen. Also fix undefined
behavior in std::isalnum with negative char values.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 22, 2026 19:03
@benhillis benhillis requested a review from a team as a code owner April 22, 2026 19:03
Copy link
Copy Markdown
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 hardens crash dump collection in WslCoreVm::CollectCrashDumps() by ensuring the guest-provided process name is handled as a bounded buffer, preventing out-of-bounds reads and eliminating undefined behavior during filename sanitization.

Changes:

  • Compute the received LX_PROCESS_CRASH::Buffer length from the actual response span and build a bounded std::string.
  • Replace raw const char* usage with a safe, length-bounded process name for formatting and telemetry.
  • Fix std::isalnum undefined behavior by casting char to unsigned char before classification.

@benhillis benhillis merged commit 901db6d into master Apr 22, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants