Skip to content

[tcp_proxy] Add nullptr checks to watermark asserts #40034

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

Merged
merged 4 commits into from
Jul 1, 2025

Conversation

nezdolik
Copy link
Member

Commit Message: Add nullptr checks into watermark asserts in tcp proxy to avoid potential segfaults.
Additional Description:
Risk Level: Low
Testing:
Docs Changes:
Release Notes:
Platform Specific Features:

Signed-off-by: Kateryna Nezdolii <kateryna.nezdolii@gmail.com>
@nezdolik
Copy link
Member Author

cc @jrajahalme

@@ -437,7 +437,8 @@ void Filter::UpstreamCallbacks::onEvent(Network::ConnectionEvent event) {

void Filter::UpstreamCallbacks::onAboveWriteBufferHighWatermark() {
// TCP Tunneling may call on high/low watermark multiple times.
ASSERT(parent_->config_->tunnelingConfigHelper() || !on_high_watermark_called_);
ASSERT((parent_ != nullptr && parent_->config_->tunnelingConfigHelper()) ||
Copy link
Member Author

Choose a reason for hiding this comment

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

in the case when we enter draining state parent_ will be set to nullptr. In draining state if code invokes this callback is will trigger ASSERT failure in non release mode. @ggreenway would this be correct logic to assert fail if callback is invoked in draining state? or should we instead have ASSERT statement like:

ASSERT(parent == nullptr || parent_->config_->tunnelingConfigHelper() || !on_high_watermark_called_);

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I think what you wrote in the comment is correct. Please also add a comment explaining the draining case. It looks like the two ASSERTs were the only places using parent_ without checking it for nullptr.

@ggreenway ggreenway self-assigned this Jun 26, 2025
nezdolik added 2 commits June 27, 2025 10:43
Signed-off-by: Kateryna Nezdolii <kateryna.nezdolii@gmail.com>
Signed-off-by: Kateryna Nezdolii <kateryna.nezdolii@gmail.com>
@botengyao
Copy link
Member

/retest

@nezdolik
Copy link
Member Author

Verify examples ci step fails with

Container dynamic-config-cp-service1-1  Error response from daemon: No such image: dynamic-config-cp-echo:latest0.0s 

cc @phlax

@wbpcode wbpcode merged commit 8efd30d into envoyproxy:main Jul 1, 2025
25 checks passed
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.

4 participants