-
Notifications
You must be signed in to change notification settings - Fork 5.5k
upstream: Null-deref on TCP health checker if setsockopt fails #6793
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
Changes from 2 commits
ab89ac2
609cfec
413fe8a
14c343c
f3fda0e
1b95a69
d0a53bf
9acd444
260074f
57d549c
b77ef7d
2eaee67
5721aca
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -347,7 +347,9 @@ TcpHealthCheckerImpl::TcpHealthCheckerImpl(const Cluster& cluster, | |
|
|
||
| TcpHealthCheckerImpl::TcpActiveHealthCheckSession::~TcpActiveHealthCheckSession() { | ||
| if (client_) { | ||
| client_->close(Network::ConnectionCloseType::NoFlush); | ||
| Network::ClientConnectionPtr clientToDestroy(std::move(client_)); | ||
| clientToDestroy->close(Network::ConnectionCloseType::NoFlush); | ||
| parent_.dispatcher_.deferredDelete(std::move(clientToDestroy)); | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -358,21 +360,23 @@ void TcpHealthCheckerImpl::TcpActiveHealthCheckSession::onData(Buffer::Instance& | |
| data.drain(data.length()); | ||
| handleSuccess(false); | ||
| if (!parent_.reuse_connection_) { | ||
| client_->close(Network::ConnectionCloseType::NoFlush); | ||
| Network::ClientConnectionPtr clientToDestroy(std::move(client_)); | ||
| clientToDestroy->close(Network::ConnectionCloseType::NoFlush); | ||
| parent_.dispatcher_.deferredDelete(std::move(clientToDestroy)); | ||
| } | ||
| } else { | ||
| host_->setActiveHealthFailureType(Host::ActiveHealthFailureType::UNHEALTHY); | ||
| } | ||
| } | ||
|
|
||
| void TcpHealthCheckerImpl::TcpActiveHealthCheckSession::onEvent(Network::ConnectionEvent event) { | ||
| if (event == Network::ConnectionEvent::RemoteClose) { | ||
| // If !client_, then we are already handling a failure/teardown | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Key is this. I'm using (Other ways to distinguish internally-generated from externally-generated would work too)
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The other way to do this would be to do what the other health checkers are doing which is effectively the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I updated to follow the |
||
| if (client_ && | ||
| (event == Network::ConnectionEvent::RemoteClose || | ||
| event == Network::ConnectionEvent::LocalClose)) { | ||
| Network::ClientConnectionPtr clientToDestroy(std::move(client_)); | ||
| handleFailure(envoy::data::core::v2alpha::HealthCheckFailureType::NETWORK); | ||
| } | ||
|
|
||
| if (event == Network::ConnectionEvent::RemoteClose || | ||
| event == Network::ConnectionEvent::LocalClose) { | ||
| parent_.dispatcher_.deferredDelete(std::move(client_)); | ||
| parent_.dispatcher_.deferredDelete(std::move(clientToDestroy)); | ||
| } | ||
|
|
||
| if (event == Network::ConnectionEvent::Connected && parent_.receive_bytes_.empty()) { | ||
|
|
@@ -390,7 +394,9 @@ void TcpHealthCheckerImpl::TcpActiveHealthCheckSession::onEvent(Network::Connect | |
| // TODO(mattklein123): In the case that a user configured bytes to write, they will not be | ||
| // be written, since we currently have no way to know if the bytes actually get written via | ||
| // the connection interface. We might want to figure out how to handle this better later. | ||
| client_->close(Network::ConnectionCloseType::NoFlush); | ||
| Network::ClientConnectionPtr clientToDestroy(std::move(client_)); | ||
| clientToDestroy->close(Network::ConnectionCloseType::NoFlush); | ||
| parent_.dispatcher_.deferredDelete(std::move(clientToDestroy)); | ||
| handleSuccess(false); | ||
| } | ||
| } | ||
|
|
@@ -418,8 +424,10 @@ void TcpHealthCheckerImpl::TcpActiveHealthCheckSession::onInterval() { | |
| } | ||
|
|
||
| void TcpHealthCheckerImpl::TcpActiveHealthCheckSession::onTimeout() { | ||
| Network::ClientConnectionPtr clientToDestroy(std::move(client_)); | ||
| host_->setActiveHealthFailureType(Host::ActiveHealthFailureType::TIMEOUT); | ||
| client_->close(Network::ConnectionCloseType::NoFlush); | ||
| clientToDestroy->close(Network::ConnectionCloseType::NoFlush); | ||
| parent_.dispatcher_.deferredDelete(std::move(clientToDestroy)); | ||
| } | ||
|
|
||
| GrpcHealthCheckerImpl::GrpcHealthCheckerImpl(const Cluster& cluster, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.