Commit ebb70fe
committed
M72: service worker: Make LevelDB database outlive its iterator to fix crash.
As explained in the bug by pwnall:
ServiceWorkerDatabase::GetRegistrationsForOrigin() obtains a LevelDB
iterator and calls ServiceWorkerDatabase::ReadResourceRecords() in a
loop. ReadResourceRecords() in turn calls
ServiceWorkerDatabase::HandleReadResult(), which may call
ServiceWorkerDatabase::Disable() if the status is a failure. Disable()
contains a "db_.reset()" which deletes the leveldb::DB instance. So,
ReadResourceRecords() may end up deleting the database before the
iterator used by GetRegistrationsForOrigin() is deleted. The contract
for leveldb::DB::NewIterator() [1] states that the iterator must be
deleted before the DB instance is deleted.
[1] https://cs.chromium.org/chromium/src/third_party/leveldatabase/src/include/leveldb/db.h?l=92&rcl=73d5834eceee8efa9a8ccfec77dc096a9e8ba18a
Bug: 909024
Change-Id: Ifee9aa0f7e1db9168d61b6407a11e249b2001986
Reviewed-on: https://chromium-review.googlesource.com/c/1354730
Commit-Queue: Matt Falkenhagen <falken@chromium.org>
Reviewed-by: Hiroki Nakagawa <nhiroki@chromium.org>
Reviewed-by: Victor Costan <pwnall@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#612599}(cherry picked from commit dd5d624)
Reviewed-on: https://chromium-review.googlesource.com/c/1362673
Reviewed-by: Matt Falkenhagen <falken@chromium.org>
Cr-Commit-Position: refs/branch-heads/3626@{#65}
Cr-Branched-From: d897fb1-refs/heads/master@{#612437}1 parent 8cecdfb commit ebb70fe
File tree
2 files changed
+86
-10
lines changed- content/browser/service_worker
2 files changed
+86
-10
lines changedLines changed: 25 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
397 | 397 | | |
398 | 398 | | |
399 | 399 | | |
| 400 | + | |
| 401 | + | |
400 | 402 | | |
401 | 403 | | |
402 | 404 | | |
| |||
421 | 423 | | |
422 | 424 | | |
423 | 425 | | |
| 426 | + | |
| 427 | + | |
424 | 428 | | |
425 | | - | |
426 | | - | |
427 | | - | |
428 | | - | |
429 | | - | |
430 | | - | |
431 | | - | |
432 | | - | |
433 | | - | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
434 | 449 | | |
| 450 | + | |
435 | 451 | | |
436 | 452 | | |
437 | 453 | | |
438 | | - | |
439 | 454 | | |
440 | 455 | | |
441 | 456 | | |
| |||
Lines changed: 61 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| |||
2042 | 2043 | | |
2043 | 2044 | | |
2044 | 2045 | | |
| 2046 | + | |
| 2047 | + | |
| 2048 | + | |
| 2049 | + | |
| 2050 | + | |
| 2051 | + | |
| 2052 | + | |
| 2053 | + | |
| 2054 | + | |
| 2055 | + | |
| 2056 | + | |
| 2057 | + | |
| 2058 | + | |
| 2059 | + | |
| 2060 | + | |
| 2061 | + | |
| 2062 | + | |
| 2063 | + | |
| 2064 | + | |
| 2065 | + | |
| 2066 | + | |
| 2067 | + | |
| 2068 | + | |
| 2069 | + | |
| 2070 | + | |
| 2071 | + | |
| 2072 | + | |
| 2073 | + | |
| 2074 | + | |
| 2075 | + | |
| 2076 | + | |
| 2077 | + | |
| 2078 | + | |
| 2079 | + | |
| 2080 | + | |
| 2081 | + | |
| 2082 | + | |
| 2083 | + | |
| 2084 | + | |
| 2085 | + | |
| 2086 | + | |
| 2087 | + | |
| 2088 | + | |
| 2089 | + | |
| 2090 | + | |
| 2091 | + | |
| 2092 | + | |
| 2093 | + | |
| 2094 | + | |
| 2095 | + | |
| 2096 | + | |
| 2097 | + | |
| 2098 | + | |
| 2099 | + | |
| 2100 | + | |
| 2101 | + | |
| 2102 | + | |
| 2103 | + | |
| 2104 | + | |
| 2105 | + | |
2045 | 2106 | | |
0 commit comments