Commit 19fb869
committed
task_http: fix UAF race on t->title in task_push_http_transfer_file
task_push_http_transfer_file() was assigning t->title AFTER
task_push_http_transfer_generic() had already published the task to
the queue with task_queue_push(). Worker threads can pick up,
execute, and finalise (free) a published task at any time --
retro_task_regular_gather() / task_queue_remove_finished() does
free(task->title); free(task) once RETRO_TASK_FLG_FINISHED is set
(task_queue.c:213-222). If the network request resolves to an
instant failure (DNS failure, ENETUNREACH while offline, immediate
cancel) or the worker simply schedules through the task quickly
under load, the worker reaches free(t) before the file helper
writes t->title. The post-push write is then a heap-use-after-free.
Symptoms in the wild: glibc malloc_printerr / abort during
download-heavy startup paths (core updater, asset/thumbnail packs),
backtrace pointing into task_http_transfer_cleanup or task_queue
finalise, no obvious smoking gun in the source it points at.
Fix: split task_push_http_transfer_generic() into a titled variant
that sets t->title before task_queue_push(). The non-titled wrapper
preserves the existing behaviour for the seven other callers (POST,
WebDAV verbs, content-bearing requests) which do not assign title.
task_push_http_transfer_file() now builds the title string locally
first and passes it through, eliminating the post-publication write.
Verified with an ASan harness mirroring the wo1 parent 644d71d commit 19fb869
1 file changed
Lines changed: 30 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
252 | 252 | | |
253 | 253 | | |
254 | 254 | | |
255 | | - | |
| 255 | + | |
256 | 256 | | |
257 | 257 | | |
| 258 | + | |
258 | 259 | | |
259 | 260 | | |
260 | 261 | | |
| |||
321 | 322 | | |
322 | 323 | | |
323 | 324 | | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
324 | 336 | | |
325 | 337 | | |
326 | 338 | | |
| |||
334 | 346 | | |
335 | 347 | | |
336 | 348 | | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
337 | 358 | | |
338 | 359 | | |
339 | 360 | | |
| |||
458 | 479 | | |
459 | 480 | | |
460 | 481 | | |
461 | | - | |
462 | 482 | | |
463 | 483 | | |
464 | 484 | | |
465 | 485 | | |
466 | | - | |
467 | | - | |
468 | | - | |
469 | | - | |
470 | | - | |
471 | | - | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
472 | 490 | | |
473 | 491 | | |
474 | 492 | | |
| |||
485 | 503 | | |
486 | 504 | | |
487 | 505 | | |
488 | | - | |
489 | | - | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
490 | 510 | | |
491 | 511 | | |
492 | 512 | | |
| |||
0 commit comments