Fix GH-21639: Protect frameless args during __toString() reentry#21815
Fix GH-21639: Protect frameless args during __toString() reentry#21815prateekbhujel wants to merge 3 commits intophp:PHP-8.4from
Conversation
|
Thanks for the PR.
I'm afraid this will need a more general solution. My hope was to avoid overhead in the VM, but it might be unavoidable for a proper fix, even if this is a largely artificial issue. |
35148db to
15ec47b
Compare
15ec47b to
c818fa7
Compare
c818fa7 to
08cc08f
Compare
08cc08f to
38e2314
Compare
|
The other alternative would be checking inside the tostring handler whether the parent frame is currently at a frameless opcode and then safely copy its CV args to a buffer, set EG(vm_interrupt) and free them on the next EG(vm_interrupt), completely moving the overhead off the main paths and be a truly generic solution. Obviously comes at a small tostring handler cost, but I'd really rather see overhead there...? |
38e2314 to
163b9ef
Compare
163b9ef to
9ae220f
Compare
|
@bwoebi Yeah, agreed. That cost belongs on the I pushed a follow-up in that direction. It checks from I did not keep the cleanup on So the copy/dtor work is on actual |
28d83f6 to
2671fc4
Compare
2671fc4 to
28d83f6
Compare
Fixes GH-21639.
Frameless internal calls can borrow CV operands directly from the caller frame. If one of those arguments is converted through
__toString(), userland can mutate the borrowed values while the frameless handler is still reading them.This keeps the fix on the actual reentry path:
__toString()runs from a frameless call, keep copies of string/array CV operands for that active frameless opcodeTests run: