Chromium Code Reviews| 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..92bd2c689ab956e4b57cc5d956d9b0e99503daf6 100644 |
| --- a/sandbox/win/src/broker_services.cc |
| +++ b/sandbox/win/src/broker_services.cc |
| @@ -273,6 +273,7 @@ DWORD WINAPI BrokerServicesBase::TargetEventsThread(PVOID param) { |
| ResultCode BrokerServicesBase::SpawnTarget(const wchar_t* exe_path, |
| const wchar_t* command_line, |
| TargetPolicy* policy, |
| + ResultCode* last_warning, |
| PROCESS_INFORMATION* target_info) { |
| if (!exe_path) |
| return SBOX_ERROR_BAD_PARAMS; |
| @@ -286,6 +287,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 +305,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,7 +414,7 @@ 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, |
| @@ -418,6 +425,12 @@ ResultCode BrokerServicesBase::SpawnTarget(const wchar_t* exe_path, |
| return result; |
| } |
| + if (lowbox_token.IsValid()) { |
|
Will Harris
2016/07/12 16:10:59
comment here on why this does not abort
|
| + *last_warning = target->AssignLowBoxToken(lowbox_token); |
| + if (*last_warning != SBOX_ALL_OK) |
| + win_result = ::GetLastError(); |
| + } |
| + |
| // Now the policy is the owner of the target. |
| result = policy_base->AddTarget(target); |
| @@ -451,6 +464,8 @@ ResultCode BrokerServicesBase::SpawnTarget(const wchar_t* exe_path, |
| } |
| *target_info = process_info.Take(); |
| + if (*last_warning != SBOX_ALL_OK) |
| + ::SetLastError(win_result); |
| return result; |
| } |