Commit 5d82a8b
[backport] CVE-2025-5068 (2/2)
Enforce SharedWorker::Terminate() procedure order
During the investigation of crbug.com/409059706, we observed that
PerformShutdownOnWorkerThread() is called during the status is
running.
I suppose the root cause is race condition between `Terminate()`
procedure and a child process termination procedure in different
thread. WorkerThread can be terminated if two conditions are met;
`Terminate()` is called and all child worker threads have been
terminated. Both `Terminate()` and the child process termination
procedure may call `PerformShutdownOnWorkerThread()`, and former
is executed regardless of two conditions are met. The latter
is called if `Terminate()` is called and no child processes.
To be clear, "`Terminate()` is called" does not mean
`PrepareForShutdownOnWorkerThread()` is executed. `Terminate()`
queues it after the flag to tell `Terminate()` call. And, when
the issue happen, I am quite sure the flag is set but,
`PrepareForShutdownOnWorkerThread()` won't be executed yet.
The fix is that:
1. The "Terminate() is called" flag to be multi staged.
The flag is used for two purpose; a. avoid re-enter of
`Terminate()`, and b. `PrepareForShutdownOnWorkerThread()` is
in flight. The CL changed the flag to enum to represent
the stage properly.
2. `PerformShutdownOnWorkerThread()` is queued even if it is
called within the child process termination procedure.
It avoid the execution order flip between
`PrepareForShutdownOnWorkerThread()` and
`PerformShutdownOnWorkerThread()`.
In addition, this change ensures `PerformShutdownOnWorkerThread()`
is called once. While `PerformShutdownOnWorkerThread()` touches
fields inside, the fields must not be touched at some point within
the function, the function is actually not re-entrant when it reaches
to the end. Upon mikt@ suggestion, I made
`PerformShutdownOnWorkerThread()` is called only when two conditions
are fulfilled. i.e. `Terminate()` is called and the number of child
threads is 0. Also, the CL uses the enum to show
`PerformShutdownOnWorkerThread()` is in-flight to avoid re-entrance
in this level.
Bug: 409059706
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6543412
Change-Id: I0e3f26e04c7374ab4df3c000845f8c57a9ef2906
Reviewed-on: https://codereview.qt-project.org/c/qt/qtwebengine-chromium/+/650560
Reviewed-by: Anu Aliyas <[email protected]>1 parent 11fc420 commit 5d82a8b
File tree
4 files changed
+105
-21
lines changed- chromium/third_party/blink
- common
- public/common
- renderer/core/workers
4 files changed
+105
-21
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2652 | 2652 | | |
2653 | 2653 | | |
2654 | 2654 | | |
| 2655 | + | |
| 2656 | + | |
| 2657 | + | |
| 2658 | + | |
| 2659 | + | |
| 2660 | + | |
| 2661 | + | |
2655 | 2662 | | |
2656 | 2663 | | |
2657 | 2664 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1744 | 1744 | | |
1745 | 1745 | | |
1746 | 1746 | | |
| 1747 | + | |
| 1748 | + | |
1747 | 1749 | | |
1748 | 1750 | | |
1749 | 1751 | | |
| |||
Lines changed: 85 additions & 19 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
279 | 279 | | |
280 | 280 | | |
281 | 281 | | |
282 | | - | |
| 282 | + | |
283 | 283 | | |
284 | | - | |
| 284 | + | |
| 285 | + | |
285 | 286 | | |
286 | 287 | | |
287 | 288 | | |
| |||
297 | 298 | | |
298 | 299 | | |
299 | 300 | | |
300 | | - | |
301 | | - | |
302 | | - | |
303 | | - | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
304 | 328 | | |
305 | 329 | | |
306 | 330 | | |
| |||
439 | 463 | | |
440 | 464 | | |
441 | 465 | | |
442 | | - | |
| 466 | + | |
443 | 467 | | |
444 | 468 | | |
445 | 469 | | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
446 | 476 | | |
447 | | - | |
448 | | - | |
449 | 477 | | |
450 | 478 | | |
451 | 479 | | |
452 | 480 | | |
453 | 481 | | |
454 | | - | |
455 | | - | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
456 | 508 | | |
457 | 509 | | |
458 | 510 | | |
| |||
787 | 839 | | |
788 | 840 | | |
789 | 841 | | |
790 | | - | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
791 | 848 | | |
792 | 849 | | |
793 | 850 | | |
794 | 851 | | |
795 | 852 | | |
796 | | - | |
797 | | - | |
798 | | - | |
799 | | - | |
800 | | - | |
801 | | - | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
802 | 868 | | |
803 | 869 | | |
804 | 870 | | |
| |||
855 | 921 | | |
856 | 922 | | |
857 | 923 | | |
858 | | - | |
| 924 | + | |
859 | 925 | | |
860 | 926 | | |
861 | 927 | | |
| |||
Lines changed: 11 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
321 | 321 | | |
322 | 322 | | |
323 | 323 | | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
324 | 331 | | |
325 | 332 | | |
326 | 333 | | |
| |||
417 | 424 | | |
418 | 425 | | |
419 | 426 | | |
420 | | - | |
421 | | - | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
422 | 431 | | |
423 | 432 | | |
424 | 433 | | |
| |||
0 commit comments