summaryrefslogtreecommitdiffstats
path: root/sandbox/win
diff options
context:
space:
mode:
authorrickyz <rickyz@chromium.org>2015-09-17 17:51:28 -0700
committerCommit bot <commit-bot@chromium.org>2015-09-18 00:52:05 +0000
commit5af5d257aa1126ff7c70cc0d855e53df351d1048 (patch)
tree9876fe18ce777b90235ae76debc00f42dc26f324 /sandbox/win
parent4dff1d58fa60695afac0aa3da11634378c0d7aad (diff)
downloadchromium_src-5af5d257aa1126ff7c70cc0d855e53df351d1048.zip
chromium_src-5af5d257aa1126ff7c70cc0d855e53df351d1048.tar.gz
chromium_src-5af5d257aa1126ff7c70cc0d855e53df351d1048.tar.bz2
Get rid of the token cache.
The caching is not worth the additional complexity, and this would have required changes to work with appcontainer, so just get rid of it instead. Review URL: https://codereview.chromium.org/1346413002 Cr-Commit-Position: refs/heads/master@{#349555}
Diffstat (limited to 'sandbox/win')
-rw-r--r--sandbox/win/src/broker_services.cc80
-rw-r--r--sandbox/win/src/broker_services.h2
2 files changed, 3 insertions, 79 deletions
diff --git a/sandbox/win/src/broker_services.cc b/sandbox/win/src/broker_services.cc
index 1a4c2f3..92cd0e0 100644
--- a/sandbox/win/src/broker_services.cc
+++ b/sandbox/win/src/broker_services.cc
@@ -108,44 +108,6 @@ void DeregisterPeerTracker(PeerTracker* peer) {
}
}
-// Utility function to determine whether a token for the specified policy can
-// be cached.
-bool IsTokenCacheable(const sandbox::PolicyBase* policy) {
- const sandbox::AppContainerAttributes* app_container =
- policy->GetAppContainer();
-
- // We cannot cache tokens with an app container or lowbox.
- if (app_container || policy->GetLowBoxSid())
- return false;
-
- return true;
-}
-
-// Utility function to pack token values into a key for the cache map.
-uint32_t GenerateTokenCacheKey(const sandbox::PolicyBase* policy) {
- const size_t kTokenShift = 3;
- uint32_t key;
-
- DCHECK(IsTokenCacheable(policy));
-
- // Make sure our token values aren't too large to pack into the key.
- static_assert(sandbox::USER_LAST <= (1 << kTokenShift),
- "TokenLevel too large");
- static_assert(sandbox::INTEGRITY_LEVEL_LAST <= (1 << kTokenShift),
- "IntegrityLevel too large");
- static_assert(sizeof(key) < (kTokenShift * 3),
- "Token key type too small");
-
- // The key is the enum values shifted to avoid overlap and OR'd together.
- key = policy->GetInitialTokenLevel();
- key <<= kTokenShift;
- key |= policy->GetLockdownTokenLevel();
- key <<= kTokenShift;
- key |= policy->GetIntegrityLevel();
-
- return key;
-}
-
} // namespace
namespace sandbox {
@@ -220,9 +182,6 @@ BrokerServicesBase::~BrokerServicesBase() {
}
::DeleteCriticalSection(&lock_);
-
- // Close any token in the cache.
- STLDeleteValues(&token_cache_);
}
TargetPolicy* BrokerServicesBase::CreatePolicy() {
@@ -368,42 +327,9 @@ ResultCode BrokerServicesBase::SpawnTarget(const wchar_t* exe_path,
base::win::ScopedHandle lockdown_token;
ResultCode result = SBOX_ALL_OK;
- if (IsTokenCacheable(policy_base)) {
- // Create the master tokens only once and save them in a cache. That way
- // can just duplicate them to avoid hammering LSASS on every sandboxed
- // process launch.
- uint32_t token_key = GenerateTokenCacheKey(policy_base);
- TokenCacheMap::iterator it = token_cache_.find(token_key);
- TokenPair* tokens;
- if (it != token_cache_.end()) {
- tokens = it->second;
- } else {
- result = policy_base->MakeTokens(&initial_token, &lockdown_token);
- if (SBOX_ALL_OK != result)
- return result;
-
- tokens = new TokenPair(initial_token.Pass(), lockdown_token.Pass());
- token_cache_[token_key] = tokens;
- }
-
- HANDLE temp_token;
- if (!::DuplicateToken(tokens->initial.Get(), SecurityImpersonation,
- &temp_token)) {
- return SBOX_ERROR_GENERIC;
- }
- initial_token.Set(temp_token);
-
- if (!::DuplicateTokenEx(tokens->lockdown.Get(), TOKEN_ALL_ACCESS, 0,
- SecurityIdentification, TokenPrimary,
- &temp_token)) {
- return SBOX_ERROR_GENERIC;
- }
- lockdown_token.Set(temp_token);
- } else {
- result = policy_base->MakeTokens(&initial_token, &lockdown_token);
- if (SBOX_ALL_OK != result)
- return result;
- }
+ result = policy_base->MakeTokens(&initial_token, &lockdown_token);
+ if (SBOX_ALL_OK != result)
+ return result;
base::win::ScopedHandle job;
result = policy_base->MakeJobObject(&job);
diff --git a/sandbox/win/src/broker_services.h b/sandbox/win/src/broker_services.h
index 3f269ef..5fd6ca4 100644
--- a/sandbox/win/src/broker_services.h
+++ b/sandbox/win/src/broker_services.h
@@ -105,8 +105,6 @@ class BrokerServicesBase final : public BrokerServices,
// job. Consult |jobless_process_handles_| for handles of pocess without job.
std::set<DWORD> child_process_ids_;
- TokenCacheMap token_cache_;
-
DISALLOW_COPY_AND_ASSIGN(BrokerServicesBase);
};