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

Issue 458753006: Fix use after free bug by calling GetTokenService in Core's ctor. (Closed)

Created:
6 years, 4 months ago by maniscalco
Modified:
6 years, 4 months ago
CC:
chromium-reviews
Project:
chromium
Visibility:
Public.

Description

Fix bug where TokenServiceProvider is used after it has been destroyed. There was a race condition where GetTokenService could be called on an already destroyed TokenServiceProvider (see linked bug for details). Update Core to ensure TokenServiceProvider is not destroyed out from under the token service task runner thread. BUG=401119 Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=289222

Patch Set 1 #

Patch Set 2 : Remove TokenServiceProvider interface. #

Patch Set 3 : Fix whitespace. #

Patch Set 4 : Make TokenServiceProvider RefCountedThreadSafe. #

Patch Set 5 : Update comments. #

Total comments: 2

Patch Set 6 : Update TSP comment (CANDIDATE). #

Total comments: 2
Unified diffs Side-by-side diffs Delta from patch set Stats (+75 lines, -47 lines) Patch
M chrome/browser/sync/profile_sync_components_factory_impl.cc View 1 2 3 4 chunks +7 lines, -6 lines 0 comments Download
M google_apis/gaia/oauth2_token_service_request.h View 1 2 3 4 5 4 chunks +21 lines, -11 lines 0 comments Download
M google_apis/gaia/oauth2_token_service_request.cc View 1 2 3 8 chunks +20 lines, -10 lines 2 comments Download
M google_apis/gaia/oauth2_token_service_request_unittest.cc View 1 2 3 4 chunks +8 lines, -3 lines 0 comments Download
M sync/internal_api/attachments/attachment_downloader.cc View 1 2 3 1 chunk +2 lines, -2 lines 0 comments Download
M sync/internal_api/attachments/attachment_downloader_impl.cc View 1 2 3 1 chunk +2 lines, -2 lines 0 comments Download
M sync/internal_api/attachments/attachment_downloader_impl_unittest.cc View 1 2 3 4 chunks +4 lines, -3 lines 0 comments Download
M sync/internal_api/attachments/attachment_uploader_impl.cc View 1 2 3 1 chunk +2 lines, -2 lines 0 comments Download
M sync/internal_api/attachments/attachment_uploader_impl_unittest.cc View 1 2 3 4 chunks +4 lines, -3 lines 0 comments Download
M sync/internal_api/public/attachments/attachment_downloader.h View 1 2 3 1 chunk +1 line, -1 line 0 comments Download
M sync/internal_api/public/attachments/attachment_downloader_impl.h View 1 2 3 2 chunks +2 lines, -2 lines 0 comments Download
M sync/internal_api/public/attachments/attachment_uploader_impl.h View 1 2 3 2 chunks +2 lines, -2 lines 0 comments Download

Messages

Total messages: 29 (0 generated)
maniscalco
Roger, Mihai, would you two please review this change?
6 years, 4 months ago (2014-08-11 17:51:04 UTC) #1
rohitrao (ping after 24h)
Is it possible for token_service_ to be destroyed before the OAuth2TokenServiceRequest, or is that guaranteed ...
6 years, 4 months ago (2014-08-11 18:07:17 UTC) #2
maniscalco
On 2014/08/11 18:07:17, rohitrao wrote: > Is it possible for token_service_ to be destroyed before ...
6 years, 4 months ago (2014-08-11 18:15:21 UTC) #3
Roger Tawa OOO till Jul 10th
Is there still a good reason to keep the TokenServiceProvider interface, or would it be ...
6 years, 4 months ago (2014-08-11 18:37:38 UTC) #4
maniscalco
On 2014/08/11 18:37:38, Roger Tawa wrote: > Is there still a good reason to keep ...
6 years, 4 months ago (2014-08-11 19:30:26 UTC) #5
msarda
On 2014/08/11 19:30:26, maniscalco wrote: > On 2014/08/11 18:37:38, Roger Tawa wrote: > > Is ...
6 years, 4 months ago (2014-08-12 07:55:52 UTC) #6
msarda
+Colin who actually wrote the ProfileTokenServiceProvider for CloundPrint.
6 years, 4 months ago (2014-08-12 07:56:52 UTC) #7
blundell
On 2014/08/12 07:56:52, msarda wrote: > +Colin who actually wrote the ProfileTokenServiceProvider for CloundPrint. I ...
6 years, 4 months ago (2014-08-12 13:33:05 UTC) #8
maniscalco
On 2014/08/12 13:33:05, blundell wrote: > On 2014/08/12 07:56:52, msarda wrote: > > +Colin who ...
6 years, 4 months ago (2014-08-12 16:40:29 UTC) #9
msarda
On 2014/08/12 16:40:29, maniscalco wrote: > On 2014/08/12 13:33:05, blundell wrote: > > On 2014/08/12 ...
6 years, 4 months ago (2014-08-12 16:56:51 UTC) #10
maniscalco
Mihai, understood, thanks. Sounds like patch set 3 is still a candidate. I've now added ...
6 years, 4 months ago (2014-08-12 17:35:14 UTC) #11
Roger Tawa OOO till Jul 10th
lgtm for patchset 5. https://codereview.chromium.org/458753006/diff/80001/google_apis/gaia/oauth2_token_service_request.h File google_apis/gaia/oauth2_token_service_request.h (right): https://codereview.chromium.org/458753006/diff/80001/google_apis/gaia/oauth2_token_service_request.h#newcode32 google_apis/gaia/oauth2_token_service_request.h:32: // OAuth2TokenServiceRequest thread. How is ...
6 years, 4 months ago (2014-08-12 18:09:56 UTC) #12
maniscalco
Thanks for the feedback. I've uploaded patch set 6 which clarifies a comment about who ...
6 years, 4 months ago (2014-08-12 18:27:03 UTC) #13
maniscalco
The CQ bit was checked by maniscalco@chromium.org
6 years, 4 months ago (2014-08-12 20:38:08 UTC) #14
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/maniscalco@chromium.org/458753006/100001
6 years, 4 months ago (2014-08-12 20:42:53 UTC) #15
commit-bot: I haz the power
FYI, CQ is re-trying this CL (attempt #1). The failing builders are: android_aosp on tryserver.chromium.linux ...
6 years, 4 months ago (2014-08-12 22:48:51 UTC) #16
commit-bot: I haz the power
The CQ bit was unchecked by commit-bot@chromium.org
6 years, 4 months ago (2014-08-13 00:42:29 UTC) #17
commit-bot: I haz the power
Try jobs failed on following builders: win_chromium_x64_rel on tryserver.chromium.win (http://build.chromium.org/p/tryserver.chromium.win/builders/win_chromium_x64_rel/builds/6134)
6 years, 4 months ago (2014-08-13 00:42:30 UTC) #18
maniscalco
The CQ bit was checked by maniscalco@chromium.org
6 years, 4 months ago (2014-08-13 02:35:37 UTC) #19
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/maniscalco@chromium.org/458753006/100001
6 years, 4 months ago (2014-08-13 02:37:11 UTC) #20
commit-bot: I haz the power
FYI, CQ is re-trying this CL (attempt #1). The failing builders are: win_chromium_x64_rel on tryserver.chromium.win ...
6 years, 4 months ago (2014-08-13 05:50:21 UTC) #21
blundell
lgtm with a question about a comment This code is like an onion... Now that ...
6 years, 4 months ago (2014-08-13 06:58:05 UTC) #22
blundell
On 2014/08/13 06:58:05, blundell wrote: > lgtm with a question about a comment > > ...
6 years, 4 months ago (2014-08-13 07:55:52 UTC) #23
commit-bot: I haz the power
Change committed as 289222
6 years, 4 months ago (2014-08-13 09:06:39 UTC) #24
maniscalco
I want to make sure I understand. Do you see a bug or are you ...
6 years, 4 months ago (2014-08-13 16:10:30 UTC) #25
maniscalco
https://codereview.chromium.org/458753006/diff/100001/google_apis/gaia/oauth2_token_service_request.cc File google_apis/gaia/oauth2_token_service_request.cc (right): https://codereview.chromium.org/458753006/diff/100001/google_apis/gaia/oauth2_token_service_request.cc#newcode80 google_apis/gaia/oauth2_token_service_request.cc:80: // It is important that provider_ is destroyed on ...
6 years, 4 months ago (2014-08-13 16:13:04 UTC) #26
blundell
On 2014/08/13 16:10:30, maniscalco wrote: > I want to make sure I understand. Do you ...
6 years, 4 months ago (2014-08-14 07:14:34 UTC) #27
blundell
On 2014/08/13 16:13:04, maniscalco wrote: > https://codereview.chromium.org/458753006/diff/100001/google_apis/gaia/oauth2_token_service_request.cc > File google_apis/gaia/oauth2_token_service_request.cc (right): > > https://codereview.chromium.org/458753006/diff/100001/google_apis/gaia/oauth2_token_service_request.cc#newcode80 > ...
6 years, 4 months ago (2014-08-14 07:16:54 UTC) #28
maniscalco
6 years, 4 months ago (2014-08-14 16:12:20 UTC) #29
Message was sent while issue was closed.
On 2014/08/14 07:16:54, blundell (OOO until August 25) wrote:
> On 2014/08/13 16:13:04, maniscalco wrote:
> >
>
https://codereview.chromium.org/458753006/diff/100001/google_apis/gaia/oauth2...
> > File google_apis/gaia/oauth2_token_service_request.cc (right):
> > 
> >
>
https://codereview.chromium.org/458753006/diff/100001/google_apis/gaia/oauth2...
> > google_apis/gaia/oauth2_token_service_request.cc:80: // It is important that
> > provider_ is destroyed on the owner thread, not the
> > On 2014/08/13 06:58:05, blundell wrote:
> > > This comment is puzzling. Since |provider_| is a ref-counted object that
is
> > > passed to this object from the outside, we actually don't have control
over
> > the
> > > destruction of |provider_|.
> > 
> > You're right, this comment is incorrect.  The class comment for TSP is
related
> > and was also incorrect until Roger pointed it out and I fixed it.  Looks
like
> I
> > missed this one.
> > 
> > The idea is that we don't want a future maintainer to cause provider_ to be
> > destroyed on any thread other than the owner thread. 
> OAuth2TokenServiceRequest
> > is promising to clear references to TSP only on the owner thread.
> > 
> > Why does OA2TSP care about not causing TSP to be destroyed on a thread other
> > than the owner thread?  Only because it promised that in the TSP class
> comment.
> > 
> > Happy to fix this comment in a follow up CL.  Open to suggestions on how to
> word
> > it clearly.
> 
> Maybe something like "OA2TokenServiceRequest guarantees to clear its last
> reference to the passed-in TSP on the owner thread, so that the client can
> ensure that the TSP instance is destroyed on the owner thread if desired." ?

I like that.  I'll send a CL.

Powered by Google App Engine
This is Rietveld 408576698