Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SiteInstance::GetSiteForURL must run in UI thread, but we call it in IO thread in TorProfileService::SetProxy #4321

Closed
riastradh-brave opened this issue May 6, 2019 · 0 comments · Fixed by brave/brave-core#2391

Comments

@riastradh-brave
Copy link
Contributor

As of chromium/chromium@ea6921f (2019-01-29), SiteInstance::GetSiteForURL fails DCHECKs if we run it in the IO thread, but we do exactly that when we call TorProfileService::SetProxy in an OnBeforeURLRequest handler:

int TorProfileServiceImpl::SetProxy(net::ProxyResolutionService* service,
                                    const GURL& request_url,
                                    bool new_circuit) {
  DCHECK_CURRENTLY_ON(BrowserThread::IO);
  const TorConfig tor_config = tor_launcher_factory_->GetTorConfig();
  GURL url = SiteInstance::GetSiteForURL(profile_, request_url);

https://github.com/brave/brave-core/blob/b4afcc7dd690ee4393823c3d9fa6d9ea94c455a2/browser/tor/tor_profile_service_impl.cc#L97-L102

This breaks debug builds. It may also have other consequences in non-debug builds -- I haven't seen symptoms but I haven't ruled them out either.

It is not immediately clear to me how to resolve this. Internally, SiteInstanceImpl::GetSiteForURL is allowed in the IO thread when we have a BrowserOrResourceContext and should_use_effective_urls is false. Should we use SiteInstanceImpl::DetermineProcessLockURL, with some isolation context? Should we use the internal SiteInstanceImpl::GetSiteForURL directly?

cc @darkdh, @bridiver

@riastradh-brave riastradh-brave self-assigned this May 8, 2019
riastradh-brave added a commit to brave/brave-core that referenced this issue May 8, 2019
fix brave/brave-browser#4321

Calling it in the IO thread is prohibited at least as of
chromium/chromium@ea6921f
and possibly earlier.

Instead, call url::Origin::Create and
net::registry_controlled_domains::GetDomainAndRegistry directly to get
a first-party origin for a circuit isolation key.
riastradh-brave added a commit to brave/brave-core that referenced this issue May 10, 2019
fix brave/brave-browser#4394

- Disable all proxy bypass rules in TorProxyConfigService.
- Test proxy config rules for several URLs:
  . check.tpo as before
  . localhost
  . IP addresses
  . IPv6 addresses
- Fix circuit isolation bug for numeric IP addresses.
  . Circuit isolation key was empty for numeric IP addresses; should
    just be the IP address.
  . Likely caused by 4e334f8, the
    fix for brave/brave-browser#4321, so won't have actually hit
    anyone outside prereleases.
- Test circuit isolation key determination.
@bbondy bbondy added this to the Closed / Invalid milestone Jun 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants