-
Notifications
You must be signed in to change notification settings - Fork 847
(backport) Fixes silent header duplication and early loop termination that occurs upon successful revalidation when duplicate headers are present #9534
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
zwoop
merged 2 commits into
apache:9.2.x
from
elsloo:9.2.x_fix_revalidation_duplicate_header_corruption
Apr 5, 2023
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…s upon successful revalidation when duplicate headers are present - Initial attempt to backport the fix for the duplicate header bug on revalidations to 9.2.x. - Inner loop's auto `spot2` iterator contains a member variable, `_block` that references the memory address of the response headers, not the cached headers - Method called on the `cached_headers` object uses a memory address, not a named header, and leads to all response headers being deleted from the duplicate header forward - Once response headers are deleted, the first duplicate header is written to the cached headers as a new and *additional* field which leads to duplication in the cached object's headers, then the current iteration ends - The iterator of the outer loop then attempts to increment forward one step via the overridden `++` operator on `spot`, and due to header slot checks via `MIMEField::is_live()` within `MIMEHdrImpl::iterator::step()`, `_slot` is incremented to `limit` and iteration of the outer loop halts, because all response headers from that point forward were deleted in the prior iteration - This change moves away from the address-based approach to delete the header and instead uses the header name - Using the header name instead of relying on header alignment also fixes a secondary issue that could arise if response header ordering does not match the cached object's header ordering - Using the header name is slightly less efficient due to having to call `find_header`, however, this is necessary to ensure the cached headers are correctly removed before the response headers are merged into the cached object - Using a slightly less efficient approach that occurs only on successful revalidations that also contain duplicate headers should be acceptable given the tradeoff is allowing duplication if response header ordering differs from the cached object - Due to the existing logic, if a cached header is *not* in the response, it will remain in the cached object's headers Thanks to Masakazu and Leif for providing the unit test and helping with the fix, respectively. Co-Authored-By: Masakazu Kitajo <maskit@apache.org> Co-Authored-By: Leif Hedstrom <zwoop@apache.org>
Contributor
|
@elsloo : can you please re-merge this to resolve conflicts. |
zwoop
approved these changes
Apr 5, 2023
masaori335
pushed a commit
to masaori335/trafficserver
that referenced
this pull request
Sep 26, 2023
… that occurs upon successful revalidation when duplicate headers are present (apache#9534) * Fixes silent header duplication and early loop termination that occurs upon successful revalidation when duplicate headers are present - Initial attempt to backport the fix for the duplicate header bug on revalidations to 9.2.x. - Inner loop's auto `spot2` iterator contains a member variable, `_block` that references the memory address of the response headers, not the cached headers - Method called on the `cached_headers` object uses a memory address, not a named header, and leads to all response headers being deleted from the duplicate header forward - Once response headers are deleted, the first duplicate header is written to the cached headers as a new and *additional* field which leads to duplication in the cached object's headers, then the current iteration ends - The iterator of the outer loop then attempts to increment forward one step via the overridden `++` operator on `spot`, and due to header slot checks via `MIMEField::is_live()` within `MIMEHdrImpl::iterator::step()`, `_slot` is incremented to `limit` and iteration of the outer loop halts, because all response headers from that point forward were deleted in the prior iteration - This change moves away from the address-based approach to delete the header and instead uses the header name - Using the header name instead of relying on header alignment also fixes a secondary issue that could arise if response header ordering does not match the cached object's header ordering - Using the header name is slightly less efficient due to having to call `find_header`, however, this is necessary to ensure the cached headers are correctly removed before the response headers are merged into the cached object - Using a slightly less efficient approach that occurs only on successful revalidations that also contain duplicate headers should be acceptable given the tradeoff is allowing duplication if response header ordering differs from the cached object - Due to the existing logic, if a cached header is *not* in the response, it will remain in the cached object's headers Thanks to Masakazu and Leif for providing the unit test and helping with the fix, respectively. Co-Authored-By: Masakazu Kitajo <maskit@apache.org> Co-Authored-By: Leif Hedstrom <zwoop@apache.org> * Additional imports to fix the Debian build. --------- Co-authored-by: Masakazu Kitajo <maskit@apache.org> Co-authored-by: Leif Hedstrom <zwoop@apache.org> (cherry picked from commit 05c4d25)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
spot2iterator contains a member variable,_blockthat references the memory address of the response headers, not the cached headerscached_headersobject uses a memory address, not a named header, and leads to all response headers being deleted from the duplicate header forward++operator onspot, and due to header slot checks viaMIMEField::is_live()withinMIMEHdrImpl::iterator::step(),_slotis incremented tolimitand iteration of the outer loop halts, because all response headers from that point forward were deleted in the prior iterationfind_header, however, this is necessary to ensure the cached headers are correctly removed before the response headers are merged into the cached objectThanks to Masakazu and Leif for providing the unit test and helping with the fix, respectively.