2 # Originally these tests came from
3 # https://github.com/mseaborn/x86-decoder/blob/x86-64/validator_test.py
5 # Check some simple allowed instructions.
10 # mov $0x12345678, %rax
12 # mov $0x1234567812345678, %rax
13 48 b8 78 56 34 12 78 56 34 12
15 VALIDATOR: Checking jump targets: 0 to 13
16 VALIDATOR: Checking that basic blocks are aligned
17 *** <input> is safe ***
19 0000000000000000: 90 nop
20 0000000000000001: f4 hlt
21 0000000000000002: 48 c7 c0 78 56 34 12 mov %rax, 0x12345678
22 0000000000000009: 48 b8 78 56 34 12 78 56 34 12 mov %rax, 0x1234567812345678
25 ----------------------------------------------------------------------
27 # Check a disallowed instruction.
33 VALIDATOR: 0000000000000001: cd 80 int 0x80
34 VALIDATOR: ERROR: This instruction has been marked illegal by Native Client
35 VALIDATOR: Checking jump targets: 0 to 3
36 VALIDATOR: Checking that basic blocks are aligned
37 *** <input> IS UNSAFE ***
39 0000000000000000: 90 nop
40 0000000000000001: cd 80 int 0x80
42 1: [0] unrecognized instruction
44 ----------------------------------------------------------------------
49 VALIDATOR: 0000000000000000: c3 ret
50 VALIDATOR: ERROR: This instruction has been marked illegal by Native Client
51 VALIDATOR: 0000000000000000: c3 ret
52 VALIDATOR: ERROR: Illegal assignment to RSP
53 VALIDATOR: Checking jump targets: 0 to 1
54 VALIDATOR: Checking that basic blocks are aligned
55 *** <input> IS UNSAFE ***
57 0000000000000000: c3 ret
59 0: [0] unrecognized instruction
61 ----------------------------------------------------------------------
66 VALIDATOR: 0000000000000000: 0f 05 syscall
67 VALIDATOR: ERROR: This instruction has been marked illegal by Native Client
68 VALIDATOR: 0000000000000000: 0f 05 syscall
69 VALIDATOR: ERROR: System instructions are not allowed by Native Client
70 VALIDATOR: Checking jump targets: 0 to 2
71 VALIDATOR: Checking that basic blocks are aligned
72 *** <input> IS UNSAFE ***
74 0000000000000000: 0f 05 syscall
76 0: [0] unrecognized instruction
78 ----------------------------------------------------------------------
80 # mov $0x1234567812345678, %rax
81 48 b8 78 56 34 12 78 56 34 12
82 # mov $0x1234567812345678, %rax
83 48 b8 78 56 34 12 78 56 34 12
84 # mov $0x1234567812345678, %rax
85 48 b8 78 56 34 12 78 56 34 12
86 # mov $0x1234567812345678, %rax
87 48 b8 78 56 34 12 78 56 34 12
89 VALIDATOR: Checking jump targets: 0 to 28
90 VALIDATOR: Checking that basic blocks are aligned
91 VALIDATOR: ERROR: 20: Bad basic block alignment.
92 *** <input> IS UNSAFE ***
94 0000000000000000: 48 b8 78 56 34 12 78 56 34 12 mov %rax, 0x1234567812345678
95 000000000000000a: 48 b8 78 56 34 12 78 56 34 12 mov %rax, 0x1234567812345678
96 0000000000000014: 48 b8 78 56 34 12 78 56 34 12 mov %rax, 0x1234567812345678
97 000000000000001e: 48 b8 78 56 34 12 78 56 34 12 mov %rax, 0x1234567812345678
99 1e: [0] unrecognized instruction
100 20: [0] direct jump out of range
101 24: [0] direct jump out of range
103 @validators_disagree:
104 Because RDFA validator recovered after bundle boundary.
105 ----------------------------------------------------------------------
107 # Forwards and backwards jumps.
119 VALIDATOR: Checking jump targets: 0 to 9
120 VALIDATOR: Checking that basic blocks are aligned
121 *** <input> is safe ***
123 0000000000000000: 90 nop
124 0000000000000001: eb 04 jmp 0x7
125 0000000000000003: eb fe jmp 0x3
126 0000000000000005: eb fc jmp 0x3
127 0000000000000007: eb fa jmp 0x3
130 ----------------------------------------------------------------------
132 # Out-of-range unaligned jump.
136 VALIDATOR: 0000000000000000: eb fd jmp 0xffffffffffffffff
137 VALIDATOR: ERROR: Instruction jumps to bad address
138 VALIDATOR: Checking jump targets: 0 to 2
139 VALIDATOR: Checking that basic blocks are aligned
140 *** <input> IS UNSAFE ***
142 0000000000000000: eb fd jmp 0xffffffffffffffff
144 0: [0] direct jump out of range
146 ----------------------------------------------------------------------
148 # Out-of-range unaligned jump.
152 VALIDATOR: 0000000000000000: eb 1f jmp 0x21
153 VALIDATOR: ERROR: Instruction jumps to bad address
154 VALIDATOR: Checking jump targets: 0 to 2
155 VALIDATOR: Checking that basic blocks are aligned
156 *** <input> IS UNSAFE ***
158 0000000000000000: eb 1f jmp 0x21
160 0: [0] direct jump out of range
162 ----------------------------------------------------------------------
164 # Jump into instruction.
165 # mov $0x1234567812345678, %rax
166 48 b8 78 56 34 12 78 56 34 12
170 VALIDATOR: Checking jump targets: 0 to c
171 VALIDATOR: ERROR: 5: Bad jump target
172 VALIDATOR: Checking that basic blocks are aligned
173 *** <input> IS UNSAFE ***
175 0000000000000000: 48 b8 78 56 34 12 78 56 34 12 mov %rax, 0x1234567812345678
176 000000000000000a: eb f9 jmp 0x5
178 a: [0] bad jump target
180 @validators_disagree:
181 Difference in jump reporting.
182 ----------------------------------------------------------------------
184 # Unmasked indirect jumps are disallowed.
188 VALIDATOR: 0000000000000000: ff e0 jmp %rax
189 VALIDATOR: ERROR: Invalid indirect jump
190 VALIDATOR: Checking jump targets: 0 to 2
191 VALIDATOR: Checking that basic blocks are aligned
192 *** <input> IS UNSAFE ***
194 0000000000000000: ff e0 jmp %rax
196 0: [0] unrecognized instruction
198 ----------------------------------------------------------------------
203 VALIDATOR: 0000000000000000: ff 20 jmp [%rax]
204 VALIDATOR: ERROR: Invalid base register in memory offset
205 VALIDATOR: 0000000000000000: ff 20 jmp [%rax]
206 VALIDATOR: ERROR: Jump not native client compliant
207 VALIDATOR: Checking jump targets: 0 to 2
208 VALIDATOR: Checking that basic blocks are aligned
209 *** <input> IS UNSAFE ***
211 0000000000000000: ff 20 jmp [%rax]
213 0: [0] unrecognized instruction
215 ----------------------------------------------------------------------
220 VALIDATOR: 0000000000000000: ff d0 call %rax
221 VALIDATOR: ERROR: Invalid indirect jump
222 VALIDATOR: 0000000000000000: ff d0 call %rax
223 VALIDATOR: WARNING: Bad call alignment, return pc = 2
224 VALIDATOR: Checking jump targets: 0 to 2
225 VALIDATOR: Checking that basic blocks are aligned
226 *** <input> IS UNSAFE ***
228 0000000000000000: ff d0 call %rax
230 0: [0] unrecognized instruction
232 ----------------------------------------------------------------------
237 VALIDATOR: 0000000000000000: ff 10 call [%rax]
238 VALIDATOR: ERROR: Invalid base register in memory offset
239 VALIDATOR: 0000000000000000: ff 10 call [%rax]
240 VALIDATOR: ERROR: Jump not native client compliant
241 VALIDATOR: 0000000000000000: ff 10 call [%rax]
242 VALIDATOR: WARNING: Bad call alignment, return pc = 2
243 VALIDATOR: Checking jump targets: 0 to 2
244 VALIDATOR: Checking that basic blocks are aligned
245 *** <input> IS UNSAFE ***
247 0000000000000000: ff 10 call [%rax]
249 0: [0] unrecognized instruction
251 ----------------------------------------------------------------------
253 # Masking instructions on their own are allowed.
263 VALIDATOR: Checking jump targets: 0 to e
264 VALIDATOR: Checking that basic blocks are aligned
265 *** <input> is safe ***
267 0000000000000000: 83 e0 e0 and %eax, 0xe0
268 0000000000000003: 83 e3 e0 and %ebx, 0xe0
269 0000000000000006: 48 83 e0 e0 and %rax, 0xe0
270 000000000000000a: 48 83 e3 e0 and %rbx, 0xe0
273 ----------------------------------------------------------------------
285 VALIDATOR: Checking jump targets: 0 to c
286 VALIDATOR: Checking that basic blocks are aligned
287 *** <input> is safe ***
289 0000000000000000: 83 e0 e0 and %eax, 0xe0
290 0000000000000003: 4c 01 f8 add %rax, %r15
291 0000000000000006: 83 e3 e0 and %ebx, 0xe0
292 0000000000000009: 4c 01 fb add %rbx, %r15
295 ----------------------------------------------------------------------
297 # Masked indirect jumps are allowed.
305 VALIDATOR: Checking jump targets: 0 to 8
306 VALIDATOR: Checking that basic blocks are aligned
307 *** <input> is safe ***
309 0000000000000000: 83 e0 e0 and %eax, 0xe0
310 0000000000000003: 4c 01 f8 add %rax, %r15
311 0000000000000006: ff e0 jmp %rax
314 ----------------------------------------------------------------------
323 VALIDATOR: 0000000000000006: ff d3 call %rbx
324 VALIDATOR: WARNING: Bad call alignment, return pc = 8
325 VALIDATOR: Checking jump targets: 0 to 8
326 VALIDATOR: Checking that basic blocks are aligned
327 *** <input> is safe ***
329 0000000000000000: 83 e3 e0 and %ebx, 0xe0
330 0000000000000003: 4c 01 fb add %rbx, %r15
331 0000000000000006: ff d3 call %rbx
334 ----------------------------------------------------------------------
336 # The registers must match up for the mask and the jump.
344 VALIDATOR: 0000000000000006: ff e0 jmp %rax
345 VALIDATOR: ERROR: Invalid indirect jump
346 VALIDATOR: Checking jump targets: 0 to 8
347 VALIDATOR: Checking that basic blocks are aligned
348 *** <input> IS UNSAFE ***
350 0000000000000000: 83 e3 e0 and %ebx, 0xe0
351 0000000000000003: 4c 01 f8 add %rax, %r15
352 0000000000000006: ff e0 jmp %rax
354 6: [0] unrecognized instruction
356 @validators_disagree:
357 Difference in error reporting.
358 ----------------------------------------------------------------------
367 VALIDATOR: 0000000000000006: ff e0 jmp %rax
368 VALIDATOR: ERROR: Invalid indirect jump
369 VALIDATOR: Checking jump targets: 0 to 8
370 VALIDATOR: Checking that basic blocks are aligned
371 *** <input> IS UNSAFE ***
373 0000000000000000: 83 e0 e0 and %eax, 0xe0
374 0000000000000003: 4c 01 fb add %rbx, %r15
375 0000000000000006: ff e0 jmp %rax
377 6: [0] unrecognized instruction
379 @validators_disagree:
380 Difference in error reporting.
381 ----------------------------------------------------------------------
390 VALIDATOR: 0000000000000006: ff e3 jmp %rbx
391 VALIDATOR: ERROR: Invalid indirect jump
392 VALIDATOR: Checking jump targets: 0 to 8
393 VALIDATOR: Checking that basic blocks are aligned
394 *** <input> IS UNSAFE ***
396 0000000000000000: 83 e0 e0 and %eax, 0xe0
397 0000000000000003: 4c 01 f8 add %rax, %r15
398 0000000000000006: ff e3 jmp %rbx
400 6: [0] unrecognized instruction
402 @validators_disagree:
403 Difference in error reporting.
404 ----------------------------------------------------------------------
413 VALIDATOR: 0000000000000006: ff e3 jmp %rbx
414 VALIDATOR: ERROR: Invalid indirect jump
415 VALIDATOR: Checking jump targets: 0 to 8
416 VALIDATOR: Checking that basic blocks are aligned
417 *** <input> IS UNSAFE ***
419 0000000000000000: 83 e0 e0 and %eax, 0xe0
420 0000000000000003: 4c 01 fb add %rbx, %r15
421 0000000000000006: ff e3 jmp %rbx
423 6: [0] unrecognized instruction
425 @validators_disagree:
426 Difference in error reporting.
427 ----------------------------------------------------------------------
436 VALIDATOR: 0000000000000006: ff e0 jmp %rax
437 VALIDATOR: ERROR: Invalid indirect jump
438 VALIDATOR: Checking jump targets: 0 to 8
439 VALIDATOR: Checking that basic blocks are aligned
440 *** <input> IS UNSAFE ***
442 0000000000000000: 83 e3 e0 and %ebx, 0xe0
443 0000000000000003: 4c 01 fb add %rbx, %r15
444 0000000000000006: ff e0 jmp %rax
446 6: [0] unrecognized instruction
448 @validators_disagree:
449 Difference in error reporting.
450 ----------------------------------------------------------------------
452 # The mask and the jump must be adjacent.
462 VALIDATOR: 0000000000000007: ff e0 jmp %rax
463 VALIDATOR: ERROR: Invalid indirect jump
464 VALIDATOR: Checking jump targets: 0 to 9
465 VALIDATOR: Checking that basic blocks are aligned
466 *** <input> IS UNSAFE ***
468 0000000000000000: 83 e0 e0 and %eax, 0xe0
469 0000000000000003: 90 nop
470 0000000000000004: 4c 01 f8 add %rax, %r15
471 0000000000000007: ff e0 jmp %rax
473 7: [0] unrecognized instruction
475 ----------------------------------------------------------------------
486 VALIDATOR: 0000000000000007: ff e0 jmp %rax
487 VALIDATOR: ERROR: Invalid indirect jump
488 VALIDATOR: Checking jump targets: 0 to 9
489 VALIDATOR: Checking that basic blocks are aligned
490 *** <input> IS UNSAFE ***
492 0000000000000000: 83 e0 e0 and %eax, 0xe0
493 0000000000000003: 4c 01 f8 add %rax, %r15
494 0000000000000006: 90 nop
495 0000000000000007: ff e0 jmp %rax
497 7: [0] unrecognized instruction
499 ----------------------------------------------------------------------
501 # Jumping into the middle of the superinstruction must be rejected.
511 VALIDATOR: Checking jump targets: 0 to a
512 VALIDATOR: ERROR: 6: Bad jump target
513 VALIDATOR: Checking that basic blocks are aligned
514 *** <input> IS UNSAFE ***
516 0000000000000000: 83 e0 e0 and %eax, 0xe0
517 0000000000000003: 4c 01 f8 add %rax, %r15
518 0000000000000006: ff e0 jmp %rax
519 0000000000000008: eb fc jmp 0x6
521 8: [0] bad jump target
523 @validators_disagree:
524 Difference in jump reporting.
525 ----------------------------------------------------------------------
536 VALIDATOR: Checking jump targets: 0 to a
537 VALIDATOR: ERROR: 3: Bad jump target
538 VALIDATOR: Checking that basic blocks are aligned
539 *** <input> IS UNSAFE ***
541 0000000000000000: 83 e0 e0 and %eax, 0xe0
542 0000000000000003: 4c 01 f8 add %rax, %r15
543 0000000000000006: ff e0 jmp %rax
544 0000000000000008: eb f9 jmp 0x3
546 8: [0] bad jump target
548 @validators_disagree:
550 Difference in jump reporting.
551 ----------------------------------------------------------------------
553 # Read-only access to special registers is allowed.
565 VALIDATOR: Checking jump targets: 0 to 8
566 VALIDATOR: Checking that basic blocks are aligned
567 *** <input> is safe ***
569 0000000000000000: 50 push %rax
570 0000000000000001: 55 push %rbp
571 0000000000000002: 54 push %rsp
572 0000000000000003: 41 57 push %r15
573 0000000000000005: 48 89 e0 mov %rax, %rsp
576 ----------------------------------------------------------------------
578 # Write access to special registers is not allowed.
582 VALIDATOR: Checking jump targets: 0 to 1
583 VALIDATOR: Checking that basic blocks are aligned
584 *** <input> is safe ***
586 0000000000000000: 58 pop %rax
589 ----------------------------------------------------------------------
594 VALIDATOR: 0000000000000000: 5d pop %rbp
595 VALIDATOR: ERROR: Illegal change to register RBP
596 VALIDATOR: Checking jump targets: 0 to 1
597 VALIDATOR: Checking that basic blocks are aligned
598 *** <input> IS UNSAFE ***
600 0000000000000000: 5d pop %rbp
602 0: [0] error - %bpl or %bp is changed
604 ----------------------------------------------------------------------
609 VALIDATOR: 0000000000000000: 5c pop %rsp
610 VALIDATOR: ERROR: Illegal assignment to RSP
611 VALIDATOR: Checking jump targets: 0 to 1
612 VALIDATOR: Checking that basic blocks are aligned
613 *** <input> IS UNSAFE ***
615 0000000000000000: 5c pop %rsp
617 0: [0] error - %spl or %sp is changed
619 ----------------------------------------------------------------------
624 VALIDATOR: 0000000000000000: 41 5f pop %r15
625 VALIDATOR: ERROR: Illegal to change the value of register RegR15
626 VALIDATOR: Checking jump targets: 0 to 2
627 VALIDATOR: Checking that basic blocks are aligned
628 *** <input> IS UNSAFE ***
630 0000000000000000: 41 5f pop %r15
632 0: [0] error - %r15 is changed
634 ----------------------------------------------------------------------
639 # mov (%r15, %rax), %ebx
642 VALIDATOR: Checking jump targets: 0 to 6
643 VALIDATOR: Checking that basic blocks are aligned
644 *** <input> is safe ***
646 0000000000000000: 89 c0 mov %eax, %eax
647 0000000000000002: 41 8b 1c 07 mov %ebx, [%r15+%rax*1]
650 ----------------------------------------------------------------------
652 # Test for a top-bit-set register.
655 # mov (%r15, %r12), %ebx
658 VALIDATOR: Checking jump targets: 0 to 7
659 VALIDATOR: Checking that basic blocks are aligned
660 *** <input> is safe ***
662 0000000000000000: 45 89 e4 mov %r12d, %r12d
663 0000000000000003: 43 8b 1c 27 mov %ebx, [%r15+%r12*1]
666 ----------------------------------------------------------------------
668 # Check %edi and %esi because the first 'mov' also begins superinstructions.
671 # mov (%r15, %rdi), %ebx
674 VALIDATOR: Checking jump targets: 0 to 6
675 VALIDATOR: Checking that basic blocks are aligned
676 *** <input> is safe ***
678 0000000000000000: 89 ff mov %edi, %edi
679 0000000000000002: 41 8b 1c 3f mov %ebx, [%r15+%rdi*1]
682 ----------------------------------------------------------------------
686 # mov (%r15, %rsi), %ebx
689 VALIDATOR: Checking jump targets: 0 to 6
690 VALIDATOR: Checking that basic blocks are aligned
691 *** <input> is safe ***
693 0000000000000000: 89 f6 mov %esi, %esi
694 0000000000000002: 41 8b 1c 37 mov %ebx, [%r15+%rsi*1]
697 ----------------------------------------------------------------------
699 # Check mask on its own.
703 VALIDATOR: Checking jump targets: 0 to 2
704 VALIDATOR: Checking that basic blocks are aligned
705 *** <input> is safe ***
707 0000000000000000: 89 c0 mov %eax, %eax
710 ----------------------------------------------------------------------
712 # mov (%r15, %rax), %ebx
715 VALIDATOR: 0000000000000000: 41 8b 1c 07 mov %ebx, [%r15+%rax*1]
716 VALIDATOR: ERROR: Invalid index register in memory offset
717 VALIDATOR: Checking jump targets: 0 to 4
718 VALIDATOR: Checking that basic blocks are aligned
719 *** <input> IS UNSAFE ***
721 0000000000000000: 41 8b 1c 07 mov %ebx, [%r15+%rax*1]
723 0: [0] improper memory address - bad index
725 ----------------------------------------------------------------------
729 # mov (%r15, %rax), %ebx
734 VALIDATOR: Checking jump targets: 0 to 8
735 VALIDATOR: ERROR: 2: Bad jump target
736 VALIDATOR: Checking that basic blocks are aligned
737 *** <input> IS UNSAFE ***
739 0000000000000000: 89 c0 mov %eax, %eax
740 0000000000000002: 41 8b 1c 07 mov %ebx, [%r15+%rax*1]
741 0000000000000006: eb fa jmp 0x2
743 6: [0] bad jump target
745 @validators_disagree:
746 Difference in jump reporting.
747 ----------------------------------------------------------------------
749 # Check that post-conditions do not leak from a superinstruction. In the
750 # PyDFA validator, to share DFT states, the first instruction of the
751 # nacljmp, "and $~31, %eax", records a post-condition, just as when it is
752 # used on its own. Although the code below is safe, we don't really want
753 # the post-condition to leak through.
760 # %rax should not be regarded as zero-extended here.
761 # mov (%r15, %rax), %ebx
764 VALIDATOR: 0000000000000008: 41 8b 1c 07 mov %ebx, [%r15+%rax*1]
765 VALIDATOR: ERROR: Invalid index register in memory offset
766 VALIDATOR: Checking jump targets: 0 to c
767 VALIDATOR: Checking that basic blocks are aligned
768 *** <input> IS UNSAFE ***
770 0000000000000000: 83 e0 e0 and %eax, 0xe0
771 0000000000000003: 4c 01 f8 add %rax, %r15
772 0000000000000006: ff e0 jmp %rax
773 0000000000000008: 41 8b 1c 07 mov %ebx, [%r15+%rax*1]
775 8: [0] improper memory address - bad index
777 ----------------------------------------------------------------------
781 # lea (%r15, %rdi), %rdi
783 # rep stos %al, %es:(%rdi)
785 # %rdi should not be regarded as zero-extended here.
786 # mov (%r15, %rdi), %ebx
789 VALIDATOR: 0000000000000008: 41 8b 1c 3f mov %ebx, [%r15+%rdi*1]
790 VALIDATOR: ERROR: Invalid index register in memory offset
791 VALIDATOR: Checking jump targets: 0 to c
792 VALIDATOR: Checking that basic blocks are aligned
793 *** <input> IS UNSAFE ***
795 0000000000000000: 89 ff mov %edi, %edi
796 0000000000000002: 49 8d 3c 3f lea %rdi, [%r15+%rdi*1]
797 0000000000000006: f3 aa stosb [%rdi]
798 0000000000000008: 41 8b 1c 3f mov %ebx, [%r15+%rdi*1]
800 8: [0] improper memory address - bad index
802 ----------------------------------------------------------------------
806 # lea (%r15, %rsi), %rsi
810 # lea (%r15, %rdi), %rdi
812 # rep movsb %ds:(%rsi), %es:(%rdi)
814 # %rsi should not be regarded as zero-extended here.
815 # mov (%r15, %rsi), %ebx
818 VALIDATOR: 000000000000000e: 41 8b 1c 37 mov %ebx, [%r15+%rsi*1]
819 VALIDATOR: ERROR: Invalid index register in memory offset
820 VALIDATOR: Checking jump targets: 0 to 12
821 VALIDATOR: Checking that basic blocks are aligned
822 *** <input> IS UNSAFE ***
824 0000000000000000: 89 f6 mov %esi, %esi
825 0000000000000002: 49 8d 34 37 lea %rsi, [%r15+%rsi*1]
826 0000000000000006: 89 ff mov %edi, %edi
827 0000000000000008: 49 8d 3c 3f lea %rdi, [%r15+%rdi*1]
828 000000000000000c: f3 a4 movsb [%rdi], [%rsi]
829 000000000000000e: 41 8b 1c 37 mov %ebx, [%r15+%rsi*1]
831 e: [0] improper memory address - bad index
833 ----------------------------------------------------------------------
835 # Non-%r15-based memory accesses.
836 # mov 0x1234(%rip), %eax
838 # mov 0x1234(%rsp), %eax
840 # mov 0x1234(%rbp), %eax
843 VALIDATOR: Checking jump targets: 0 to 13
844 VALIDATOR: Checking that basic blocks are aligned
845 *** <input> is safe ***
847 0000000000000000: 8b 05 34 12 00 00 mov %eax, [%rip+0x1234]
848 0000000000000006: 8b 84 24 34 12 00 00 mov %eax, [%rsp+0x1234]
849 000000000000000d: 8b 85 34 12 00 00 mov %eax, [%rbp+0x1234]
852 ----------------------------------------------------------------------
854 # mov 0x1234(%rsp, %rbx), %eax
857 VALIDATOR: 0000000000000000: 8b 84 1c 34 12 00 00 mov %eax, [%rsp+%rbx*1+0x1234]
858 VALIDATOR: ERROR: Invalid index register in memory offset
859 VALIDATOR: Checking jump targets: 0 to 7
860 VALIDATOR: Checking that basic blocks are aligned
861 *** <input> IS UNSAFE ***
863 0000000000000000: 8b 84 1c 34 12 00 00 mov %eax, [%rsp+%rbx*1+0x1234]
865 0: [0] improper memory address - bad index
867 ----------------------------------------------------------------------
869 # mov 0x1234(%rbp, %rbx), %eax
872 VALIDATOR: 0000000000000000: 8b 84 1d 34 12 00 00 mov %eax, [%rbp+%rbx*1+0x1234]
873 VALIDATOR: ERROR: Invalid index register in memory offset
874 VALIDATOR: Checking jump targets: 0 to 7
875 VALIDATOR: Checking that basic blocks are aligned
876 *** <input> IS UNSAFE ***
878 0000000000000000: 8b 84 1d 34 12 00 00 mov %eax, [%rbp+%rbx*1+0x1234]
880 0: [0] improper memory address - bad index
882 ----------------------------------------------------------------------
886 # mov 0x1234(%rsp, %rbx), %eax
889 VALIDATOR: Checking jump targets: 0 to 9
890 VALIDATOR: Checking that basic blocks are aligned
891 *** <input> is safe ***
893 0000000000000000: 89 db mov %ebx, %ebx
894 0000000000000002: 8b 84 1c 34 12 00 00 mov %eax, [%rsp+%rbx*1+0x1234]
897 ----------------------------------------------------------------------
901 # mov 0x1234(%rbp, %rbx), %eax
904 VALIDATOR: Checking jump targets: 0 to 9
905 VALIDATOR: Checking that basic blocks are aligned
906 *** <input> is safe ***
908 0000000000000000: 89 db mov %ebx, %ebx
909 0000000000000002: 8b 84 1d 34 12 00 00 mov %eax, [%rbp+%rbx*1+0x1234]
912 ----------------------------------------------------------------------
914 # 'lea' is not a memory access.
915 # lea (%rbx, %rcx, 4), %rax
918 VALIDATOR: Checking jump targets: 0 to 4
919 VALIDATOR: Checking that basic blocks are aligned
920 *** <input> is safe ***
922 0000000000000000: 48 8d 04 8b lea %rax, [%rbx+%rcx*4]
925 ----------------------------------------------------------------------
933 VALIDATOR: Checking jump targets: 0 to 6
934 VALIDATOR: Checking that basic blocks are aligned
935 *** <input> is safe ***
937 0000000000000000: 48 89 e5 mov %rbp, %rsp
938 0000000000000003: 48 89 ec mov %rsp, %rbp
941 ----------------------------------------------------------------------
948 VALIDATOR: Checking jump targets: 0 to 6
949 VALIDATOR: Checking that basic blocks are aligned
950 *** <input> is safe ***
952 0000000000000000: 83 c5 08 add %ebp, 0x8
953 0000000000000003: 4c 01 fd add %rbp, %r15
956 ----------------------------------------------------------------------
965 VALIDATOR: Checking jump targets: 0 to 8
966 VALIDATOR: ERROR: 3: Bad jump target
967 VALIDATOR: Checking that basic blocks are aligned
968 *** <input> IS UNSAFE ***
970 0000000000000000: 83 c5 08 add %ebp, 0x8
971 0000000000000003: 4c 01 fd add %rbp, %r15
972 0000000000000006: eb fb jmp 0x3
974 6: [0] bad jump target
976 @validators_disagree:
977 Difference in jump reporting.
978 ----------------------------------------------------------------------
980 # A stack fixup on its own is not allowed.
984 VALIDATOR: 0000000000000000: 4c 01 fd add %rbp, %r15
985 VALIDATOR: ERROR: Illegal change to register RBP
986 VALIDATOR: Checking jump targets: 0 to 3
987 VALIDATOR: Checking that basic blocks are aligned
988 *** <input> IS UNSAFE ***
990 0000000000000000: 4c 01 fd add %rbp, %r15
992 0: [0] improper %rbp sandboxing
994 ----------------------------------------------------------------------
999 VALIDATOR: 0000000000000000: 4c 01 fc add %rsp, %r15
1000 VALIDATOR: ERROR: Illegal assignment to RSP
1001 VALIDATOR: Checking jump targets: 0 to 3
1002 VALIDATOR: Checking that basic blocks are aligned
1003 *** <input> IS UNSAFE ***
1005 0000000000000000: 4c 01 fc add %rsp, %r15
1007 0: [0] improper %rsp sandboxing
1009 ----------------------------------------------------------------------
1014 VALIDATOR: 0000000000000000: 4d 01 ff add %r15, %r15
1015 VALIDATOR: ERROR: Illegal to change the value of register RegR15
1016 VALIDATOR: Checking jump targets: 0 to 3
1017 VALIDATOR: Checking that basic blocks are aligned
1018 *** <input> IS UNSAFE ***
1020 0000000000000000: 4d 01 ff add %r15, %r15
1022 0: [0] error - %r15 is changed
1024 ----------------------------------------------------------------------
1026 # Sandboxing is not required on prefetch instructions.
1027 # prefetchnta (%rax)
1030 VALIDATOR: Checking jump targets: 0 to 3
1031 VALIDATOR: Checking that basic blocks are aligned
1032 *** <input> is safe ***
1034 0000000000000000: 0f 18 00 prefetchnta [%rax]
1037 ----------------------------------------------------------------------
1039 # Segment register manipulations are forbidden
1043 VALIDATOR: 0000000000000000: 48 8e c0 mov %es, %ax
1044 VALIDATOR: ERROR: This instruction has been marked illegal by Native Client
1045 VALIDATOR: 0000000000000000: 48 8e c0 mov %es, %ax
1046 VALIDATOR: ERROR: Illegal assignment to segment register RegES
1047 VALIDATOR: Checking jump targets: 0 to 3
1048 VALIDATOR: Checking that basic blocks are aligned
1049 *** <input> IS UNSAFE ***
1051 0000000000000000: 48 8e c0 mov %es, %ax
1053 0: [0] unrecognized instruction
1055 ----------------------------------------------------------------------
1060 VALIDATOR: 0000000000000000: 48 8c c0 mov %rax, %es
1061 VALIDATOR: ERROR: This instruction has been marked illegal by Native Client
1062 VALIDATOR: Checking jump targets: 0 to 3
1063 VALIDATOR: Checking that basic blocks are aligned
1064 *** <input> IS UNSAFE ***
1066 0000000000000000: 48 8c c0 mov %rax, %es
1068 0: [0] unrecognized instruction