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

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

Issue 330853002: Add UIPI support for sandbox alternate desktop (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: conditional tweak Created 6 years, 6 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/sandbox_policy_base.cc
diff --git a/sandbox/win/src/sandbox_policy_base.cc b/sandbox/win/src/sandbox_policy_base.cc
index 711fafc006acd0c2462b05b65e215983aa40556b..9a8cc956a94113fe59d45430ade7fd1289f85645 100644
--- a/sandbox/win/src/sandbox_policy_base.cc
+++ b/sandbox/win/src/sandbox_policy_base.cc
@@ -4,6 +4,8 @@
#include "sandbox/win/src/sandbox_policy_base.h"
+#include <sddl.h>
+
#include "base/basictypes.h"
#include "base/callback.h"
#include "base/logging.h"
@@ -75,6 +77,8 @@ SANDBOX_INTERCEPT MitigationFlags g_shared_delayed_mitigations;
// Initializes static members.
HWINSTA PolicyBase::alternate_winstation_handle_ = NULL;
HDESK PolicyBase::alternate_desktop_handle_ = NULL;
+IntegrityLevel PolicyBase::alternate_desktop_integrity_label_ =
+ INTEGRITY_LEVEL_SYSTEM;
rvargas (doing something else) 2014/06/13 19:46:11 nit: Shouldn't we use _LEVEL_LAST here? It shouldn
jschuh 2014/06/13 22:29:36 Done, but it makes the conditional below a bit mor
PolicyBase::PolicyBase()
: ref_count(1),
@@ -521,6 +525,26 @@ ResultCode PolicyBase::MakeTokens(HANDLE* initial, HANDLE* lockdown) {
return SBOX_ERROR_GENERIC;
}
+ // If we're launching on the alternate desktop we need to make sure our
+ // process has an integrity label that can access it. So, we lower the label
rvargas (doing something else) 2014/06/13 19:46:11 label -> level
jschuh 2014/06/13 22:29:36 Fine, but you have to deal with the ire of Bell an
rvargas (doing something else) 2014/06/13 23:18:47 no me asusta el acertijo!
+ // on the desktop if needed.
+ if (alternate_desktop_handle_ &&
+ integrity_level_ != INTEGRITY_LEVEL_LAST &&
+ alternate_desktop_integrity_label_ < integrity_level_ &&
rvargas (doing something else) 2014/06/13 19:46:11 _label_ -> level
rvargas (doing something else) 2014/06/13 19:46:11 ... then this would be alternate_desktop_integrit
jschuh 2014/06/13 22:29:36 Done, but that's not quite how it works due to the
rvargas (doing something else) 2014/06/13 23:18:47 Yeah, I got that... the way I was reading this con
+ base::win::OSInfo::GetInstance()->version() >= base::win::VERSION_VISTA) {
+ static_assert(INTEGRITY_LEVEL_SYSTEM < INTEGRITY_LEVEL_UNTRUSTED,
+ "Integrity level ordering reversed.");
+ result = SetObjectIntegrityLabel(alternate_desktop_handle_,
+ SE_WINDOW_OBJECT,
+ L"",
+ GetIntegrityLevelString(integrity_level_));
+ if (ERROR_SUCCESS != result) {
+ ::SetLastError(result);
rvargas (doing something else) 2014/06/13 19:46:11 nit: I don't think we promise a last error.
jschuh 2014/06/13 22:29:36 Done.
+ return SBOX_ERROR_GENERIC;
+ }
+ alternate_desktop_integrity_label_ = integrity_level_;
+ }
+
if (appcontainer_list_.get() && appcontainer_list_->HasAppContainer()) {
// Windows refuses to work with an impersonation token. See SetAppContainer
// implementation for more details.
« sandbox/win/src/restricted_token_utils.h ('K') | « sandbox/win/src/sandbox_policy_base.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698