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

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

Issue 1225183003: CreateThread interception, to use CreateRemoteThread (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove thread_attributes from IPC call, use nullptr Created 4 years, 11 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/process_thread_policy.cc
diff --git a/sandbox/win/src/process_thread_policy.cc b/sandbox/win/src/process_thread_policy.cc
index b4976c0bbebeaefc8cfb9cdf57c9533d2c3c0b96..e78608744fe8bd098bccf52ce29311611d754747 100644
--- a/sandbox/win/src/process_thread_policy.cc
+++ b/sandbox/win/src/process_thread_policy.cc
@@ -99,6 +99,9 @@ bool ProcessPolicy::GenerateRules(const wchar_t* name,
if (!policy->AddRule(IPC_CREATEPROCESSW_TAG, process.get())) {
return false;
}
+ if (!policy->AddRule(IPC_CREATETHREAD_TAG, process.get())) {
+ return false;
+ }
liamjm (20p) 2016/02/02 20:43:45 cpu@: Can you comment on the suitability of adding
return true;
}
@@ -238,4 +241,31 @@ DWORD ProcessPolicy::CreateProcessWAction(EvalResult eval_result,
return ERROR_SUCCESS;
}
+DWORD ProcessPolicy::CreateThreadAction(
forshaw 2016/02/02 11:11:49 Is this only going to be used in test code or will
liamjm (20p) 2016/02/02 20:43:45 This is the intended mechanism for CreateThread in
+ EvalResult eval_result,
+ const ClientInfo& client_info,
+ const SIZE_T stack_size,
+ const LPTHREAD_START_ROUTINE start_address,
+ const LPVOID parameter,
+ const DWORD creation_flags,
+ LPDWORD thread_id,
+ HANDLE* handle) {
+ // The only action supported is ASK_BROKER which means create the process.
forshaw 2016/02/02 11:11:49 nit: You mean thread not process?
liamjm (20p) 2016/02/02 20:43:45 Done.
+ if (GIVE_ALLACCESS != eval_result && GIVE_READONLY != eval_result) {
+ return ERROR_ACCESS_DENIED;
+ }
+ HANDLE local_handle =
+ CreateRemoteThread(client_info.process, nullptr, stack_size,
+ start_address, parameter, creation_flags, thread_id);
+ if (!local_handle) {
+ return ::GetLastError();
+ }
+ if (!::DuplicateHandle(::GetCurrentProcess(), local_handle,
+ client_info.process, handle, 0, FALSE,
Will Harris 2016/02/02 05:45:33 should this 0 be THREAD_ALL_ACCESS if eval_result
forshaw 2016/02/02 11:11:49 CreateRemoteThread should return a handle with THR
liamjm (20p) 2016/02/02 20:43:45 If DUPLCIATE_SAME_ACCESS is specified below, then
+ DUPLICATE_CLOSE_SOURCE | DUPLICATE_SAME_ACCESS)) {
Will Harris 2016/02/02 05:45:33 I'm not sure this should be DUPLICATE_SAME_ACCESS
+ return ERROR_ACCESS_DENIED;
+ }
+ return ERROR_SUCCESS;
+}
+
} // namespace sandbox

Powered by Google App Engine
This is Rietveld 408576698