Commit 5c63f62b authored by Takashi Toyoshima's avatar Takashi Toyoshima Committed by Chromium LUCI CQ

Web MIDI: Add a SECURITY_CHECK to be robust for attacks and changes

In the current production code, `client_` is always set immediately
after the MIDIDispatcher construction, and there is no timing to run
SessionStarted without a valid `client_` on the same thread.

This SECURITY_CHECK just makes the code robust against attacks via
mojo injections and code changes in the future.

Bug: 1161806
Change-Id: Ic8a5f6e0dc70e6bb4c7cccb4d69d63fc12382c19
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2631811
Commit-Queue: Takashi Toyoshima <toyoshim@chromium.org>
Auto-Submit: Takashi Toyoshima <toyoshim@chromium.org>
Reviewed-by: default avatarYutaka Hirano <yhirano@chromium.org>
Cr-Commit-Position: refs/heads/master@{#844503}
parent 1313fe13
......@@ -101,8 +101,13 @@ void MIDIDispatcher::SetOutputPortState(uint32_t port,
void MIDIDispatcher::SessionStarted(midi::mojom::blink::Result result) {
TRACE_EVENT0("midi", "MIDIDispatcher::OnSessionStarted");
// We always have a valid instance in `client_` in the production code, but
// just in case to be robust for mojo injections and code changes in the
// future. Other methods protect accesses to `client_` by `initialized_` flag
// that is set below.
SECURITY_CHECK(client_);
DCHECK(!initialized_);
DCHECK(client_);
initialized_ = true;
if (result == midi::mojom::blink::Result::OK) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment