Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C_Login: test for segfault when user pin not setup #573

Conversation

williamcroberts
Copy link
Member

@williamcroberts williamcroberts commented Jul 31, 2020

A command like:
pkcs11-tool --module /usr/lib/libtpm2_pkcs11.so --init-token --label tpmhsm --so-pin foo --pin bar

Will cause a C_Login even because --pin is specified. However, C_InitPIN
has not been called to initialize the userpin. This causes a NPD when
trying to load the user sealobjects public and private blobs.

Related-to: #563

Signed-off-by: William Roberts william.c.roberts@intel.com

A command like:
pkcs11-tool --module /usr/lib/libtpm2_pkcs11.so --init-token --label tpmhsm --so-pin foo --pin bar

Will cause a C_Login event becuase --pin is specified. However, C_InitPIN
has not been called to initialize the userpin. This causes an NPD when
trying to load the user sealobjects public and private blobs.

Relates-to: tpm2-software#563

Signed-off-by: William Roberts <william.c.roberts@intel.com>
@codecov
Copy link

codecov bot commented Jul 31, 2020

Codecov Report

Merging #573 into master will increase coverage by 0.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #573      +/-   ##
==========================================
+ Coverage   70.30%   70.31%   +0.01%     
==========================================
  Files          33       33              
  Lines        8573     8573              
==========================================
+ Hits         6027     6028       +1     
+ Misses       2546     2545       -1     
Impacted Files Coverage Δ
src/lib/backend_esysdb.c 81.15% <0.00%> (+0.52%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3105942...43898f2. Read the comment docs.

@williamcroberts
Copy link
Member Author

This test gets skipped, we need to add C code test...

williamcroberts pushed a commit to williamcroberts/tpm2-pkcs11 that referenced this pull request Jul 31, 2020
When the db code fails at a certain point, it can delete the token
freein'g the in-use mutex. Detect this condition and keep the mutex as
it's still in use and held.

Fixes: tpm2-software#573

Signed-off-by: William Roberts <william.c.roberts@intel.com>
williamcroberts pushed a commit to williamcroberts/tpm2-pkcs11 that referenced this pull request Jul 31, 2020
When the db code fails at a certain point, it can delete the token
freein'g the in-use mutex. Detect this condition and keep the mutex as
it's still in use and held.

Fixes: tpm2-software#573

Signed-off-by: William Roberts <william.c.roberts@intel.com>
williamcroberts pushed a commit to williamcroberts/tpm2-pkcs11 that referenced this pull request Jul 31, 2020
Rather than trying to free the token when we have failure in
C_InitToken, just reset the state that matters. This prevents us from
free'ing a mutex currently being held by a lock, as well as free'ing and
reallocating structures needlessly.

Fixes: tpm2-software#573

Signed-off-by: William Roberts <william.c.roberts@intel.com>
williamcroberts pushed a commit to williamcroberts/tpm2-pkcs11 that referenced this pull request Aug 3, 2020
Rather than trying to free the token when we have failure in
C_InitToken, just reset the state that matters. This prevents us from
free'ing a mutex currently being held by a lock, as well as free'ing and
reallocating structures needlessly.

Fixes: tpm2-software#573

Signed-off-by: William Roberts <william.c.roberts@intel.com>
williamcroberts pushed a commit that referenced this pull request Aug 3, 2020
Rather than trying to free the token when we have failure in
C_InitToken, just reset the state that matters. This prevents us from
free'ing a mutex currently being held by a lock, as well as free'ing and
reallocating structures needlessly.

Fixes: #573

Signed-off-by: William Roberts <william.c.roberts@intel.com>
@williamcroberts williamcroberts deleted the fix-C_Login-segfault branch August 28, 2020 18:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant