[Code health] Fix unsafe buffer usage in lib/bindings_internal.h [chromium/src : main]

0 views
Skip to first unread message

Daniel Soromou (Gerrit)

unread,
2:45 PM (5 hours ago) 2:45 PM
to Arthur Sonzogni, Daniel Cheng, Chromium LUCI CQ, chromium...@chromium.org
Attention needed from Daniel Cheng

New activity on the change

Open in Gerrit

Related details

Attention is currently required from:
  • Daniel Cheng
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not 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: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: Ide46efb8cbf53705e8d882cb0cbf80de7ac81d14
Gerrit-Change-Number: 6814595
Gerrit-PatchSet: 4
Gerrit-Owner: Arthur Sonzogni <arthurs...@chromium.org>
Gerrit-Reviewer: Arthur Sonzogni <arthurs...@chromium.org>
Gerrit-Reviewer: Daniel Cheng <dch...@chromium.org>
Gerrit-CC: Daniel Soromou <koreta...@chromium.org>
Gerrit-Attention: Daniel Cheng <dch...@chromium.org>
Gerrit-Comment-Date: Mon, 20 Oct 2025 18:45:42 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Daniel Soromou (Gerrit)

unread,
3:41 PM (4 hours ago) 3:41 PM
to Arthur Sonzogni, Tom Sepez, Daniel Cheng, Chromium LUCI CQ, chromium...@chromium.org
Attention needed from Arthur Sonzogni, Daniel Cheng and Tom Sepez

Daniel Soromou voted Commit-Queue+1

Commit-Queue+1
Open in Gerrit

Related details

Attention is currently required from:
  • Arthur Sonzogni
  • Daniel Cheng
  • Tom Sepez
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not 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: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: Ide46efb8cbf53705e8d882cb0cbf80de7ac81d14
Gerrit-Change-Number: 6814595
Gerrit-PatchSet: 5
Gerrit-Owner: Arthur Sonzogni <arthurs...@chromium.org>
Gerrit-Reviewer: Arthur Sonzogni <arthurs...@chromium.org>
Gerrit-Reviewer: Daniel Cheng <dch...@chromium.org>
Gerrit-Reviewer: Daniel Soromou <koreta...@chromium.org>
Gerrit-Reviewer: Tom Sepez <tse...@chromium.org>
Gerrit-Attention: Tom Sepez <tse...@chromium.org>
Gerrit-Attention: Arthur Sonzogni <arthurs...@chromium.org>
Gerrit-Attention: Daniel Cheng <dch...@chromium.org>
Gerrit-Comment-Date: Mon, 20 Oct 2025 19:41:04 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
satisfied_requirement
unsatisfied_requirement
open
diffy

Tom Sepez (Gerrit)

unread,
3:43 PM (4 hours ago) 3:43 PM
to Arthur Sonzogni, Daniel Soromou, Daniel Cheng, Chromium LUCI CQ, chromium...@chromium.org
Attention needed from Arthur Sonzogni, Daniel Cheng and Daniel Soromou

Tom Sepez added 1 comment

File mojo/public/cpp/bindings/lib/bindings_internal.h
Line 101, Patchset 5 (Latest): if (!base_addr.IsValid()) {
return nullptr;
}
Tom Sepez . unresolved

So this still doesn't prove that the offset is withing the object, just that it hasn't overflowed. So it's still unsafe to smuggle a pointer in this manner,

Open in Gerrit

Related details

Attention is currently required from:
  • Arthur Sonzogni
  • Daniel Cheng
  • Daniel Soromou
Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not 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: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Ide46efb8cbf53705e8d882cb0cbf80de7ac81d14
    Gerrit-Change-Number: 6814595
    Gerrit-PatchSet: 5
    Gerrit-Owner: Arthur Sonzogni <arthurs...@chromium.org>
    Gerrit-Reviewer: Arthur Sonzogni <arthurs...@chromium.org>
    Gerrit-Reviewer: Daniel Cheng <dch...@chromium.org>
    Gerrit-Reviewer: Daniel Soromou <koreta...@chromium.org>
    Gerrit-Reviewer: Tom Sepez <tse...@chromium.org>
    Gerrit-Attention: Arthur Sonzogni <arthurs...@chromium.org>
    Gerrit-Attention: Daniel Soromou <koreta...@chromium.org>
    Gerrit-Attention: Daniel Cheng <dch...@chromium.org>
    Gerrit-Comment-Date: Mon, 20 Oct 2025 19:43:13 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Tom Sepez (Gerrit)

    unread,
    3:45 PM (4 hours ago) 3:45 PM
    to Arthur Sonzogni, Daniel Soromou, Alex Gough, Daniel Cheng, Chromium LUCI CQ, chromium...@chromium.org
    Attention needed from Alex Gough, Arthur Sonzogni, Daniel Cheng and Daniel Soromou

    Tom Sepez added 1 comment

    File mojo/public/cpp/bindings/lib/bindings_internal.h
    Line 92, Patchset 5 (Latest):inline const void* DecodePointer(const uint64_t* offset) {
    Tom Sepez . unresolved

    @ajgo - how do we validate the result of this before use?

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Alex Gough
    • Arthur Sonzogni
    • Daniel Cheng
    • Daniel Soromou
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not 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: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Ide46efb8cbf53705e8d882cb0cbf80de7ac81d14
    Gerrit-Change-Number: 6814595
    Gerrit-PatchSet: 5
    Gerrit-Owner: Arthur Sonzogni <arthurs...@chromium.org>
    Gerrit-Reviewer: Alex Gough <aj...@chromium.org>
    Gerrit-Reviewer: Arthur Sonzogni <arthurs...@chromium.org>
    Gerrit-Reviewer: Daniel Cheng <dch...@chromium.org>
    Gerrit-Reviewer: Daniel Soromou <koreta...@chromium.org>
    Gerrit-Reviewer: Tom Sepez <tse...@chromium.org>
    Gerrit-Attention: Arthur Sonzogni <arthurs...@chromium.org>
    Gerrit-Attention: Alex Gough <aj...@chromium.org>
    Gerrit-Attention: Daniel Soromou <koreta...@chromium.org>
    Gerrit-Attention: Daniel Cheng <dch...@chromium.org>
    Gerrit-Comment-Date: Mon, 20 Oct 2025 19:44:59 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Alex Gough (Gerrit)

    unread,
    4:23 PM (4 hours ago) 4:23 PM
    to Arthur Sonzogni, Daniel Soromou, Alex Gough, Tom Sepez, Daniel Cheng, Chromium LUCI CQ, chromium...@chromium.org
    Attention needed from Arthur Sonzogni, Daniel Cheng and Daniel Soromou

    Alex Gough added 1 comment

    File mojo/public/cpp/bindings/lib/bindings_internal.h
    Line 92, Patchset 5 (Latest):inline const void* DecodePointer(const uint64_t* offset) {
    Tom Sepez . unresolved

    @ajgo - how do we validate the result of this before use?

    Alex Gough

    mojo does a validation pass before its decoding pass e.g. https://source.chromium.org/chromium/chromium/src/+/main:mojo/public/cpp/bindings/lib/map_data_internal.h;drc=a416f377ead3d8c361b97126daf78381344937dd;bpv=1;bpt=1;l=52 so adding more validation here might not be appropriate

    Open in Gerrit

    Related details

    Attention is currently required from:
    Gerrit-Attention: Daniel Soromou <koreta...@chromium.org>
    Gerrit-Attention: Daniel Cheng <dch...@chromium.org>
    Gerrit-Comment-Date: Mon, 20 Oct 2025 20:23:26 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Tom Sepez <tse...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Alex Gough (Gerrit)

    unread,
    4:24 PM (4 hours ago) 4:24 PM
    to Arthur Sonzogni, Daniel Soromou, Alex Gough, Tom Sepez, Daniel Cheng, Chromium LUCI CQ, chromium...@chromium.org
    Attention needed from Arthur Sonzogni, Daniel Cheng and Daniel Soromou

    Alex Gough added 1 comment

    Commit Message
    Line 18, Patchset 5 (Latest):Generated with gemini-cli
    Alex Gough . unresolved

    what was the prompt and how did you teach it about mojo serialization?

    Gerrit-Comment-Date: Mon, 20 Oct 2025 20:24:23 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Tom Sepez (Gerrit)

    unread,
    4:33 PM (3 hours ago) 4:33 PM
    to Arthur Sonzogni, Daniel Soromou, Alex Gough, Daniel Cheng, Chromium LUCI CQ, chromium...@chromium.org
    Attention needed from Arthur Sonzogni, Daniel Cheng and Daniel Soromou

    Tom Sepez added 1 comment

    File mojo/public/cpp/bindings/lib/bindings_internal.h
    Line 92, Patchset 5 (Latest):inline const void* DecodePointer(const uint64_t* offset) {
    Tom Sepez . unresolved

    @ajgo - how do we validate the result of this before use?

    Alex Gough

    mojo does a validation pass before its decoding pass e.g. https://source.chromium.org/chromium/chromium/src/+/main:mojo/public/cpp/bindings/lib/map_data_internal.h;drc=a416f377ead3d8c361b97126daf78381344937dd;bpv=1;bpt=1;l=52 so adding more validation here might not be appropriate

    Tom Sepez
    Ah. So in theory, we could write:
    ```
    UNSAFE_BUFFER_USAGE inline const void* DecodePointer(const uint64_t* offset) {
    if (!*offset)
    return nullptr;
    // SAFETY: required from caller, enforced by UNSAFE_BUFFER_USAGE.
    return UNSAFE_BUFFERS(reinterpret_cast<const char*>(offset) + *offset);
    }
    ```
    but then you play the game of writing // PRECONDITIONS: comments in the callers.
    Gerrit-Comment-Date: Mon, 20 Oct 2025 20:33:28 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Tom Sepez <tse...@chromium.org>
    Comment-In-Reply-To: Alex Gough <aj...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Daniel Soromou (Gerrit)

    unread,
    4:36 PM (3 hours ago) 4:36 PM
    to Arthur Sonzogni, Alex Gough, Tom Sepez, Daniel Cheng, Chromium LUCI CQ, chromium...@chromium.org
    Attention needed from Alex Gough, Arthur Sonzogni and Daniel Cheng

    Daniel Soromou voted and added 1 comment

    Votes added by Daniel Soromou

    Commit-Queue+1

    1 comment

    Commit Message
    Line 18, Patchset 5 (Latest):Generated with gemini-cli
    Alex Gough . unresolved

    what was the prompt and how did you teach it about mojo serialization?

    Daniel Soromou

    The prompt and tools for the fix generation can be found here: agents/prompts/projects/spanification/. There is not a specific mojo serialization knowledge. Please, is there any specification consideration for mojo spanification?

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Alex Gough
    • Arthur Sonzogni
    • Daniel Cheng
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not 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: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Ide46efb8cbf53705e8d882cb0cbf80de7ac81d14
    Gerrit-Change-Number: 6814595
    Gerrit-PatchSet: 5
    Gerrit-Owner: Arthur Sonzogni <arthurs...@chromium.org>
    Gerrit-Reviewer: Alex Gough <aj...@chromium.org>
    Gerrit-Reviewer: Arthur Sonzogni <arthurs...@chromium.org>
    Gerrit-Reviewer: Daniel Cheng <dch...@chromium.org>
    Gerrit-Reviewer: Daniel Soromou <koreta...@chromium.org>
    Gerrit-Reviewer: Tom Sepez <tse...@chromium.org>
    Gerrit-Attention: Arthur Sonzogni <arthurs...@chromium.org>
    Gerrit-Attention: Alex Gough <aj...@chromium.org>
    Gerrit-Attention: Daniel Cheng <dch...@chromium.org>
    Gerrit-Comment-Date: Mon, 20 Oct 2025 20:36:13 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes
    Comment-In-Reply-To: Alex Gough <aj...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Daniel Cheng (Gerrit)

    unread,
    7:29 PM (27 minutes ago) 7:29 PM
    to Arthur Sonzogni, Daniel Soromou, Alex Gough, Tom Sepez, Daniel Cheng, Chromium LUCI CQ, chromium...@chromium.org
    Attention needed from Alex Gough, Arthur Sonzogni and Daniel Soromou

    Daniel Cheng added 1 comment

    File mojo/public/cpp/bindings/lib/bindings_internal.h
    Line 92, Patchset 5 (Latest):inline const void* DecodePointer(const uint64_t* offset) {
    Tom Sepez . unresolved

    @ajgo - how do we validate the result of this before use?

    Alex Gough

    mojo does a validation pass before its decoding pass e.g. https://source.chromium.org/chromium/chromium/src/+/main:mojo/public/cpp/bindings/lib/map_data_internal.h;drc=a416f377ead3d8c361b97126daf78381344937dd;bpv=1;bpt=1;l=52 so adding more validation here might not be appropriate

    Tom Sepez
    Ah. So in theory, we could write:
    ```
    UNSAFE_BUFFER_USAGE inline const void* DecodePointer(const uint64_t* offset) {
    if (!*offset)
    return nullptr;
    // SAFETY: required from caller, enforced by UNSAFE_BUFFER_USAGE.
    return UNSAFE_BUFFERS(reinterpret_cast<const char*>(offset) + *offset);
    }
    ```
    but then you play the game of writing // PRECONDITIONS: comments in the callers.
    Daniel Cheng

    I think it would be reasonable to mark `DecodePointer()` (and maybe `EncodePointer()`) as unsafe and similarly force `Pointer::Get()` and `Pointer::Set()` to be unsafe as well.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Alex Gough
    • Arthur Sonzogni
    • Daniel Soromou
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not 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: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Ide46efb8cbf53705e8d882cb0cbf80de7ac81d14
    Gerrit-Change-Number: 6814595
    Gerrit-PatchSet: 5
    Gerrit-Owner: Arthur Sonzogni <arthurs...@chromium.org>
    Gerrit-Reviewer: Alex Gough <aj...@chromium.org>
    Gerrit-Reviewer: Arthur Sonzogni <arthurs...@chromium.org>
    Gerrit-Reviewer: Daniel Cheng <dch...@chromium.org>
    Gerrit-Reviewer: Daniel Soromou <koreta...@chromium.org>
    Gerrit-Reviewer: Tom Sepez <tse...@chromium.org>
    Gerrit-Attention: Arthur Sonzogni <arthurs...@chromium.org>
    Gerrit-Attention: Daniel Soromou <koreta...@chromium.org>
    Gerrit-Attention: Alex Gough <aj...@chromium.org>
    Gerrit-Comment-Date: Mon, 20 Oct 2025 23:29:28 +0000
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy
    Reply all
    Reply to author
    Forward
    0 new messages