tree data: duplicate anydata children into target context - #2565
Merged
Conversation
Member
|
Already fixed in the |
Yeaseen
force-pushed
the
fix-anydata-cross-ctx-dup
branch
from
August 27, 2026 17:17
778b864 to
c466bcf
Compare
Author
|
@michalvasko Done, thanks. I rebased onto |
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
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.
Summary
Fix a use-after-free in cross-context duplication of data trees containing
anydataXML subtrees.This addresses
GHSA-jq97-j23h-2vqw:GHSA-jq97-j23h-2vqw
Problem
lyd_dup_siblings_to_ctx()is expected to duplicate a data tree into the targetcontext. However, when duplicating an
anydatanode that stores its value as achild subtree, the embedded children were copied with
lyd_dup_siblings().That preserves references to the source context. If the source tree and source
context are freed after successful duplication, later operations on the duplicate
can access freed memory. One affected path is XPath traversal through
lyd_trim_xpath().Fix
Duplicate
anydatachild subtrees withlyd_dup_siblings_to_ctx()andLYD_CTX(trg)so embedded children are copied into the same target context asthe containing
anydatanode.Add a regression test that duplicates an
anydataXML subtree into a secondcontext, destroys the original context, and then evaluates XPath on the
duplicate.
Verification
I ran the advisory reproducer against an ASan/UBSan build with this fix applied.
The reproducer completes successfully and no use-after-free is reported.