Commit 3f3da90
committed
php#146 flock: pin task across SUSPEND to keep inline-tail flock_data alive
ASAN: heap-use-after-free in php_stdiop_set_option at the post-SUSPEND
read of flock_data->result. flock_data is the inline tail of the libuv
task; the scheduler's WAKER_CLEAN_EVENTS runs between worker completion
and SUSPEND returning, releases the task's last ref, and libuv_task_dispose
pefree's the whole region — including flock_data — before our code wakes.
Fix: ADD_REF the task before SUSPEND, snapshot result/error_code into
locals after SUSPEND, then RELEASE. All error paths matched.
Repro: ext/async/tests/io/081-flock_non_blocking_event_loop.phpt under
LINUX_X64_DEBUG_ZTS_ASAN (PR php#149 job 77702704014). Local ASAN sweep on
ext/async/tests + ext/standard/tests/file + Zend/tests: 6795/6798 pass,
3 pre-existing unrelated fails (gh19983, 050/052 thread shutdown), no
new UAFs.1 parent 17dd197 commit 3f3da90
1 file changed
Lines changed: 11 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1244 | 1244 | | |
1245 | 1245 | | |
1246 | 1246 | | |
| 1247 | + | |
| 1248 | + | |
| 1249 | + | |
| 1250 | + | |
1247 | 1251 | | |
1248 | 1252 | | |
| 1253 | + | |
1249 | 1254 | | |
1250 | 1255 | | |
1251 | 1256 | | |
1252 | | - | |
| 1257 | + | |
| 1258 | + | |
| 1259 | + | |
| 1260 | + | |
| 1261 | + | |
1253 | 1262 | | |
1254 | 1263 | | |
1255 | 1264 | | |
1256 | 1265 | | |
1257 | | - | |
| 1266 | + | |
1258 | 1267 | | |
1259 | 1268 | | |
1260 | 1269 | | |
| |||
0 commit comments