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

Issue 6683071: TPM_ERROR and ScopedTssType: uses the first, creates the second. (Closed)

Created:
9 years, 9 months ago by Will Drewry
Modified:
9 years, 7 months ago
Reviewers:
gauravsh, fes
CC:
chromium-os-reviews_chromium.org, Chris Masone, gauravsh, Will Drewry
Visibility:
Public.

Description

TPM_ERROR and ScopedTssType: uses the first, creates the second. This change fixes two issues: 1. A huge amount of duplicated code during error path handling. 2. Relying on TSS_SUCCESS to be 0 forever. 2 was fixed by using the TPM_ERROR() macro everywhere. 1 is addressed by adding wrappers around all the TSS objects that need to be freed such that automatic variable scope will result in the correct releasing of the objects (and in the right order). My original implementation used one main TSS manager class which handled the objects and memory. However, ignoring storage class changes, the destructor ordering in a function should be reliable to ensure that all TSS objects and memory will be cleaned up prior to any ScopedTssContexts being destroyed. Thoughts? TEST= 1. unittests pass 2. suite_Smoke passes in a VM 3. live test of x86-alex works 4. On booted x86-alex, repeated calls to cryptohome --action=status does not appear to incur any memory leakage. I'll start a longer run. BUG=chromium-os:13129 Change-Id: I5b0f654cc524fb4fee4f909a4d7d4c9754595c69 R=gauravsh@chromium.org,fes@chromium.org Committed: http://chrome-svn/viewvc/chromeos?view=rev&revision=a50e4c5

Patch Set 1 #

Patch Set 2 : clean up spacing #

Patch Set 3 : catch a few more cases #

Patch Set 4 : fix oversights for context management #

Patch Set 5 : rebase #

Patch Set 6 : catch a few more scope-able places #

Patch Set 7 : add warn_unused_result #

Total comments: 21

Patch Set 8 : fix up nits and add some checks #

Patch Set 9 : an alternate world. Thoughts? #

Total comments: 10

Patch Set 10 : fix indent #

Patch Set 11 : fix up style #

Total comments: 2
Unified diffs Side-by-side diffs Delta from patch set Stats (+442 lines, -409 lines) Patch
M SConstruct View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download
A scoped_tss_type.h View 1 2 3 4 5 6 7 8 1 chunk +115 lines, -0 lines 1 comment Download
M tpm.cc View 1 2 3 4 5 6 7 8 9 10 40 chunks +326 lines, -408 lines 1 comment Download

Messages

Total messages: 10 (0 generated)
Will Drewry
9 years, 9 months ago (2011-03-29 03:43:12 UTC) #1
gauravsh
This is a nice change. My main comment is regarding the naming and semantics of ...
9 years, 9 months ago (2011-03-29 19:16:05 UTC) #2
Will Drewry
Fixed everything except the ScopedTssType naming issue. Any thoughts on what would be more clear ...
9 years, 9 months ago (2011-03-29 19:42:21 UTC) #3
gauravsh
http://codereview.chromium.org/6683071/diff/10002/scoped_tss_type.h File scoped_tss_type.h (right): http://codereview.chromium.org/6683071/diff/10002/scoped_tss_type.h#newcode9 scoped_tss_type.h:9: // ScopedTssContext context; On 2011/03/29 19:42:22, Will Drewry wrote: ...
9 years, 9 months ago (2011-03-29 20:21:54 UTC) #4
Will Drewry
PTAL This is an in-between approach where the ScopedTss* is usable in the normal places ...
9 years, 9 months ago (2011-03-29 20:34:51 UTC) #5
gauravsh
lgtm http://codereview.chromium.org/6683071/diff/12002/tpm.cc File tpm.cc (right): http://codereview.chromium.org/6683071/diff/12002/tpm.cc#newcode350 tpm.cc:350: Tspi_Key_CreateKey(local_key_handle, srk_handle, 0))) { nit: just indent this ...
9 years, 9 months ago (2011-03-29 20:52:44 UTC) #6
Will Drewry
done - thanks! http://codereview.chromium.org/6683071/diff/12002/tpm.cc File tpm.cc (right): http://codereview.chromium.org/6683071/diff/12002/tpm.cc#newcode350 tpm.cc:350: Tspi_Key_CreateKey(local_key_handle, srk_handle, 0))) { On 2011/03/29 ...
9 years, 9 months ago (2011-03-29 20:54:59 UTC) #7
gauravsh
http://codereview.chromium.org/6683071/diff/12002/tpm.cc File tpm.cc (right): http://codereview.chromium.org/6683071/diff/12002/tpm.cc#newcode612 tpm.cc:612: if (TPM_ERROR(result = On 2011/03/29 20:54:59, Will Drewry wrote: ...
9 years, 9 months ago (2011-03-29 20:58:45 UTC) #8
Will Drewry
ah! fixed! http://codereview.chromium.org/6683071/diff/12002/tpm.cc File tpm.cc (right): http://codereview.chromium.org/6683071/diff/12002/tpm.cc#newcode350 tpm.cc:350: Tspi_Key_CreateKey(local_key_handle, srk_handle, 0))) { On 2011/03/29 20:52:44, ...
9 years, 9 months ago (2011-03-29 21:14:30 UTC) #9
fes
9 years, 9 months ago (2011-03-29 22:55:38 UTC) #10
LGTM other than minor nits.

http://codereview.chromium.org/6683071/diff/6007/scoped_tss_type.h
File scoped_tss_type.h (right):

http://codereview.chromium.org/6683071/diff/6007/scoped_tss_type.h#newcode65
scoped_tss_type.h:65: explicit ScopedTssType(TSS_HCONTEXT c = 0, TssType t = 0)
:
Colon goes on the next line

http://codereview.chromium.org/6683071/diff/6007/tpm.cc
File tpm.cc (right):

http://codereview.chromium.org/6683071/diff/6007/tpm.cc#newcode642
tpm.cc:642: local_context_handle.ptr()))) {
Spacing is off.

Powered by Google App Engine
This is Rietveld 408576698