-
Notifications
You must be signed in to change notification settings - Fork 7.9k
fix: dangling opline in ZEND_INIT_ARRAY #18578
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
Conversation
This causes problems if an allocation profiler decides to walk the stack, or if the engine itself OOMs on this opcode, and it tries to print file and line information.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SAVE_OPLINE is only needed for zend_hash_real_init_mixed.
No, it's any allocation. The crash reports have 6435 ZEND_VM_HANDLER(71, ZEND_INIT_ARRAY, CONST|TMP|VAR|CV|UNUSED, CONST|TMPVAR|UNUSED|NEXT|CV, ARRAY_INIT|REF)
6436 {
6437 zval *array;
6438 uint32_t size;
6439 USE_OPLINE
6440
SAVE_OPLINE();
6441 array = EX_VAR(opline->result.var);
6442 if (OP1_TYPE != IS_UNUSED) {
6443 size = opline->extended_value >> ZEND_ARRAY_SIZE_SHIFT;
6444 ZVAL_ARR(array, zend_new_array(size));
6445 /* Explicitly initialize array as not-packed if flag is set */
6446 if (opline->extended_value & ZEND_ARRAY_NOT_PACKED) {
6447 zend_hash_real_init_mixed(Z_ARRVAL_P(array));
6448 }
6449 ZEND_VM_DISPATCH_TO_HANDLER(ZEND_ADD_ARRAY_ELEMENT);
6450 } else {
6451 ZVAL_ARR(array, zend_new_array(0));
6452 ZEND_VM_NEXT_OPCODE();
6453 }
6454 } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, I must have brainfarted.
* PHP-8.4: Fix OSS-Fuzz #418106144 Fix OSS-Fuzz #417078295 fix: dangling opline in ZEND_INIT_ARRAY (#18578)
This causes problems if an allocation profiler decides to walk the stack, or if the engine itself OOMs on this opcode, and it tries to print file and line information.
This is similar to #12648 and #12758. Targeting PHP 8.3.
I don't have a reproducer for this one yet. You can see from prior issues that you have to manipulate the frames and such, so it's a bit tricky. I have two customer crash reports with
ZEND_INIT_ARRAY_SPEC_TMP_UNUSED_HANDLER
, so I know it's reachable, I just haven't figured out exactly how to do reproduce it yet.