Commit 4a843ef
committed
Fix GH-21776: use-after-free in zend_std_read_property magic __isset
When __isset drops the last non-temp reference to $this (e.g.
$GLOBALS['o'] = 0), the OBJ_RELEASE after the __isset call freed zobj
before zend_std_read_property reached the shared uninit_error check
at zend_lazy_object_must_init(zobj), a heap-use-after-free.
The GC_ADDREF/OBJ_RELEASE pair around __isset has been correct since
2018. The 2023 lazy-object support added a zobj read in the shared
fall-through path without extending the isset branch's ref coverage
to match. Defer the release via a local flag so zobj stays alive
through the lazy-init check and the recursive read on the initialized
instance. Route the lazy-init block's exits through a release_zobj_exit
label so the deferred release fires on those paths too, while the hot
paths that already released inline skip the flag check.
Closes GH-217761 parent 6031497 commit 4a843ef
2 files changed
Lines changed: 26 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
743 | 743 | | |
744 | 744 | | |
745 | 745 | | |
| 746 | + | |
746 | 747 | | |
747 | 748 | | |
748 | 749 | | |
| |||
937 | 938 | | |
938 | 939 | | |
939 | 940 | | |
940 | | - | |
| 941 | + | |
941 | 942 | | |
942 | 943 | | |
943 | 944 | | |
| |||
986 | 987 | | |
987 | 988 | | |
988 | 989 | | |
989 | | - | |
| 990 | + | |
990 | 991 | | |
991 | 992 | | |
992 | 993 | | |
| |||
999 | 1000 | | |
1000 | 1001 | | |
1001 | 1002 | | |
1002 | | - | |
| 1003 | + | |
1003 | 1004 | | |
1004 | 1005 | | |
1005 | 1006 | | |
1006 | | - | |
| 1007 | + | |
| 1008 | + | |
1007 | 1009 | | |
1008 | 1010 | | |
1009 | 1011 | | |
| |||
1015 | 1017 | | |
1016 | 1018 | | |
1017 | 1019 | | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
1018 | 1024 | | |
1019 | 1025 | | |
1020 | 1026 | | |
| |||
0 commit comments