-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
openssl: Fix return value from tls_net_read. #4100
Conversation
Some fixes are needed. Please sign-off your commits otherwise DCO won't pass (git commit -s -m "..") In your other branch, you also have Let's take some inspiration from Curl OpenSSL backend usage: https://github.com/curl/curl/blob/master/lib/vtls/openssl.c#L4210-L4270 (fixed link) |
The curl implementation is a good reference but it is a little different from the current one.
My other branch based off 1.7.5 has changes to clear the error queue before and after the read/write/handshake call, and print the errors. it also checks errno for SSL_ERROR_SYSCALL. I can compare it with curl's implementation next week. |
Looking at Line 210 in 37aa680
Current version:
PR change:
Adding a special check for other errors won't make a difference, IMO. |
note that current version and PR change commented above are the same code |
edac0e0
to
2622e87
Compare
I had a typo - fixed it. So in the current version, i don't distinguish between errors other than WANT_READ/WANT_WRITE. And I don't see what I can include without more testing. Adding special cases for Can you be more clear about what you are expecting for today's release? |
Updated the commit to clear error queue. |
ret = SSL_read(session->ssl, buf, len); | ||
if (ret <= 0) { | ||
ret = SSL_get_error(session->ssl, ret); | ||
if (ret == SSL_ERROR_WANT_READ) { | ||
ret = FLB_TLS_WANT_READ; | ||
} | ||
else if (ret < 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here is a thing (and I still need to clarify more): the error might describe that "wants to read or write" in the case of "SSL_ERROR_WANT_WRITE", by definition:
#define SSL_ERROR_WANT_WRITE 3
that is not an error and removing the < 0
will make that case to fail. Not sure about the impact of that change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand that. However it is already a bug. tls_net_read is returning 3 today for SSL_ERROR_WANT_WRITE
which is worse because it makes the http client adds 3 garbage bytes to its response buffer. It doesn't log an error but it will corrupt memory later on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added the change to handle SSL_ERROR_WANT_WRITE.
I think until we don't have full clarity of the impact of the change, let's put this PR on stand-by, I will ask other folks to provide their opinion on this (cc: @nokute78 @leonardo-albertovich) |
Thanks for clarifying. I think we do need to handle |
Holding off on this PR sounds fine. The fix for handling |
2622e87
to
8d1cfeb
Compare
Looks good to me. By the way, we may need to take care a case which mbedtls_ssl_read returns |
Hi @edsiper what's our plan on this PR now? |
This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me, I double checked the documentation to be sure that the event loop event type switch is correct and indeed it is so let's make one last round of checkins to ensure that we all agree about it : @edsiper @krispraws
I will wait a day for additional comments and rebase this PR. |
@krispraws Could you fix conflict ? Note: #4369 and aws/aws-for-fluent-bit#278 (comment) may be fixed by this patch. |
Signed-off-by: Ramya <[email protected]>
8d1cfeb
to
0ff059f
Compare
@nokute78 , I have rebased against the latest |
@krispraws Thank you for fixing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think until we don't have full clarity of the impact of the change, let's put this PR on stand-by, I will ask other folks to provide their opinion on this (cc: @nokute78 @leonardo-albertovich)
I and @leonardo-albertovich approved this patch.
Let's merge this PR.
@edsiper I can't merge this since |
@edsiper , Is there anything else needed for this PR? |
thanks everybody for your patience, I will re-force the CI since it's stuck and merge it as soon as is ready |
looks like everything is good, just a problem with the CI message update |
@krispraws @nokute78 @leonardo-albertovich @PettitWesley are you ok with moving this change also to 1.8 branch for the next 1.8.12 release ? |
@edsiper , yes, we should move this to 1.8. Do you want me to create a PR for that? |
@krispraws thanks, yes please! so we can make it part of 1.8.12 |
…4100) Signed-off-by: Ramya <[email protected]>
Error codes returned from SSL_get_error() are positive values: https://github.com/openssl/openssl/blob/master/include/openssl/ssl.h.in#L1181
Without this fix, if the read fails and SSL_get_error() returned SSL_ERROR_SSL or any other similar error, tls_net_read returns 1 to the caller which thinks it read 1 byte.
Addresses
Addresses #4098
Testing
Before we can approve your change; please submit the following in a comment:
Documentation
Fluent Bit is licensed under Apache 2.0, by submitting this pull request I understand that this code will be released under the terms of that license.