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

Unified Diff: src/trusted/platform_qualify/win/nacl_dep_qualify.c

Issue 3539011: Enable check for DEP / NX page protection (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client/
Patch Set: Modify windows check to use Noel's signal interface Created 10 years, 2 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 | « src/trusted/platform_qualify/platform_qualify.gyp ('k') | src/trusted/sel_universal/sel_universal.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/trusted/platform_qualify/win/nacl_dep_qualify.c
===================================================================
--- src/trusted/platform_qualify/win/nacl_dep_qualify.c (revision 3470)
+++ src/trusted/platform_qualify/win/nacl_dep_qualify.c (working copy)
@@ -15,22 +15,56 @@
#include <stdlib.h>
#include "native_client/src/trusted/platform_qualify/nacl_dep_qualify.h"
+#include "native_client/src/trusted/service_runtime/nacl_signal.h"
+static int g_SigFound;
+
+static enum NaClSignalResult signal_catch(int in_untrusted_code,
+ int signal,
+ void *ctx) {
+ UNREFERENCED_PARAMETER(ctx);
+ /* Should be a trusted segfault */
+ if (!in_untrusted_code && 11 == signal) {
+ g_SigFound = signal;
+ return NACL_SIGNAL_SKIP;
+ }
+ return NACL_SIGNAL_SEARCH; /* some other signal we weren't expecting */
+}
+
+static int setup_signals() {
+ return NaClSignalHandlerAdd(signal_catch);
+}
+
+static void restore_signals(int handlerId) {
+ if (0 == NaClSignalHandlerRemove(handlerId)) {
+ /* What to do if the remove failed? */
+ fprintf(stderr, "Failed to unload handler.\n");
+ }
+}
+
/*
* Returns 1 if Data Execution Prevention is present and working.
*/
int NaClAttemptToExecuteData() {
int result;
+ int handlerId;
char *thunk_buffer = malloc(64);
nacl_void_thunk thunk = NaClGenerateThunk(thunk_buffer, 64);
+ handlerId = setup_signals();
+ g_SigFound = 0;
__try {
thunk();
+ } __except (EXCEPTION_EXECUTE_HANDLER) {
+ }
+
+ /* Should be a segfault */
+ if (11 == g_SigFound) {
+ result = 1;
+ } else {
result = 0;
- } __except (GetExceptionCode() == EXCEPTION_ACCESS_VIOLATION ?
- EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) {
- result = 1;
}
+ restore_signals(handlerId);
return result;
}
« no previous file with comments | « src/trusted/platform_qualify/platform_qualify.gyp ('k') | src/trusted/sel_universal/sel_universal.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698