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

Issue 2844333003: [Sync] Address use-after-free in Directory::InsertEntry (Closed)

Created:
3 years, 7 months ago by pavely
Modified:
3 years, 7 months ago
Reviewers:
skym
CC:
chromium-reviews, sync-reviews_chromium.org
Target Ref:
refs/heads/master
Project:
chromium
Visibility:
Public.

Description

[Sync] Address use-after-free in Directory::InsertEntry Directory::InsertEntry takes pointer to EntryKernel and inserts owning pointer into methandles_mapo with WrapUnique. The object is still owned by unique_ptr in ModelNeutralMutableEntry ctor. If one if the steps inside InsertEntry fails ModelNeutralMutableEntry will not release unique_ptr which will cause object to be freed while metahandles map still has entry pointing to it. I changed InsertEntry to pass ownint pointer to EntryKernel. Caller is free to stash non-owning pointer, but has to reset it to nullptr if InsertEntry fails. I refactored couple of functions in Directory to be more strict with pointers to EntryKernel. Particularly DeleteEntry should use entry found in metahandles_map, not the entry passed as an argument to remove entry from different indices. It shouldn't matter in terms of correctness, but makes it easier to reason about the logic. BUG=705704 R=skym@chromium.org Review-Url: https://codereview.chromium.org/2844333003 Cr-Commit-Position: refs/heads/master@{#468102} Committed: https://chromium.googlesource.com/chromium/src/+/34f7b0fb34457f5442bd7798a754872ee9a4e499

Patch Set 1 #

Unified diffs Side-by-side diffs Delta from patch set Stats (+96 lines, -89 lines) Patch
M components/sync/syncable/directory.h View 2 chunks +3 lines, -2 lines 0 comments Download
M components/sync/syncable/directory.cc View 6 chunks +31 lines, -30 lines 0 comments Download
M components/sync/syncable/model_neutral_mutable_entry.cc View 3 chunks +9 lines, -9 lines 0 comments Download
M components/sync/syncable/mutable_entry.h View 3 chunks +7 lines, -5 lines 0 comments Download
M components/sync/syncable/mutable_entry.cc View 5 chunks +46 lines, -43 lines 0 comments Download

Messages

Total messages: 7 (3 generated)
pavely
3 years, 7 months ago (2017-04-28 00:37:04 UTC) #1
skym
lgtm
3 years, 7 months ago (2017-04-28 16:01:57 UTC) #2
commit-bot: I haz the power
CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2844333003/1
3 years, 7 months ago (2017-04-28 18:27:36 UTC) #4
commit-bot: I haz the power
3 years, 7 months ago (2017-04-28 19:58:46 UTC) #7
Message was sent while issue was closed.
Committed patchset #1 (id:1) as
https://chromium.googlesource.com/chromium/src/+/34f7b0fb34457f5442bd7798a754...

Powered by Google App Engine
This is Rietveld 408576698