Implement MediaConnectionManager for media connection limits. [chromium/src : main]

0 views
Skip to first unread message

Dale Curtis (Gerrit)

unread,
Jun 18, 2025, 7:02:57 PMJun 18
to Ted (Chromium) Meyer, Chromium LUCI CQ, chromium...@chromium.org, blink-...@chromium.org, feature-me...@chromium.org, kinuko...@chromium.org
Attention needed from Ted (Chromium) Meyer

Dale Curtis added 1 comment

Patchset-level comments
File-level comment, Patchset 3 (Latest):
Dale Curtis . resolved

Still waiting on CQ results, but this is good enough to start looking at.

Open in Gerrit

Related details

Attention is currently required from:
  • Ted (Chromium) Meyer
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Review
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: Ib7bdce6ad7f05ff89ec1fb32829dd31e2814af48
Gerrit-Change-Number: 6655738
Gerrit-PatchSet: 3
Gerrit-Owner: Dale Curtis <dalec...@chromium.org>
Gerrit-Reviewer: Dale Curtis <dalec...@chromium.org>
Gerrit-Reviewer: Ted (Chromium) Meyer <tmath...@chromium.org>
Gerrit-Attention: Ted (Chromium) Meyer <tmath...@chromium.org>
Gerrit-Comment-Date: Wed, 18 Jun 2025 23:02:50 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Ted (Chromium) Meyer (Gerrit)

unread,
Jun 18, 2025, 8:41:32 PMJun 18
to Dale Curtis, Chromium LUCI CQ, chromium...@chromium.org, blink-...@chromium.org, feature-me...@chromium.org, kinuko...@chromium.org
Attention needed from Dale Curtis

Ted (Chromium) Meyer added 4 comments

File third_party/blink/renderer/platform/media/media_connection_manager.cc
Line 194, Patchset 4 (Latest): // May have been removed by MaybeReleaseDeferredConnections().
Ted (Chromium) Meyer . unresolved

Shouldn't this be NOTREACHED? Where is `loader` owned if not in one of these maps?

Line 274, Patchset 4 (Latest): auto& pending_deque = pending_it->value;
Ted (Chromium) Meyer . unresolved

I'm not sure what the purpose of this is? removing it would also fix the UAF, as `deferred_loaders_per_origin_.find(origin)` can become part of the while loop.

Line 275, Patchset 4 (Latest): while (!deferred_deque.empty() && !pending_deque.empty()) {
Ted (Chromium) Meyer . unresolved

There's a UAF in this call stack:
```
MediaConnectionManager::MaybeReleaseDeferredConnections
ManagedWebAssociatedURLLoader::Abort
WebAssociatedURLLoaderClient::DidFail
ManagedWebAssociatedURLLoader::~ManagedWebAssociatedURLLoader
MediaConnectionManager::ReleaseLoader
MediaConnectionManager::ClearOriginIfEmpty
```

which deletes the storage for `deferred_queue` if it's got size==1

Line 300, Patchset 4 (Latest): origin_it->value.erase(loader_it);
Ted (Chromium) Meyer . unresolved

I think it makes sense to add `if (origin_it.empty()) { map.erase(origin); }` here, rather than having the `ClearOriginIfEmpty` function. I'm _pretty_ sure they're being correctly erased now, though in the future changes might make that more uncertain.

Open in Gerrit

Related details

Attention is currently required from:
  • Dale Curtis
Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    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: Ib7bdce6ad7f05ff89ec1fb32829dd31e2814af48
    Gerrit-Change-Number: 6655738
    Gerrit-PatchSet: 4
    Gerrit-Owner: Dale Curtis <dalec...@chromium.org>
    Gerrit-Reviewer: Dale Curtis <dalec...@chromium.org>
    Gerrit-Reviewer: Ted (Chromium) Meyer <tmath...@chromium.org>
    Gerrit-Attention: Dale Curtis <dalec...@chromium.org>
    Gerrit-Comment-Date: Thu, 19 Jun 2025 00:41:24 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Dale Curtis (Gerrit)

    unread,
    Jun 24, 2025, 4:09:51 PMJun 24
    to Ted (Chromium) Meyer, Chromium LUCI CQ, chromium...@chromium.org, blink-...@chromium.org, feature-me...@chromium.org, kinuko...@chromium.org
    Attention needed from Ted (Chromium) Meyer

    Dale Curtis added 4 comments

    File third_party/blink/renderer/platform/media/media_connection_manager.cc
    Line 194, Patchset 4: // May have been removed by MaybeReleaseDeferredConnections().
    Ted (Chromium) Meyer . unresolved

    Shouldn't this be NOTREACHED? Where is `loader` owned if not in one of these maps?

    Dale Curtis

    When `MaybeReleaseDeferredConnections()` is called and removes the loader from `deferred_loaders_per_origin_` this function is still called, so it may have already been removed. That's what the comment is supposed to mean, happy to make it clearer if you have suggestions.

    Line 274, Patchset 4: auto& pending_deque = pending_it->value;
    Ted (Chromium) Meyer . resolved

    I'm not sure what the purpose of this is? removing it would also fix the UAF, as `deferred_loaders_per_origin_.find(origin)` can become part of the while loop.

    Dale Curtis

    We don't want to always release all deferred connections, we only want to release enough of them to start any pending loaders. But yeah, it should be part of the while loop.

    Line 275, Patchset 4: while (!deferred_deque.empty() && !pending_deque.empty()) {
    Ted (Chromium) Meyer . resolved

    There's a UAF in this call stack:
    ```
    MediaConnectionManager::MaybeReleaseDeferredConnections
    ManagedWebAssociatedURLLoader::Abort
    WebAssociatedURLLoaderClient::DidFail
    ManagedWebAssociatedURLLoader::~ManagedWebAssociatedURLLoader
    MediaConnectionManager::ReleaseLoader
    MediaConnectionManager::ClearOriginIfEmpty
    ```

    which deletes the storage for `deferred_queue` if it's got size==1

    Dale Curtis

    Done

    Line 300, Patchset 4: origin_it->value.erase(loader_it);
    Ted (Chromium) Meyer . resolved

    I think it makes sense to add `if (origin_it.empty()) { map.erase(origin); }` here, rather than having the `ClearOriginIfEmpty` function. I'm _pretty_ sure they're being correctly erased now, though in the future changes might make that more uncertain.

    Dale Curtis

    This will result in churning between empty and non-empty deques as loaders move in/out of deferred states. Synthetic testing shows about a 25% overhead.

    ReleaseLoader() must always be called, so this should be pretty bulletproof.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Ted (Chromium) Meyer
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    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: Ib7bdce6ad7f05ff89ec1fb32829dd31e2814af48
    Gerrit-Change-Number: 6655738
    Gerrit-PatchSet: 6
    Gerrit-Owner: Dale Curtis <dalec...@chromium.org>
    Gerrit-Reviewer: Dale Curtis <dalec...@chromium.org>
    Gerrit-Reviewer: Ted (Chromium) Meyer <tmath...@chromium.org>
    Gerrit-Attention: Ted (Chromium) Meyer <tmath...@chromium.org>
    Gerrit-Comment-Date: Tue, 24 Jun 2025 20:09:41 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Ted (Chromium) Meyer <tmath...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Dale Curtis (Gerrit)

    unread,
    Oct 10, 2025, 4:19:22 PM (9 hours ago) Oct 10
    to Ted (Chromium) Meyer, Chromium LUCI CQ, chromium...@chromium.org, blink-...@chromium.org, feature-me...@chromium.org, kinuko...@chromium.org

    Dale Curtis abandoned this change

    Related details

    Attention set is empty
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • 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: abandon
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Ib7bdce6ad7f05ff89ec1fb32829dd31e2814af48
    Gerrit-Change-Number: 6655738
    Gerrit-PatchSet: 8
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy
    Reply all
    Reply to author
    Forward
    0 new messages