-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
SIGSEGV When Reading From SSL Stream #11885
Comments
mscdex
added
c++
Issues and PRs that require attention from people who are familiar with C++.
tls
Issues and PRs related to the tls subsystem.
labels
Mar 16, 2017
/cc @nodejs/crypto |
It is possible that OnRead triggers a callback that closes the socket (thus "destroySSL"). |
It's near-impenetrable spaghetti code but yes, it looks I'll see if I can find a way to reproduce and come up with a fix. |
bnoordhuis
added a commit
to bnoordhuis/io.js
that referenced
this issue
Mar 20, 2017
OnRead() calls into JS land which can result in the SSL context object being destroyed on return. Check that `ssl_ != nullptr` afterwards. Fixes: nodejs#11885 PR-URL: nodejs#11898 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
Fixed in 03a6c6e. |
jungx098
pushed a commit
to jungx098/node
that referenced
this issue
Mar 21, 2017
OnRead() calls into JS land which can result in the SSL context object being destroyed on return. Check that `ssl_ != nullptr` afterwards. Fixes: nodejs#11885 PR-URL: nodejs#11898 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
italoacasas
pushed a commit
to italoacasas/node
that referenced
this issue
Mar 21, 2017
OnRead() calls into JS land which can result in the SSL context object being destroyed on return. Check that `ssl_ != nullptr` afterwards. Fixes: nodejs#11885 PR-URL: nodejs#11898 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
MylesBorins
pushed a commit
that referenced
this issue
Apr 18, 2017
OnRead() calls into JS land which can result in the SSL context object being destroyed on return. Check that `ssl_ != nullptr` afterwards. Fixes: #11885 PR-URL: #11898 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
MylesBorins
pushed a commit
that referenced
this issue
Apr 18, 2017
OnRead() calls into JS land which can result in the SSL context object being destroyed on return. Check that `ssl_ != nullptr` afterwards. Fixes: #11885 PR-URL: #11898 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
MylesBorins
pushed a commit
that referenced
this issue
Apr 19, 2017
OnRead() calls into JS land which can result in the SSL context object being destroyed on return. Check that `ssl_ != nullptr` afterwards. Fixes: #11885 PR-URL: #11898 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
MylesBorins
pushed a commit
that referenced
this issue
Apr 19, 2017
OnRead() calls into JS land which can result in the SSL context object being destroyed on return. Check that `ssl_ != nullptr` afterwards. Fixes: #11885 PR-URL: #11898 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
andrew749
pushed a commit
to michielbaird/node
that referenced
this issue
Jul 19, 2017
OnRead() calls into JS land which can result in the SSL context object being destroyed on return. Check that `ssl_ != nullptr` afterwards. Fixes: nodejs/node#11885 PR-URL: nodejs/node#11898 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
NodeJS is consistently raising a SIGSEGV.
I can't share the code that reproduces this, but have at least partially tracked down the source of the issue. It occurs in a container that runs a test application testing various other nodejs applications in other containers.
In
src/tls_wrap.cc
, inTLSWrap::ClearOut()
, it initially checks ifssl_
is null. If not, it continues on to read data from the stream. It enters the forever loop which callsSSL_read()
.SSL_read()
assumes that it is provided a non-null pointer to the SSL stream. The first time through the forever loop, this is safe. However, when this loops, it is not always true thatssl_
is not null. In my scenario, a second time through the loop,ssl_
was null and the subsequent dereference attempt inSSL_read()
causes the SIGSEGV.I've made two changes:
SSL_read()
within the forever loop, check ifssl_
is null. If so, break out of the loop. Simplying returning from here caused other issues.SSL_get_shutdown()
. This call can't be made ifssl_
is null.The diff for the changes is below and is against the
v6.10.1-proposal
branch.Neither
SSL_read()
orSSL_get_shutdown()
check if the passed parameter is null and so when null is passed, a SIGSEGV occurs.These two changes appear to be sufficient to avoid the SIGSEGV and my test application has been able to continuously run without issue. However, I wasn't been able to track down when/where
ssl_
becomes null and if the above changes are complete & sufficient. Experts required - I'm not sufficiently confident that the changes are complete & sufficient to submit a pull request.Note that while similar to issue #8074, it is not the same. I had applied the changes suggested by pull request #11776 (against v6.10.1-proposal), but that did not prevent the SIGSEGV.
There appears to be a lot of places where pointers are not being checked. Unfortunately, this appears all over in the OpenSSL dependency (as explicitly seen with
SSL_read()
andSSL_get_shutdown()
).The text was updated successfully, but these errors were encountered: