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

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: 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
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;
}

Powered by Google App Engine
This is Rietveld 408576698