dns: preserve reentrant c-ares query after qid reuse - #46880
Open
fvallenilla wants to merge 2 commits into
Open
Conversation
Signed-off-by: Freddy Vallenilla <fvallenilla@netflix.com>
fvallenilla
marked this pull request as ready for review
August 21, 2026 23:07
|
CC @envoyproxy/dependency-shepherds: Your approval is needed for changes made to |
Member
|
@fvallenilla ci failures look real /wait |
Contributor
Author
|
@phlax The branch is up to date now, remaining failure seems unrelated
|
Member
|
/lgtm deps |
Member
|
/retest |
Member
|
/assign @yanavlasov for c-ares sign off |
|
neither of for, c-ares, sign, off can be assigned to this issue. |
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.
Commit Message:
dns: preserve reentrant c-ares query after QID reuse
A July security fix for c-ares (CVE-2026-33630) made query teardown run twice: once before the completion callback, once after. Between those two teardowns, the callback can enqueue a new query with the same 16-bit transaction ID. The second teardown then deletes the map entry by key — evicting the new query if there was a collision.
As a result: c-ares discards the responses for the new query, does not call its callback, and Envoy can permanently stop refreshing the affected DNS cluster.
The change in this PR is to only remove a completing query's QID entry when the table still points to that query. A replacement query that has taken ownership of the same QID remains registered and completes normally.
Before and after diagrams
Before patch
sequenceDiagram participant E as Envoy AUTO resolver participant V6 as Completing AAAA query participant Q as queries_by_qid participant V4 as Reentrant A query E->>V6: Resolve AAAA for IPv4-only hostname V6->>Q: QID 42 points to AAAA query V6-->>E: Return NODATA in callback E->>V4: Start A fallback inline V4->>Q: Randomly select the same QID 42 for A query E-->>V6: Callback returns V6->>Q: Remove QID 42 unconditionally Note over V4,Q: A query loses its table entry Note over E: Refresh loop stallsAfter patch
sequenceDiagram participant E as Envoy AUTO resolver participant V6 as Completing AAAA query participant Q as queries_by_qid participant V4 as Reentrant A query E->>V6: Resolve AAAA for IPv4-only hostname V6->>Q: QID 42 points to AAAA query V6-->>E: Return NODATA in callback E->>V4: Start A fallback inline V4->>Q: Randomly reuse QID 42 for A query E-->>V6: Callback returns V6->>Q: Remove only if QID 42 still points to AAAA query Q-->>V6: QID 42 now points to A query V6-->>Q: Keep QID 42 Note over V4,Q: A query retains its table entry V4-->>E: Return IPv4 addresses E->>E: Schedule next DNS refreshAdditional Description:
This ports the guard from c-ares/c-ares#1256 while Envoy remains on c-ares 1.34.8. The failure and a minimal natural-QID reproduction are documented in #46877.
AI assistance was used to prepare this draft. The submitter will review and take ownership before marking it ready for review.
Risk Level: Low
Testing:
bazel build @c-ares//:aresbazel run //tools/code_format:check_format -- check bazel/c-ares.patch changelogs/current/bug_fixes/dns_resolver__preserve-reused-cares-qid.rstSTRICT_DNScluster at a 2 ms refresh interval hit a natural QID collision after 119,436 opportunities, processed both the collision and following normal address, and completed another 8,637 successful refreshes with zero failures.Docs Changes: N/A
Release Notes: Added a DNS resolver bug-fix fragment.
Platform Specific Features: N/A
[Optional Runtime guard:] N/A; this is a dependency correctness fix that preserves the current query owner.
Fixes #46877