Clamp aligned_offset in MemorySnapshotSanitized [crashpad/crashpad : main]

3 views
Skip to first unread message

Mark Mentovai (Gerrit)

unread,
Jul 23, 2026, 5:50:22 PM (5 days ago) Jul 23
to Joshua Peraza, crashpa...@luci-project-accounts.iam.gserviceaccount.com, crashp...@chromium.org
Attention needed from Joshua Peraza

Mark Mentovai added 3 comments

Patchset-level comments
File-level comment, Patchset 2 (Latest):
Mark Mentovai . resolved

Good to hear from you. Welcome back!

File snapshot/BUILD.gn
Line 335, Patchset 2 (Parent): # There’s no way to make the link depend on this file. “inputs” doesn’t have
# the intended effect in a config. https://crbug.com/781858,
# https://crbug.com/796187.
Mark Mentovai . unresolved

This was formatted correctly before!

(Oh, I know what this is, it’s the thing where `gn format` counts bytes instead of UTF-8 characters. Bad `gn format`!)

File snapshot/sanitized/memory_snapshot_sanitized.cc
Line 59, Patchset 2 (Latest): ((address_ + sizeof(Pointer) - 1) & ~(sizeof(Pointer) - 1)) - address_;
Mark Mentovai . unresolved

`#include <algorithm>` and use `std::min(size, …)`, and then `aligned_offset` can even remain `const`.

Open in Gerrit

Related details

Attention is currently required from:
  • Joshua Peraza
Submit Requirements:
  • requirement satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: crashpad/crashpad
Gerrit-Branch: main
Gerrit-Change-Id: Ib58b96250631f760329f16d30a0e7b8b062394f2
Gerrit-Change-Number: 8138617
Gerrit-PatchSet: 2
Gerrit-Owner: Joshua Peraza <jpe...@chromium.org>
Gerrit-Reviewer: Joshua Peraza <jpe...@chromium.org>
Gerrit-Reviewer: Mark Mentovai <ma...@chromium.org>
Gerrit-Attention: Joshua Peraza <jpe...@chromium.org>
Gerrit-Comment-Date: Thu, 23 Jul 2026 21:50:16 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Joshua Peraza (Gerrit)

unread,
Jul 23, 2026, 6:14:41 PM (5 days ago) Jul 23
to Mark Mentovai, crashpa...@luci-project-accounts.iam.gserviceaccount.com, crashp...@chromium.org
Attention needed from Mark Mentovai

Joshua Peraza added 3 comments

Patchset-level comments
Mark Mentovai . resolved

Good to hear from you. Welcome back!

Joshua Peraza

Thanks!

File snapshot/BUILD.gn
Line 335, Patchset 2 (Parent): # There’s no way to make the link depend on this file. “inputs” doesn’t have
# the intended effect in a config. https://crbug.com/781858,
# https://crbug.com/796187.
Mark Mentovai . resolved

This was formatted correctly before!

(Oh, I know what this is, it’s the thing where `gn format` counts bytes instead of UTF-8 characters. Bad `gn format`!)

Joshua Peraza

Reformat reverted.

File snapshot/sanitized/memory_snapshot_sanitized.cc
Line 59, Patchset 2: ((address_ + sizeof(Pointer) - 1) & ~(sizeof(Pointer) - 1)) - address_;
Mark Mentovai . resolved

`#include <algorithm>` and use `std::min(size, …)`, and then `aligned_offset` can even remain `const`.

Joshua Peraza

Done

Open in Gerrit

Related details

Attention is currently required from:
  • Mark Mentovai
Submit Requirements:
    • requirement satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: crashpad/crashpad
    Gerrit-Branch: main
    Gerrit-Change-Id: Ib58b96250631f760329f16d30a0e7b8b062394f2
    Gerrit-Change-Number: 8138617
    Gerrit-PatchSet: 3
    Gerrit-Owner: Joshua Peraza <jpe...@chromium.org>
    Gerrit-Reviewer: Joshua Peraza <jpe...@chromium.org>
    Gerrit-Reviewer: Mark Mentovai <ma...@chromium.org>
    Gerrit-Attention: Mark Mentovai <ma...@chromium.org>
    Gerrit-Comment-Date: Thu, 23 Jul 2026 22:14:35 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Mark Mentovai <ma...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Mark Mentovai (Gerrit)

    unread,
    Jul 24, 2026, 9:50:35 AM (4 days ago) Jul 24
    to Joshua Peraza, crashpa...@luci-project-accounts.iam.gserviceaccount.com, crashp...@chromium.org
    Attention needed from Joshua Peraza

    Mark Mentovai voted and added 2 comments

    Votes added by Mark Mentovai

    Code-Review+1

    2 comments

    Patchset-level comments
    File-level comment, Patchset 3 (Latest):
    Mark Mentovai . resolved

    LGTM otherwise!

    Commit Message
    Line 22, Patchset 3 (Latest):Bug:500097298
    Mark Mentovai . unresolved

    Missing a space after the colon.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Joshua Peraza
    Submit Requirements:
    • requirement satisfiedCode-Owners
    • requirement satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: crashpad/crashpad
    Gerrit-Branch: main
    Gerrit-Change-Id: Ib58b96250631f760329f16d30a0e7b8b062394f2
    Gerrit-Change-Number: 8138617
    Gerrit-PatchSet: 3
    Gerrit-Owner: Joshua Peraza <jpe...@chromium.org>
    Gerrit-Reviewer: Joshua Peraza <jpe...@chromium.org>
    Gerrit-Reviewer: Mark Mentovai <ma...@chromium.org>
    Gerrit-Attention: Joshua Peraza <jpe...@chromium.org>
    Gerrit-Comment-Date: Fri, 24 Jul 2026 13:50:30 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Joshua Peraza (Gerrit)

    unread,
    Jul 24, 2026, 12:30:38 PM (4 days ago) Jul 24
    to Mark Mentovai, crashpa...@luci-project-accounts.iam.gserviceaccount.com, crashp...@chromium.org

    Joshua Peraza voted and added 1 comment

    Votes added by Joshua Peraza

    Commit-Queue+2

    1 comment

    Commit Message
    Line 22, Patchset 3:Bug:500097298
    Mark Mentovai . resolved

    Missing a space after the colon.

    Joshua Peraza

    Done

    Open in Gerrit

    Related details

    Attention set is empty
    Submit Requirements:
      • requirement satisfiedCode-Owners
      • requirement satisfiedCode-Review
      • requirement satisfiedReview-Enforcement
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: crashpad/crashpad
      Gerrit-Branch: main
      Gerrit-Change-Id: Ib58b96250631f760329f16d30a0e7b8b062394f2
      Gerrit-Change-Number: 8138617
      Gerrit-PatchSet: 4
      Gerrit-Owner: Joshua Peraza <jpe...@chromium.org>
      Gerrit-Reviewer: Joshua Peraza <jpe...@chromium.org>
      Gerrit-Reviewer: Mark Mentovai <ma...@chromium.org>
      Gerrit-Comment-Date: Fri, 24 Jul 2026 16:30:31 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: Yes
      Comment-In-Reply-To: Mark Mentovai <ma...@chromium.org>
      satisfied_requirement
      open
      diffy

      crashpad-scoped@luci-project-accounts.iam.gserviceaccount.com (Gerrit)

      unread,
      Jul 24, 2026, 12:46:45 PM (4 days ago) Jul 24
      to Joshua Peraza, Mark Mentovai, crashp...@chromium.org

      crashpa...@luci-project-accounts.iam.gserviceaccount.com submitted the change

      Unreviewed changes

      3 is the latest approved patch-set.
      No files were changed between the latest approved patch-set and the submitted one.

      Change information

      Commit message:
      Clamp aligned_offset in MemorySnapshotSanitized

      MemorySanitizer::Sanitize() computes the number of leading unaligned
      bytes from the snapshot's base address and uses it as the length of a
      memcpy into the data buffer and as the subtrahend for the word count.
      When the snapshot is shorter than the alignment offset (an unaligned
      base address with a sub-word region), the leading memcpy writes past the
      end of the buffer and the word count underflows.

      Clamp the offset to the buffer size so that short unaligned regions are
      defaced in place.

      Add MemorySnapshotSanitized.ShortUnalignedRegion64/32 unit tests
      covering every (offset, size) pair below the pointer width.
      Bug: 500097298
      Change-Id: Ib58b96250631f760329f16d30a0e7b8b062394f2
      Reviewed-by: Mark Mentovai <ma...@chromium.org>
      Commit-Queue: Joshua Peraza <jpe...@chromium.org>
      Files:
      • M snapshot/BUILD.gn
      • M snapshot/sanitized/memory_snapshot_sanitized.cc
      • A snapshot/sanitized/memory_snapshot_sanitized_test.cc
      Change size: M
      Delta: 3 files changed, 121 insertions(+), 2 deletions(-)
      Branch: refs/heads/main
      Submit Requirements:
      • requirement satisfiedCode-Review: +1 by Mark Mentovai
      Open in Gerrit
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: merged
      Gerrit-Project: crashpad/crashpad
      Gerrit-Branch: main
      Gerrit-Change-Id: Ib58b96250631f760329f16d30a0e7b8b062394f2
      Gerrit-Change-Number: 8138617
      Gerrit-PatchSet: 5
      Gerrit-Owner: Joshua Peraza <jpe...@chromium.org>
      Gerrit-Reviewer: Joshua Peraza <jpe...@chromium.org>
      Gerrit-Reviewer: Mark Mentovai <ma...@chromium.org>
      open
      diffy
      satisfied_requirement
      Reply all
      Reply to author
      Forward
      0 new messages