Skip to content

Commit

Permalink
JIT: Fixed register clobbering during overflow handling
Browse files Browse the repository at this point in the history
Fixes oss-fuzz #44535
  • Loading branch information
dstogov committed Feb 11, 2022
1 parent 7434909 commit 912608d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 6 deletions.
12 changes: 6 additions & 6 deletions ext/opcache/jit/zend_jit_x86.dasc
Original file line number Diff line number Diff line change
Expand Up @@ -4457,11 +4457,11 @@ static int zend_jit_math_long_long(dasm_State **Dst,
(Z_MODE(op2_addr) == IS_CONST_ZVAL && Z_LVAL_P(Z_ZV(op2_addr)) == 1))) {
if (opcode == ZEND_ADD) {
|.if X64
| mov64 rax, 0x43e0000000000000
| mov64 Ra(tmp_reg), 0x43e0000000000000
if (Z_MODE(res_addr) == IS_REG) {
| movd xmm(Z_REG(res_addr)-ZREG_XMM0), rax
| movd xmm(Z_REG(res_addr)-ZREG_XMM0), Ra(tmp_reg)
} else {
| SET_ZVAL_LVAL res_addr, rax
| SET_ZVAL_LVAL res_addr, Ra(tmp_reg)
}
|.else
| SET_ZVAL_LVAL res_addr, 0
Expand All @@ -4470,11 +4470,11 @@ static int zend_jit_math_long_long(dasm_State **Dst,
break;
} else if (opcode == ZEND_SUB) {
|.if X64
| mov64 rax, 0xc3e0000000000000
| mov64 Ra(tmp_reg), 0xc3e0000000000000
if (Z_MODE(res_addr) == IS_REG) {
| movd xmm(Z_REG(res_addr)-ZREG_XMM0), rax
| movd xmm(Z_REG(res_addr)-ZREG_XMM0), Ra(tmp_reg)
} else {
| SET_ZVAL_LVAL res_addr, rax
| SET_ZVAL_LVAL res_addr, Ra(tmp_reg)
}
|.else
| SET_ZVAL_LVAL res_addr, 0x00200000
Expand Down
21 changes: 21 additions & 0 deletions ext/opcache/tests/jit/assign_dim_op_007.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
--TEST--
JIT ASSIGN_DIM_OP: overflow
--INI--
opcache.enable=1
opcache.enable_cli=1
opcache.file_update_protection=0
opcache.jit_buffer_size=1M
--FILE--
<?php
class test {
public$member;
function __construct(){
$this->member = 9223372036854775807;
$this->member += 1;
}
}
new test();
?>
DONE
--EXPECT--
DONE

0 comments on commit 912608d

Please sign in to comment.