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

tsan: make detecting the need for locking when using tsan easier #17479

Closed
wants to merge 8 commits into from

Conversation

paulidale
Copy link
Contributor

TSAN has a number of problems currently.

Eventually this might fix #17447

  • documentation is added or updated
  • tests are added or updated

@paulidale paulidale added branch: master Merge to master branch triaged: bug The issue/pr is/fixes a bug branch: 3.0 Merge to openssl-3.0 branch labels Jan 12, 2022
@paulidale paulidale self-assigned this Jan 12, 2022
@github-actions github-actions bot added the severity: fips change The pull request changes FIPS provider sources label Jan 12, 2022
@paulidale
Copy link
Contributor Author

The files that reference TSAN_QUALIFIER are:

test/threadstest.c
crypto/core_namemap.c
crypto/mem.c
crypto/objects/obj_dat.c
crypto/lhash/lhash.c
crypto/lhash/lhash_local.h
crypto/x509/v3_purp.c
include/internal/tsan_assist.h
providers/implementations/rands/drbg_local.h
ssl/ssl_local.h
ssl/ssl_lib.c

Copy link
Member

@bernd-edlinger bernd-edlinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, whether or not you want to fix the white space issue.

crypto/mem.c Outdated Show resolved Hide resolved
Copy link
Member

@bernd-edlinger bernd-edlinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah sorry, overlooked the CI issue, which is relevant

@bernd-edlinger
Copy link
Member

crypto/lhash/lhash.c:199:9: error: variable 'ret' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
    if (tsan_lock(lh)) {
        ^~~~~~~~~~~~~
crypto/lhash/lhash.c:210:12: note: uninitialized use occurs here
    return ret;
           ^~~
crypto/lhash/lhash.c:199:5: note: remove the 'if' if its condition is always true
    if (tsan_lock(lh)) {
    ^~~~~~~~~~~~~~~~~~~
crypto/lhash/lhash.c:192:14: note: initialize the variable 'ret' to silence this warning
    void *ret;
             ^
              = NULL
1 error generated.

@paulidale paulidale marked this pull request as ready for review January 12, 2022 09:30
Copy link
Member

@bernd-edlinger bernd-edlinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice.

@bernd-edlinger
Copy link
Member

the test case is master only stuff.

@bernd-edlinger bernd-edlinger added the approval: done This pull request has the required number of approvals label Jan 12, 2022
Doing the tsan operations under lock would be difficult to arrange here (locks
require memory allocation).
Most of the DRGB code is run under lock from the EVP layer.  This is relied
on to make the majority of TSAN operations safe.  However, it is still necessary
to enable locking for all DRBGs created.
Not all platforms support tsan operations, those that don't need to have an
alternative locking path.

Fixes openssl#17447
openssl-machine pushed a commit that referenced this pull request Jan 13, 2022
Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
(Merged from #17479)
openssl-machine pushed a commit that referenced this pull request Jan 13, 2022
Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
(Merged from #17479)
openssl-machine pushed a commit that referenced this pull request Jan 13, 2022
Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
(Merged from #17479)
openssl-machine pushed a commit that referenced this pull request Jan 13, 2022
Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
(Merged from #17479)
openssl-machine pushed a commit that referenced this pull request Jan 13, 2022
Doing the tsan operations under lock would be difficult to arrange here (locks
require memory allocation).

Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
(Merged from #17479)
openssl-machine pushed a commit that referenced this pull request Jan 13, 2022
Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
(Merged from #17479)
openssl-machine pushed a commit that referenced this pull request Jan 13, 2022
Most of the DRGB code is run under lock from the EVP layer.  This is relied
on to make the majority of TSAN operations safe.  However, it is still necessary
to enable locking for all DRBGs created.

Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
(Merged from #17479)
openssl-machine pushed a commit that referenced this pull request Jan 13, 2022
Not all platforms support tsan operations, those that don't need to have an
alternative locking path.

Fixes #17447

Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
(Merged from #17479)
@paulidale
Copy link
Contributor Author

Merged to master. Manually cherry picked to 3.0 (needed to omit one test and the object change).
Thanks for the review.

@paulidale paulidale closed this Jan 13, 2022
openssl-machine pushed a commit that referenced this pull request Jan 13, 2022
Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
(Merged from #17479)
openssl-machine pushed a commit that referenced this pull request Jan 13, 2022
Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
(Merged from #17479)
openssl-machine pushed a commit that referenced this pull request Jan 13, 2022
Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
(Merged from #17479)
openssl-machine pushed a commit that referenced this pull request Jan 13, 2022
Doing the tsan operations under lock would be difficult to arrange here (locks
require memory allocation).

Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
(Merged from #17479)
openssl-machine pushed a commit that referenced this pull request Jan 13, 2022
Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
(Merged from #17479)
openssl-machine pushed a commit that referenced this pull request Jan 13, 2022
Most of the DRGB code is run under lock from the EVP layer.  This is relied
on to make the majority of TSAN operations safe.  However, it is still necessary
to enable locking for all DRBGs created.

Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
(Merged from #17479)
@paulidale paulidale deleted the tsan branch May 9, 2022 01:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approval: done This pull request has the required number of approvals branch: master Merge to master branch branch: 3.0 Merge to openssl-3.0 branch severity: fips change The pull request changes FIPS provider sources triaged: bug The issue/pr is/fixes a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Possible tsan issue with arm
2 participants