Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(430)

Issue 937813002: Close a window for a race with the system linker (Closed)

Created:
5 years, 10 months ago by simonb (inactive)
Modified:
5 years, 10 months ago
CC:
chromium-reviews, aelias_OOO_until_Jul13, no sievers
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Close a window for a race with the system linker Lock globals at the head of Add/DelEntryImpl() callback handlers. The crazy linker exports updates to _r_debug pages to the UI thread if a callback poster function has been supplied. At the time the callback is posted, the crazy linker holds the globals lock, used to prevent other threads from loading libraries (in particular through ::dlopen(), used for system libraries). When the callback is received on a different thread the receiving code needs to reacquire the lock. Make the globals lock reentrant. If there is no callback poster function then the updates to _r_debug pages happen immediately on the current thread. Here the globals lock is already held. Reentrancy ensures that we do not deadlock in that case. Fix potential inaccuracy when looking for the page to mprotect. The addresses checked for writability are currently the start of the object being modified. This is 12 or 16 bytes (on arm, 24 or 32 bytes on arm64) below the address that will actually be written, and not guaranteed to be in the same memory page where the object crosses a page boundary. Workround for races with the system linker over _r_debug protections. There is no way to safely and accurately sense whether _r_debug is in a readonly page -- we might read while the system linker is in the process of writing to it, and conclude that it is not readonly when it is. Similarly, we may set it read/write, update pointers, and then set it readonly between the system linker setting it to read/write and updating pointers. To work round this, we always map it to read/write, no matter its apparent initial state, and never map it back to readonly. This may leave a small security hole, but it is better than the alternatives (typically, a crash). BUG=450659, 458346 Committed: https://crrev.com/cd5c4353b052baa4d96925cb46f47e16a697f0e1 Cr-Commit-Position: refs/heads/master@{#317314}

Patch Set 1 #

Total comments: 2

Patch Set 2 : Update for review comments #

Patch Set 3 : Updates following sync-up meeting #

Total comments: 9

Patch Set 4 : Update for more review comments #

Unified diffs Side-by-side diffs Delta from patch set Stats (+67 lines, -37 lines) Patch
M third_party/android_crazy_linker/README.chromium View 1 chunk +2 lines, -0 lines 0 comments Download
M third_party/android_crazy_linker/src/src/crazy_linker_globals.cpp View 1 chunk +4 lines, -1 line 0 comments Download
M third_party/android_crazy_linker/src/src/crazy_linker_rdebug.h View 1 1 chunk +1 line, -0 lines 0 comments Download
M third_party/android_crazy_linker/src/src/crazy_linker_rdebug.cpp View 1 2 3 9 chunks +60 lines, -36 lines 0 comments Download

Messages

Total messages: 20 (6 generated)
simonb (inactive)
5 years, 10 months ago (2015-02-18 19:52:45 UTC) #2
rmcilroy
Seems reasonable. One suggestion but otherwise LGTM. https://codereview.chromium.org/937813002/diff/1/third_party/android_crazy_linker/src/src/crazy_linker_rdebug.cpp File third_party/android_crazy_linker/src/src/crazy_linker_rdebug.cpp (right): https://codereview.chromium.org/937813002/diff/1/third_party/android_crazy_linker/src/src/crazy_linker_rdebug.cpp#newcode449 third_party/android_crazy_linker/src/src/crazy_linker_rdebug.cpp:449: after->l_prev = ...
5 years, 10 months ago (2015-02-19 11:00:26 UTC) #5
rmcilroy
Actually one final suggestion: Could you instead aquire the lock in RDebugRunnable::Run and thereby avoid ...
5 years, 10 months ago (2015-02-19 11:07:03 UTC) #6
simonb (inactive)
https://codereview.chromium.org/937813002/diff/1/third_party/android_crazy_linker/src/src/crazy_linker_rdebug.cpp File third_party/android_crazy_linker/src/src/crazy_linker_rdebug.cpp (right): https://codereview.chromium.org/937813002/diff/1/third_party/android_crazy_linker/src/src/crazy_linker_rdebug.cpp#newcode449 third_party/android_crazy_linker/src/src/crazy_linker_rdebug.cpp:449: after->l_prev = entry; On 2015/02/19 11:00:26, rmcilroy wrote: > ...
5 years, 10 months ago (2015-02-19 14:27:53 UTC) #8
simonb (inactive)
On 2015/02/19 11:07:03, rmcilroy wrote: > Actually one final suggestion: Could you instead aquire the ...
5 years, 10 months ago (2015-02-19 14:29:25 UTC) #9
rmcilroy
On 2015/02/19 14:29:25, simonb wrote: > On 2015/02/19 11:07:03, rmcilroy wrote: > > Actually one ...
5 years, 10 months ago (2015-02-19 15:57:30 UTC) #10
simonb (inactive)
Updated to reflect latest thinking. Currently testing (overnight) on a nexus4 which has shown the ...
5 years, 10 months ago (2015-02-19 19:35:07 UTC) #11
simonb (inactive)
> Currently testing (overnight) ... More than 2k invocations overnight without problems. Before patch set ...
5 years, 10 months ago (2015-02-20 11:12:03 UTC) #12
rmcilroy
One suggestion and a couple of nits, but otherwise lgtm. https://codereview.chromium.org/937813002/diff/40001/third_party/android_crazy_linker/src/src/crazy_linker_rdebug.cpp File third_party/android_crazy_linker/src/src/crazy_linker_rdebug.cpp (right): https://codereview.chromium.org/937813002/diff/40001/third_party/android_crazy_linker/src/src/crazy_linker_rdebug.cpp#newcode159 ...
5 years, 10 months ago (2015-02-20 11:17:34 UTC) #13
simonb (inactive)
https://codereview.chromium.org/937813002/diff/40001/third_party/android_crazy_linker/src/src/crazy_linker_rdebug.cpp File third_party/android_crazy_linker/src/src/crazy_linker_rdebug.cpp (right): https://codereview.chromium.org/937813002/diff/40001/third_party/android_crazy_linker/src/src/crazy_linker_rdebug.cpp#newcode159 third_party/android_crazy_linker/src/src/crazy_linker_rdebug.cpp:159: class ScopedPageMapper { On 2015/02/20 11:17:33, rmcilroy wrote: > ...
5 years, 10 months ago (2015-02-20 12:52:57 UTC) #15
rmcilroy
lgtm, thanks. https://codereview.chromium.org/937813002/diff/40001/third_party/android_crazy_linker/src/src/crazy_linker_rdebug.cpp File third_party/android_crazy_linker/src/src/crazy_linker_rdebug.cpp (right): https://codereview.chromium.org/937813002/diff/40001/third_party/android_crazy_linker/src/src/crazy_linker_rdebug.cpp#newcode176 third_party/android_crazy_linker/src/src/crazy_linker_rdebug.cpp:176: page_address_ = 0; On 2015/02/20 12:52:56, simonb ...
5 years, 10 months ago (2015-02-20 13:25:52 UTC) #16
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/937813002/60001
5 years, 10 months ago (2015-02-20 13:48:12 UTC) #18
commit-bot: I haz the power
Committed patchset #4 (id:60001)
5 years, 10 months ago (2015-02-20 14:15:47 UTC) #19
commit-bot: I haz the power
5 years, 10 months ago (2015-02-20 14:16:44 UTC) #20
Message was sent while issue was closed.
Patchset 4 (id:??) landed as
https://crrev.com/cd5c4353b052baa4d96925cb46f47e16a697f0e1
Cr-Commit-Position: refs/heads/master@{#317314}

Powered by Google App Engine
This is Rietveld 408576698