Skip to content

Fix circumvented added hooks in JIT #17870

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix prop_info_offset calculation
Z_PROP_TABLE_OFFSET already gives us an index into a void* array. Thus,
we only need to multiply by sizeof(void*).
  • Loading branch information
iluuu1994 committed Feb 21, 2025
commit 7042ec60643cf3e348076bef2d82b38646c38af3
12 changes: 4 additions & 8 deletions ext/opcache/jit/zend_jit_ir.c
Original file line number Diff line number Diff line change
Expand Up @@ -14376,8 +14376,7 @@ static int zend_jit_fetch_obj(zend_jit_ctx *jit,
if (ce && ce->ce_flags & ZEND_ACC_IMMUTABLE) {
ref = ir_CONST_ADDR(prop_info);
} else {
int prop_info_offset =
(((Z_PROP_TABLE_OFFSET(prop_info) - (sizeof(zend_object) - sizeof(zval))) / sizeof(zval)) * sizeof(void*));
int prop_info_offset = Z_PROP_TABLE_OFFSET(prop_info) * sizeof(void*);

ref = ir_LOAD_A(ir_ADD_OFFSET(obj_ref, offsetof(zend_object, ce)));
ref = ir_LOAD_A(ir_ADD_OFFSET(ref, offsetof(zend_class_entry, properties_info_table)));
Expand Down Expand Up @@ -14777,8 +14776,7 @@ static int zend_jit_assign_obj(zend_jit_ctx *jit,
if (ce && ce->ce_flags & ZEND_ACC_IMMUTABLE) {
ref = ir_CONST_ADDR(prop_info);
} else {
int prop_info_offset =
(((Z_PROP_TABLE_OFFSET(prop_info) - (sizeof(zend_object) - sizeof(zval))) / sizeof(zval)) * sizeof(void*));
int prop_info_offset = Z_PROP_TABLE_OFFSET(prop_info) * sizeof(void*);

ref = ir_LOAD_A(ir_ADD_OFFSET(obj_ref, offsetof(zend_object, ce)));
ref = ir_LOAD_A(ir_ADD_OFFSET(ref, offsetof(zend_class_entry, properties_info_table)));
Expand Down Expand Up @@ -15133,8 +15131,7 @@ static int zend_jit_assign_obj_op(zend_jit_ctx *jit,
if (ce && ce->ce_flags & ZEND_ACC_IMMUTABLE) {
ref = ir_CONST_ADDR(prop_info);
} else {
int prop_info_offset =
(((Z_PROP_TABLE_OFFSET(prop_info) - (sizeof(zend_object) - sizeof(zval))) / sizeof(zval)) * sizeof(void*));
int prop_info_offset = Z_PROP_TABLE_OFFSET(prop_info) * sizeof(void*);

ref = ir_LOAD_A(ir_ADD_OFFSET(obj_ref, offsetof(zend_object, ce)));
ref = ir_LOAD_A(ir_ADD_OFFSET(ref, offsetof(zend_class_entry, properties_info_table)));
Expand Down Expand Up @@ -15523,8 +15520,7 @@ static int zend_jit_incdec_obj(zend_jit_ctx *jit,
if (ce && ce->ce_flags & ZEND_ACC_IMMUTABLE) {
ref = ir_CONST_ADDR(prop_info);
} else {
int prop_info_offset =
(((Z_PROP_TABLE_OFFSET(prop_info) - (sizeof(zend_object) - sizeof(zval))) / sizeof(zval)) * sizeof(void*));
int prop_info_offset = Z_PROP_TABLE_OFFSET(prop_info) * sizeof(void*);

ref = ir_LOAD_A(ir_ADD_OFFSET(obj_ref, offsetof(zend_object, ce)));
ref = ir_LOAD_A(ir_ADD_OFFSET(ref, offsetof(zend_class_entry, properties_info_table)));
Expand Down
Loading