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

Unified Diff: src/trusted/validator_ragel/unreviewed/validator-x86_64.rl

Issue 10392066: validator_ragel: Use different actions for different types of commands (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client/
Patch Set: Created 8 years, 7 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: src/trusted/validator_ragel/unreviewed/validator-x86_64.rl
===================================================================
--- src/trusted/validator_ragel/unreviewed/validator-x86_64.rl (revision 8577)
+++ src/trusted/validator_ragel/unreviewed/validator-x86_64.rl (working copy)
@@ -88,9 +88,22 @@
check_jump_dest;
}
- include decode_x86_64 "validator-x86_64-instruction.rl";
+ action process_0_operands {
+ /* Restricted %rsp or %rbp must be processed by appropriate nacl-special
+ instruction, not with regular instruction. */
+ if (restricted_register == REG_RSP) {
+ PrintError("Incorrectly modified register %%rsp\n", begin - data);
+ result = 1;
+ goto error_detected;
+ } else if (restricted_register == REG_RBP) {
+ PrintError("Incorrectly modified register %%rbp\n", begin - data);
+ result = 1;
+ goto error_detected;
+ }
+ restricted_register = kNoRestrictedReg;
+ }
- action process_normal_instruction {
+ action process_1_operands {
/* Restricted %rsp or %rbp must be processed by appropriate nacl-special
instruction, not with regular instruction. */
if (restricted_register == REG_RSP) {
@@ -105,6 +118,57 @@
/* If Sandboxed Rsi is destroyed then we must note that. */
pasko-google - do not use 2012/05/12 13:54:31 s/note/detect/
khim 2012/05/12 14:32:16 Done.
if (restricted_register == kSandboxedRsi) {
if (CHECK_OPERAND(0, REG_RSI, OperandSandboxRestricted) ||
+ CHECK_OPERAND(0, REG_RSI, OperandSandboxUnrestricted)) {
+ restricted_register = kNoRestrictedReg;
+ }
+ }
+ if (restricted_register == kSandboxedRsi) {
+ if (CHECK_OPERAND(0, REG_RDI, OperandSandboxRestricted)) {
+ sandboxed_rsi_restricted_rdi = begin;
+ restricted_register = kSandboxedRsiRestrictedRdi;
+ }
+ }
+ if (restricted_register != kSandboxedRsiRestrictedRdi) {
+ restricted_register = kNoRestrictedReg;
+ if (CHECK_OPERAND(0, REG_R15, OperandSandbox8bit) ||
+ CHECK_OPERAND(0, REG_R15, OperandSandboxRestricted) ||
+ CHECK_OPERAND(0, REG_R15, OperandSandboxUnrestricted)) {
+ PrintError("Incorrectly modified register %%r15\n", begin - data);
+ result = 1;
+ goto error_detected;
+ } else if ((CHECK_OPERAND(0, REG_RBP, OperandSandbox8bit) &&
+ GET_REX_PREFIX()) ||
+ CHECK_OPERAND(0, REG_RBP, OperandSandboxUnrestricted)) {
+ PrintError("Incorrectly modified register %%rbp\n", begin - data);
+ result = 1;
+ goto error_detected;
+ } else if ((CHECK_OPERAND(0, REG_RSP, OperandSandbox8bit) &&
+ GET_REX_PREFIX()) ||
+ CHECK_OPERAND(0, REG_RSP, OperandSandboxUnrestricted)) {
+ PrintError("Incorrectly modified register %%rsp\n", begin - data);
+ result = 1;
+ goto error_detected;
+ } else if ((operand_states & 0x70) == (OperandSandboxRestricted << 5)) {
+ restricted_register = operand_states & 0x0f;
pasko-google - do not use 2012/05/12 13:54:31 copy the proposed comment above this line too
khim 2012/05/12 14:32:16 Done.
+ }
+ }
+ }
+
+ action process_2_operands {
+ /* Restricted %rsp or %rbp must be processed by appropriate nacl-special
+ instruction, not with regular instruction. */
+ if (restricted_register == REG_RSP) {
+ PrintError("Incorrectly modified register %%rsp\n", begin - data);
+ result = 1;
+ goto error_detected;
+ } else if (restricted_register == REG_RBP) {
+ PrintError("Incorrectly modified register %%rbp\n", begin - data);
+ result = 1;
+ goto error_detected;
+ }
+ /* If Sandboxed Rsi is destroyed then we must note that. */
pasko-google - do not use 2012/05/12 13:54:31 ditto
khim 2012/05/12 14:32:16 Done.
+ if (restricted_register == kSandboxedRsi) {
+ if (CHECK_OPERAND(0, REG_RSI, OperandSandboxRestricted) ||
CHECK_OPERAND(0, REG_RSI, OperandSandboxUnrestricted) ||
CHECK_OPERAND(1, REG_RSI, OperandSandboxRestricted) ||
CHECK_OPERAND(1, REG_RSI, OperandSandboxUnrestricted)) {
@@ -156,8 +220,10 @@
}
}
+ include decode_x86_64 "validator-x86_64-instruction.rl";
+
# Remove special instructions which are only allowed in special cases.
- normal_instruction = (one_instruction - (
+ normal_instruction = one_instruction - (
(0x48 0x89 0xe5) | # mov %rsp,%rbp
(0x48 0x89 0xec) | # mov %rbp,%rsp
(0x48 0x81 0xe4 any{4}) | # and $XXX,%rsp
@@ -171,7 +237,7 @@
(0x4a 0x8d 0x24 0x3c) | # lea (%rsp,%r15,1),%rsp
(0x49 0x8d 0x34 0x37) | # lea (%r15,%rsi,1),%rsi
(0x49 0x8d 0x3c 0x3f) # lea (%r15,%rdi,1),%rdi
- )) @process_normal_instruction;
+ );
data16condrep = (data16 | condrep data16 | data16 condrep);
data16rep = (data16 | rep data16 | data16 rep);

Powered by Google App Engine
This is Rietveld 408576698