Switch ChildProcessSecurityPolicyImpl to ChildProcessId [chromium/src : main]

0 views
Skip to first unread message

Christopher Staite (Gerrit)

unread,
Dec 2, 2025, 5:16:48 PM (4 days ago) Dec 2
to Tom Sepez, Ken Buchanan, Fergal Daly, Dmitry Gozman, chromium...@chromium.org, alexmo...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, mattreyno...@chromium.org, navigation...@chromium.org, toyosh...@chromium.org
Attention needed from Dmitry Gozman, Fergal Daly, Ken Buchanan and Tom Sepez

Christopher Staite added 1 comment

Patchset-level comments
File-level comment, Patchset 6 (Latest):
Christopher Staite . resolved

Hi all, taking a stab at infiltrating the ChildProcessId a little further. I've done an all target build locally, so I feel confident, but if someone could hit a dry run for me that would be appreciated. Thanks!

Open in Gerrit

Related details

Attention is currently required from:
  • Dmitry Gozman
  • Fergal Daly
  • Ken Buchanan
  • 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: I19b1a515a46dd8a92d434a4242dcf2217124479e
Gerrit-Change-Number: 7204384
Gerrit-PatchSet: 6
Gerrit-Owner: Christopher Staite <christoph...@menlosecurity.com>
Gerrit-Reviewer: Dmitry Gozman <dgo...@chromium.org>
Gerrit-Reviewer: Fergal Daly <fer...@chromium.org>
Gerrit-Reviewer: Ken Buchanan <ke...@chromium.org>
Gerrit-Reviewer: Tom Sepez <tse...@chromium.org>
Gerrit-Attention: Tom Sepez <tse...@chromium.org>
Gerrit-Attention: Dmitry Gozman <dgo...@chromium.org>
Gerrit-Attention: Ken Buchanan <ke...@chromium.org>
Gerrit-Attention: Fergal Daly <fer...@chromium.org>
Gerrit-Comment-Date: Tue, 02 Dec 2025 22:16:29 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Dmitry Gozman (Gerrit)

unread,
Dec 3, 2025, 5:45:12 AM (4 days ago) Dec 3
to Christopher Staite, Ken Buchanan, Fergal Daly, Charlie Reis, Chromium LUCI CQ, AyeAye, Tom Sepez, chromium...@chromium.org, storage...@chromium.org, dmurph+watch...@chromium.org, edgesto...@microsoft.com, alexmo...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, mattreyno...@chromium.org, navigation...@chromium.org, toyosh...@chromium.org
Attention needed from Christopher Staite and Tom Sepez

Dmitry Gozman voted and added 4 comments

Votes added by Dmitry Gozman

Commit-Queue+1

4 comments

Patchset-level comments
Dmitry Gozman . resolved

Nice one! I encourage you to push a bit further though 😊

File content/browser/child_process_security_policy_impl.cc
Line 965, Patchset 6 (Latest): if (base::Contains(security_state_,
Dmitry Gozman . unresolved

I'd prefer to see private members of `ChildProcessSecurityPolicyImpl` to be migrated to `ChildProcessId` right away. For example, `ChildProcessSecurityPolicyImpl::security_state_` and `ChildProcessSecurityPolicyImpl::Add`. This will avoid a lot of unnecessary unsafe value conversions, and keep the changes contained to a single file. WDYT?

Line 1581, Patchset 6 (Latest):bool ChildProcessSecurityPolicyImpl::CanReadFile(int child_id,
Dmitry Gozman . unresolved

What's the future plan for public APIs like this one? Perhaps we should introduce an overload that takes `ChildProcessId` right away, and immediately use it inside `content/`? Then it would be just a mechanical migration of all callers from the old method to the new one, while impl code will be good from the get go. WDYT?

File content/browser/renderer_host/render_frame_host_impl.h
Line 373, Patchset 6 (Latest): static RenderFrameHostImpl* FromFrameToken(
Dmitry Gozman . unresolved

I like this design with the overload. Let's add the same `TODO(crbug)` to the old method above, for easier search later on?

Open in Gerrit

Related details

Attention is currently required from:
  • Christopher Staite
  • Tom Sepez
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: I19b1a515a46dd8a92d434a4242dcf2217124479e
    Gerrit-Change-Number: 7204384
    Gerrit-PatchSet: 6
    Gerrit-Owner: Christopher Staite <christoph...@menlosecurity.com>
    Gerrit-Reviewer: Dmitry Gozman <dgo...@chromium.org>
    Gerrit-Reviewer: Tom Sepez <tse...@chromium.org>
    Gerrit-CC: Charlie Reis <cr...@chromium.org>
    Gerrit-CC: Fergal Daly <fer...@chromium.org>
    Gerrit-CC: Ken Buchanan <ke...@chromium.org>
    Gerrit-Attention: Tom Sepez <tse...@chromium.org>
    Gerrit-Attention: Christopher Staite <christoph...@menlosecurity.com>
    Gerrit-Comment-Date: Wed, 03 Dec 2025 10:44:49 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Christopher Staite (Gerrit)

    unread,
    Dec 3, 2025, 5:53:14 AM (4 days ago) Dec 3
    to Dmitry Gozman, Ken Buchanan, Fergal Daly, Charlie Reis, Chromium LUCI CQ, AyeAye, Tom Sepez, chromium...@chromium.org, storage...@chromium.org, dmurph+watch...@chromium.org, edgesto...@microsoft.com, alexmo...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, mattreyno...@chromium.org, navigation...@chromium.org, toyosh...@chromium.org
    Attention needed from Dmitry Gozman and Tom Sepez

    Christopher Staite added 3 comments

    File content/browser/child_process_security_policy_impl.cc
    Line 965, Patchset 6 (Latest): if (base::Contains(security_state_,
    Dmitry Gozman . unresolved

    I'd prefer to see private members of `ChildProcessSecurityPolicyImpl` to be migrated to `ChildProcessId` right away. For example, `ChildProcessSecurityPolicyImpl::security_state_` and `ChildProcessSecurityPolicyImpl::Add`. This will avoid a lot of unnecessary unsafe value conversions, and keep the changes contained to a single file. WDYT?

    Christopher Staite

    I did originally try to change `ChildProcessSecurityPolicyImpl::Add`, but the knock on to unit tests was massive and the change went out of control. Hence I've gone as far as I think is appropriate for a single review. I will probably come back and do `Add` next as it seems the logical thing to do, but that will create a very large change set across numerous files.

    Line 1581, Patchset 6 (Latest):bool ChildProcessSecurityPolicyImpl::CanReadFile(int child_id,
    Dmitry Gozman . unresolved

    What's the future plan for public APIs like this one? Perhaps we should introduce an overload that takes `ChildProcessId` right away, and immediately use it inside `content/`? Then it would be just a mechanical migration of all callers from the old method to the new one, while impl code will be good from the get go. WDYT?

    Christopher Staite

    My plan was to convert one at a time and its usages across the product. I'm happy to take guidance if you think that's a poor approach.

    File content/browser/renderer_host/render_frame_host_impl.h
    Line 373, Patchset 6 (Latest): static RenderFrameHostImpl* FromFrameToken(
    Dmitry Gozman . resolved

    I like this design with the overload. Let's add the same `TODO(crbug)` to the old method above, for easier search later on?

    Christopher Staite

    Nice idea, I'll add that in. My TODO's have been a bit hit-and-miss I'll try to make them more reliable.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Dmitry Gozman
    • Tom Sepez
    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: I19b1a515a46dd8a92d434a4242dcf2217124479e
    Gerrit-Change-Number: 7204384
    Gerrit-PatchSet: 6
    Gerrit-Owner: Christopher Staite <christoph...@menlosecurity.com>
    Gerrit-Reviewer: Dmitry Gozman <dgo...@chromium.org>
    Gerrit-Reviewer: Tom Sepez <tse...@chromium.org>
    Gerrit-CC: Charlie Reis <cr...@chromium.org>
    Gerrit-CC: Fergal Daly <fer...@chromium.org>
    Gerrit-CC: Ken Buchanan <ke...@chromium.org>
    Gerrit-Attention: Dmitry Gozman <dgo...@chromium.org>
    Gerrit-Attention: Tom Sepez <tse...@chromium.org>
    Gerrit-Comment-Date: Wed, 03 Dec 2025 10:52:58 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Dmitry Gozman <dgo...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Dmitry Gozman (Gerrit)

    unread,
    Dec 5, 2025, 5:33:32 PM (2 days ago) Dec 5
    to Christopher Staite, Ken Buchanan, Fergal Daly, Charlie Reis, Chromium LUCI CQ, AyeAye, Tom Sepez, chromium...@chromium.org, storage...@chromium.org, dmurph+watch...@chromium.org, edgesto...@microsoft.com, alexmo...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, mattreyno...@chromium.org, navigation...@chromium.org, toyosh...@chromium.org
    Attention needed from Christopher Staite and Tom Sepez

    Dmitry Gozman voted and added 5 comments

    Votes added by Dmitry Gozman

    Commit-Queue+1

    5 comments

    Patchset-level comments
    File-level comment, Patchset 7 (Latest):
    Dmitry Gozman . resolved

    Sorry, this took me quite a while to review. My only suggestion is to migrate unit tests right away, since you are already touching all the same lines. Also, let me trigger the dry run.

    File content/browser/child_process_security_policy_impl.cc
    Line 965, Patchset 6: if (base::Contains(security_state_,
    Dmitry Gozman . unresolved

    I'd prefer to see private members of `ChildProcessSecurityPolicyImpl` to be migrated to `ChildProcessId` right away. For example, `ChildProcessSecurityPolicyImpl::security_state_` and `ChildProcessSecurityPolicyImpl::Add`. This will avoid a lot of unnecessary unsafe value conversions, and keep the changes contained to a single file. WDYT?

    Christopher Staite

    I did originally try to change `ChildProcessSecurityPolicyImpl::Add`, but the knock on to unit tests was massive and the change went out of control. Hence I've gone as far as I think is appropriate for a single review. I will probably come back and do `Add` next as it seems the logical thing to do, but that will create a very large change set across numerous files.

    Dmitry Gozman

    I see, this makes sense. I did not realize the blast radius in the tests.

    Line 1581, Patchset 6:bool ChildProcessSecurityPolicyImpl::CanReadFile(int child_id,
    Dmitry Gozman . unresolved

    What's the future plan for public APIs like this one? Perhaps we should introduce an overload that takes `ChildProcessId` right away, and immediately use it inside `content/`? Then it would be just a mechanical migration of all callers from the old method to the new one, while impl code will be good from the get go. WDYT?

    Christopher Staite

    My plan was to convert one at a time and its usages across the product. I'm happy to take guidance if you think that's a poor approach.

    Dmitry Gozman

    Hmm... I looked at `CanReadFile()` and it also has a lot of usages across files. Your plan sounds good.

    File content/browser/child_process_security_policy_unittest.cc
    Line 1026, Patchset 7 (Latest): p, ChildProcessId::FromUnsafeValue(kRendererID), granted_file,
    Dmitry Gozman . unresolved

    You can probably introduce something like `kRendererChildId` of the `ChildProcessId` type right away, to avoid touching the same code again.

    File content/browser/dom_storage/dom_storage_context_wrapper_unittest.cc
    Line 52, Patchset 7 (Latest): ChildProcessId::FromUnsafeValue(kTestProcessIdOrigin1),
    Dmitry Gozman . unresolved

    Same here.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Christopher Staite
    • Tom Sepez
    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: I19b1a515a46dd8a92d434a4242dcf2217124479e
    Gerrit-Change-Number: 7204384
    Gerrit-PatchSet: 7
    Gerrit-Owner: Christopher Staite <christoph...@menlosecurity.com>
    Gerrit-Reviewer: Dmitry Gozman <dgo...@chromium.org>
    Gerrit-Reviewer: Tom Sepez <tse...@chromium.org>
    Gerrit-CC: Charlie Reis <cr...@chromium.org>
    Gerrit-CC: Fergal Daly <fer...@chromium.org>
    Gerrit-CC: Ken Buchanan <ke...@chromium.org>
    Gerrit-Attention: Tom Sepez <tse...@chromium.org>
    Gerrit-Attention: Christopher Staite <christoph...@menlosecurity.com>
    Gerrit-Comment-Date: Fri, 05 Dec 2025 22:33:14 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes
    Comment-In-Reply-To: Dmitry Gozman <dgo...@chromium.org>
    Comment-In-Reply-To: Christopher Staite <christoph...@menlosecurity.com>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy
    Reply all
    Reply to author
    Forward
    0 new messages