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

wasm: fix wasm vm crash before the body too large #37079

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

wbpcode
Copy link
Member

@wbpcode wbpcode commented Nov 9, 2024

Commit Message: wasm: fix wasm vm crash before the body too large
Additional Description:

To fix #36989

Risk Level: low.
Testing: unit/integration.
Docs Changes: n/a.
Release Notes: n/a.
Platform Specific Features: n/a.

Signed-off-by: wangbaiping/wbpcode <wangbaiping@bytedance.com>
Signed-off-by: wangbaiping(wbpcode) <wangbaiping@bytedance.com>
@wbpcode
Copy link
Member Author

wbpcode commented Nov 11, 2024

/retest

@@ -1654,6 +1654,14 @@ Http::FilterDataStatus Context::decodeData(::Envoy::Buffer::Instance& data, bool
}
if (buffering_request_body_) {
decoder_callbacks_->addDecodedData(data, false);
Copy link
Contributor

Choose a reason for hiding this comment

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

I didn't review the previous PR, but I'm genuinely confused why this isn't causing doubling the data somehow.

Copy link
Member Author

Choose a reason for hiding this comment

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

the add* actually use move semantics

Copy link
Contributor

Choose a reason for hiding this comment

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

Probably the request_body_buffer_ = &data; should be in the else, it is not used if buffering. and the if should check the callback pointer is not null (probably never happends to be null) but to be consistent with the place it is used getBuffer:

https://github.com/envoyproxy/envoy/blob/main/source/extensions/common/wasm/context.cc#L818

@@ -234,6 +237,49 @@ TEST_P(WasmFilterIntegrationTest, BodyBufferedMultipleChunksManipulation) {
"upstream_very_long_body.end");
}

TEST_P(WasmFilterIntegrationTest, LargeRequestHitBufferLimit) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I have tried to make the test failed, but with and without the change, both pass.

Copy link
Member Author

@wbpcode wbpcode Nov 15, 2024

Choose a reason for hiding this comment

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

this test mainly used to ensure big body could works as expected and this patch doesn't break anything.

It's hard to reproduce the bug in integration test because it requires specific language sdk implementation and the data should be handled by chunks.

I think maybe I should add a unit test for this. If I can get more time.

Copy link
Contributor

@johnlanni johnlanni Nov 21, 2024

Choose a reason for hiding this comment

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

It cannot be reproduced by sending large body requests, as it will go through prepareLocalReplyViaFilterChain and will not immediately end the request

@soulxu
Copy link
Member

soulxu commented Nov 20, 2024

/wait-any

@kyessenov kyessenov removed their assignment Nov 22, 2024
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.

large request body result in wasm crash
6 participants