Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(331)

Unified Diff: sandbox/win/src/broker_services.cc

Issue 2130753002: Made setting lowbox token a warning. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reverted change to logging Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sandbox/win/src/broker_services.h ('k') | sandbox/win/src/policy_target_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sandbox/win/src/broker_services.cc
diff --git a/sandbox/win/src/broker_services.cc b/sandbox/win/src/broker_services.cc
index 1339abffb6ed6b8f00f0b63f42e4b03d91dda923..64a0afeca317f84845376e71c5ffa24a9d5c8277 100644
--- a/sandbox/win/src/broker_services.cc
+++ b/sandbox/win/src/broker_services.cc
@@ -37,13 +37,9 @@ bool AssociateCompletionPort(HANDLE job, HANDLE port, void* key) {
// Utility function to do the cleanup necessary when something goes wrong
// while in SpawnTarget and we must terminate the target process.
-sandbox::ResultCode SpawnCleanup(sandbox::TargetProcess* target, DWORD error) {
- if (0 == error)
- error = ::GetLastError();
-
+sandbox::ResultCode SpawnCleanup(sandbox::TargetProcess* target) {
target->Terminate();
delete target;
- ::SetLastError(error);
return sandbox::SBOX_ERROR_GENERIC;
}
@@ -273,6 +269,8 @@ DWORD WINAPI BrokerServicesBase::TargetEventsThread(PVOID param) {
ResultCode BrokerServicesBase::SpawnTarget(const wchar_t* exe_path,
const wchar_t* command_line,
TargetPolicy* policy,
+ ResultCode* last_warning,
+ DWORD* last_error,
PROCESS_INFORMATION* target_info) {
if (!exe_path)
return SBOX_ERROR_BAD_PARAMS;
@@ -286,6 +284,7 @@ ResultCode BrokerServicesBase::SpawnTarget(const wchar_t* exe_path,
// the child process.
static DWORD thread_id = ::GetCurrentThreadId();
DCHECK(thread_id == ::GetCurrentThreadId());
+ *last_warning = SBOX_ALL_OK;
AutoLock lock(&lock_);
@@ -303,6 +302,11 @@ ResultCode BrokerServicesBase::SpawnTarget(const wchar_t* exe_path,
policy_base->MakeTokens(&initial_token, &lockdown_token, &lowbox_token);
if (SBOX_ALL_OK != result)
return result;
+ if (lowbox_token.IsValid() &&
+ base::win::GetVersion() < base::win::VERSION_WIN8) {
+ // We don't allow lowbox_token below Windows 8.
+ return SBOX_ERROR_BAD_PARAMS;
+ }
base::win::ScopedHandle job;
result = policy_base->MakeJobObject(&job);
@@ -407,22 +411,31 @@ ResultCode BrokerServicesBase::SpawnTarget(const wchar_t* exe_path,
base::win::ScopedProcessInformation process_info;
TargetProcess* target =
new TargetProcess(std::move(initial_token), std::move(lockdown_token),
- std::move(lowbox_token), job.Get(), thread_pool_);
+ job.Get(), thread_pool_);
- DWORD win_result;
result = target->Create(exe_path, command_line, inherit_handles, startup_info,
- &process_info, &win_result);
+ &process_info, last_error);
if (result != SBOX_ALL_OK) {
- SpawnCleanup(target, win_result);
+ SpawnCleanup(target);
return result;
}
+ if (lowbox_token.IsValid()) {
+ *last_warning = target->AssignLowBoxToken(lowbox_token);
+ // If this fails we continue, but report the error as a warning.
+ // This is due to certain configurations causing the setting of the
+ // token to fail post creation, and we'd rather continue if possible.
+ if (*last_warning != SBOX_ALL_OK)
+ *last_error = ::GetLastError();
+ }
+
// Now the policy is the owner of the target.
result = policy_base->AddTarget(target);
if (result != SBOX_ALL_OK) {
- SpawnCleanup(target, 0);
+ *last_error = ::GetLastError();
+ SpawnCleanup(target);
return result;
}
« no previous file with comments | « sandbox/win/src/broker_services.h ('k') | sandbox/win/src/policy_target_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698