Commit graph

45678 commits

Author SHA1 Message Date
Michał Kępień
c61539279d
Drop redundant uses of authoritative=True
The ans3 custom server instance is created with default_aa=True.  Do not
pass the authoritative=True keyword argument to the DnsResponseSend
constructor in CookieHandler.get_responses() as it is redundant.
2026-05-21 11:52:56 +02:00
Michał Kępień
802c03313f
Drop unnecessary qctx.prepare_new_response() call
The ans3 custom server does not have any zones defined, so the responses
passed to its handlers by core isctest.asyncserver code are guaranteed
to be empty.  Remove a call to qctx.prepare_new_response() from
CookieHandler.get_responses() as it is redundant.
2026-05-21 11:52:56 +02:00
Michał Kępień
a296bcf587
Remove NoErrorHandler
The NoErrorHandler class does not get matched to any query sent by ns4
in the "resend_loop" test.  Remove it as it is redundant.
2026-05-21 11:52:56 +02:00
Michał Kępień
ba6eee2b80
Simplify match criteria for CookieHandler
The CookieHandler class handles all traffic for the "example." domain.
Make it a subclass of DomainHandler to simplify its definition.
2026-05-21 11:52:56 +02:00
Michał Kępień
c0f01b60fd
Make static response handlers more specific
The RootNSHandler and ExampleNSHandler classes are only equipped to
respond to specific QNAME/QTYPE tuples, not all queries for a specific
QNAME.  Turn them into subclasses of QnameQtypeHandler and make them
only respond to QTYPE=NS queries to prevent sending NS responses for
non-NS queries.
2026-05-21 11:52:56 +02:00
Michał Kępień
ebab903a93 chg: ci: Various autorebase improvements
- Rewrite cherry-pick references during autorebases
  - Fix autorebase error reporting
  - Limit post-push pipelines for autorebased branches
  - Only autorebase when there is anything to rebase
  - Conflate missing commit reference notifications
  - Support autorebasing backported security MRs

Merge branch 'michal/autorebase-improvements' into 'main'

See merge request isc-projects/bind9!12024
2026-05-21 11:22:25 +02:00
Michał Kępień
dd723d93cb
Support autorebasing backported security MRs
Autorebasing a backported security fix enables convenient refreshing of
cherry-pick references, which makes it trivial for developers to satisfy
Danger rules just before the merge request is merged.  Add a manual CI
job that is only created for backported merge requests targeting
security-* branches.
2026-05-21 11:13:30 +02:00
Michał Kępień
086780dcf0
Conflate missing commit reference notifications
Instead of creating a separate (potentially lengthy) Danger notification
for every missing commit reference in a backport, produce a single
notification with a list of all unreferenced commit hashes.  This makes
Danger output more concise while retaining all the relevant feedback for
the developer.
2026-05-21 11:13:30 +02:00
Michał Kępień
497f771ae3
Only autorebase when there is anything to rebase
In an optimistic future, security-* branches will become empty, at least
intermittently.  When that happens, there will be nothing left to rebase
on those branches, so when something gets merged into their base
branches, an autorebase will effectively be a fast-forward.  While the
existing autorebase logic would handle such a case perfectly fine, it is
prudent to avoid creating a test pipeline after pushing such a
fast-forward update as the code revision getting pushed will have
already been tested by other pipelines.  However, the push should still
happen as non-empty downstream autorebased branches may exist and those
will still need to be rebased.  Achieve both of these objectives by
checking early whether there is anything to rebase and pushing the
fast-forwarded version of the branch without setting the AUTOREBASE CI
variable if there is not.
2026-05-21 11:13:30 +02:00
Michał Kępień
5cd870053e
Limit post-push pipelines for autorebased branches
Current CI job triggering rules cause a full pipeline to be started
after every push to security-* branches.  In this context, "push" means
"branch update", which covers both "git push" invocations and merging a
merge request.  Meanwhile, running a test pipeline is only desired after
a rebase; if a branch is fast-forwarded, it means that a merge request
has been merged into it and a pipeline should have already been run for
that merge request itself.  Limit resource use by only triggering
pipelines for security-* branches when they are pushed to with a "magic"
CI variable that is only set in autorebase jobs.  Leave all the other
triggering rules (for scheduled/manual pipelines) intact.
2026-05-21 11:13:30 +02:00
Michał Kępień
4c0e93108e
Fix autorebase error reporting
The logic used for detecting the commit breaking an autorebase does not
work correctly if the offending commit is not the first one applied
during the "reverse rebase".  Fix by using REBASE_HEAD instead of
processing the output of "git status" in a convoluted way.

Furthermore, the approach used for identifying the first offending merge
request in the case of a successful autorebase followed by a failed
build only works correctly if the base branch is not autorebased itself.
Since a solution that would work correctly for a branch autorebased on
top of a branch that only moves forward does not work correctly for a
branch autorebased on top of another autorebased branch and vice versa,
accurately identifying the most likely culprit after a successful
autorebase is a very complicated and brittle task.  Since reporting no
details at all is arguably better than reporting false details, only
produce a minimal error notification if the build fails after a
successful autorebase.
2026-05-21 11:13:30 +02:00
Michał Kępień
98c3f339bf
Rewrite cherry-pick references during autorebases
Use a custom rebasing script instead of "git rebase" to enable rewriting
cherry-pick references during autorebases.
2026-05-21 11:13:30 +02:00
Michal Nowak
5c8637debe new: ci: Add Fedora 44
Merge branch 'mnowak/fedora-44' into 'main'

See merge request isc-projects/bind9!12064
2026-05-21 07:48:11 +02:00
Michal Nowak
175b4f1711 Add Fedora 44 2026-05-21 06:09:33 +02:00
Michal Nowak
2420b9364b fix: test: Make deleg cleanuptests memory assertions 32-bit-safe
Some checks are pending
CodeQL / Analyze (push) Waiting to run
SonarCloud / Build and analyze (push) Waiting to run
Each address entry stored by dns_delegset_addaddr() is an
isc_netaddrlink_t, whose size depends on sizeof(void *) via the
ISC_LINK macro (24 bytes of address + two prev/next pointers): 40
bytes on 64-bit, 32 bytes on 32-bit. The hardcoded 4 MB / 8 MB
ranges only held on 64-bit, so dns_deleg_cleanuptests failed on
armv7l with isc_mem_inuse() returning ~3.2 MB.

Express the expected ranges in terms of sizeof(isc_netaddrlink_t)
so they scale with pointer width, and pull the 99999 entry count
out into a NENTRIES macro.

Close isc-projects/bind9#6012

Merge branch 'mnowak/armv7l-fix-dns_deleg_cleanuptests' into 'main'

See merge request isc-projects/bind9!12061
2026-05-20 18:55:34 +02:00
Michal Nowak
4623873e58 Make deleg cleanuptests memory assertions 32-bit-safe
Each address entry stored by dns_delegset_addaddr() is an
isc_netaddrlink_t, whose size depends on sizeof(void *) via the
ISC_LINK macro (24 bytes of address + two prev/next pointers): 40
bytes on 64-bit, 32 bytes on 32-bit. The hardcoded 4 MB / 8 MB
ranges only held on 64-bit, so dns_deleg_cleanuptests failed on
armv7l with isc_mem_inuse() returning ~3.2 MB.

Express the expected ranges in terms of sizeof(isc_netaddrlink_t)
so they scale with pointer width, and pull the 99999 entry count
out into a NENTRIES macro.

Assisted-by: Claude:claude-opus-4-7
2026-05-20 13:29:22 +00:00
Andoni Duarte
6cae1d10ca Merge tag 'v9.21.22'
Some checks are pending
CodeQL / Analyze (push) Waiting to run
SonarCloud / Build and analyze (push) Waiting to run
2026-05-20 10:26:28 +00:00
Ondřej Surý
61b1e53a70 fix: nil: Properly handle BN_num_bits() return value
Some checks are pending
CodeQL / Analyze (push) Waiting to run
SonarCloud / Build and analyze (push) Waiting to run
BN_num_bits() returns 0 on NULL input and a negative value on internal
error.  The error return value is now properly handled.

Merge branch 'ondrej/fix-BN_num_bits-return-value' into 'main'

See merge request isc-projects/bind9!12057
2026-05-19 21:05:59 +02:00
Ondřej Surý
965995c66a
Properly handle the return value of BN_num_bits()
BN_num_bits() returns 0 when passed NULL and a negative value on
internal error.  The OpenSSL wrappers stored the result in a size_t,
so a 0 return falsely satisfied the bit-length check and a negative
return wrapped to a huge value.  Capture the int return, reject
non-positive values, then compare against the limit.
2026-05-19 19:21:49 +02:00
Ondřej Surý
78ececa6bd fix: usr: Reject RRSIG records covering meta-types
A recursive resolver could accept and cache an RRSIG record whose
Type-Covered field names a meta-type (ANY, AXFR, IXFR, MAILA, MAILB),
even though no real RRset of those types ever exists. Such records
are now rejected by the DNS message parser.

Closes #6002

Merge branch '6002-reject-rrsig-covering-meta-types' into 'main'

See merge request isc-projects/bind9!12048
2026-05-19 15:00:39 +02:00
Ondřej Surý
c28ba9c3c6
Reject malformed RRSIG records
A signature cannot cover a meta-type (NONE, ANY, AXFR, IXFR, MAILB,
MAILA, OPT, TSIG, TKEY); previously such records were cached by the
recursive resolver and collided with negative-cache entries on the
same owner name, corrupting the QP-trie cache.

Assisted-by: Claude:claude-opus-4-7
2026-05-19 13:21:48 +02:00
Matthijs Mekking
3b45b43600 fix: dev: Don't remove corresponding RRSIG in the same loop
Some checks are pending
CodeQL / Analyze (push) Waiting to run
SonarCloud / Build and analyze (push) Waiting to run
The `dns_db_deleterdataset()` removing the corresponding signature within the iterator is wrong, because it mutates an rdataset that is not the current one.  This has been fixed.

Merge branch 'matthijs-fix-evict-cname-other' into 'main'

See merge request isc-projects/bind9!12047
2026-05-19 09:48:15 +00:00
Matthijs Mekking
1abd977f43
Don't remove corresponding RRSIG in the same loop
The dns_db_deleterdataset() removing the corresponding signature
within the iterator is wrong, because it mutates an rdataset
that is not the current one.
2026-05-19 11:19:47 +02:00
Ondřej Surý
e90a828307 fix: usr: Fix TCP fallback after repeated UDP timeouts
When an authoritative server failed to respond to two consecutive
UDP queries in a fetch, named was supposed to retry the next attempt
over TCP but in fact still sent it over UDP.  The resolver now
properly switches the transport to TCP on the third attempt to
the same server.

Closes #5529

Merge branch '5529-fix-tcp-fallback-after-udp-timeouts' into 'main'

See merge request isc-projects/bind9!12022
2026-05-19 11:19:04 +02:00
Ondřej Surý
08295d004e
Skip EDNS UDP-size hint on TCP retries
The hint feeds the EDNS OPT UDP-size field, which has no effect on TCP
transport.  Avoid the dns_adb_getudpsize() lookup when the query is
already pinned to TCP.

Assisted-by: Claude:claude-opus-4-7
2026-05-19 11:18:30 +02:00
Ondřej Surý
db28b2127a
Raise the per-server recursive-clients ceiling in fetchlimit
With the resolver now legitimately escalating to TCP after repeated
UDP timeouts to the same authoritative, each lame-server lookup
takes ~50% longer to fail.  The recursive-client backlog therefore
peaks a little higher before the fetches-per-server auto-tune drops
the quota below 200.

Bump the upper bound for the burst-against-lame-server and recovery
steps from 200 to 250 to absorb that extra latency.  The lower bound
and the final post-recovery target (clients <= 20) are unchanged.

Assisted-by: Claude:claude-opus-4-7
2026-05-19 11:18:30 +02:00
Ondřej Surý
0c0e905615
Add pytest serve_stale TCP-fallback regression tests
The serve_stale shell suite uses a UDP-only perl mock as its
authoritative server.  Now that the resolver escalates to TCP after
repeated UDP timeouts, three steps in serve_stale/tests.sh that
exercise resolver-query-timeout behaviour no longer reach the
timeout — the TCP fallback short-circuits to SERVFAIL via
`connection refused` on the perl mock.

Move those scenarios to a new system test directory
`bin/tests/system/serve_stale_tcp/` that uses a
ControllableAsyncDnsServer mock listening on both UDP and TCP, so
the resolver's TCP path is exercised end-to-end and the original
timing semantics are preserved.  Remove the corresponding shell
steps from serve_stale/tests.sh.

Assisted-by: Claude:claude-opus-4-7
2026-05-19 11:18:30 +02:00
Ondřej Surý
308c370796
Allow either UDP or TCP queries in flight in statistics test
The "active sockets" and "queries in progress" assertions previously
required exactly one extra UDP/IPv4 socket and exactly one UDP query in
progress, with no TCP counterpart.  That shape held only because the
broken TCP-fallback path left the resolver retrying UDP indefinitely.

With the fix in place, after two UDP timeouts to the same authority the
resolver legitimately escalates to TCP, and a stats snapshot taken
during recursion may catch the in-flight query on either transport.
Count the UDP and TCP counters together so the test reflects the new
correct behaviour.

Assisted-by: Claude:claude-opus-4-7
2026-05-19 11:18:30 +02:00
Ondřej Surý
a0db3d6505
Tighten serve_stale dig timeouts and inter-step sleeps
With the TCP fallback now actually firing after repeated UDP timeouts,
the resolver covers more retry transitions in the same wall-clock
window, and the original 3-second budgets in two steps of the
serve_stale test left no margin: the dig client at +timeout=3 and the
"sleep 3" before re-enabling the upstream both straddled the moment at
which the resolver switched transport, making the asserted outcome
race-prone.

Drop the dig timeout to 2s and the sleep to 1s so each step lands
firmly on one side of the transport switch.

Co-authored-by: Evan Hunt <each@isc.org>
Assisted-by: Claude:claude-opus-4-7
2026-05-19 11:18:30 +02:00
Ondřej Surý
a9283c08c2
Emit EDE 22 when the resolver runs out of usable addresses
Two exits from fctx_try() landed at DNS_R_SERVFAIL without attaching
DNS_EDE_NOREACHABLEAUTH: when fctx_getaddresses() returned a non-success,
non-wait status, and when every candidate addrinfo was unusable
(over-quota or filtered) after a restart.

With the new TCP fallback actually firing, those paths are now reached
by serve-stale and similar scenarios in which the auth is unreachable.
Attach the EDE so SERVFAIL responses keep carrying the same operator
signal that the timeout-based exit paths already produce.

Co-authored-by: Evan Hunt <each@isc.org>
Assisted-by: Claude:claude-opus-4-7
2026-05-19 11:18:30 +02:00
Ondřej Surý
1af37e24b2
Open the stale-refresh-time window on any resolver failure
The TCP-fallback fix in the previous commits means a query that would
previously have timed out on UDP now actually escalates to TCP, and a
TCP-side failure surfaces a non-ISC_R_TIMEDOUT result code to
query_usestale().  The trigger for DNS_DBFIND_STALESTART was previously
narrowed to ISC_R_TIMEDOUT, so the stale-refresh-time window stopped
opening for those clients.

Broaden the condition to any failure that has already cleared the
upstream DUPLICATE/DROP filtering in query_usestale() — the spirit of
the window is "the resolver tried and could not get a fresh answer",
not "the resolver timed out specifically".

Co-authored-by: Evan Hunt <each@isc.org>
Assisted-by: Claude:claude-opus-4-7
2026-05-19 11:18:30 +02:00
Ondřej Surý
59c00a6f31
Force TCP after repeated UDP timeouts to the same authoritative
Make the decision in fctx_query() before the dispatch is bound so the
chosen transport and the DNS_FETCHOPT_TCP flag agree.  The previous
location in resquery_send() ran after the UDP dispatch had already been
attached, so the flag flip had no effect on the wire.

Moving the decision earlier also means FCTX_ADDRINFO_NOEDNS0 servers,
previously exempt, now escalate to TCP too.  TCP works regardless of
EDNS state, so this is the intended behaviour.

Assisted-by: Claude:claude-opus-4-7
2026-05-19 11:18:30 +02:00
Ondřej Surý
01523a078a
Temporarily remove TCP fallback after UDP timeouts
The retry path in resquery_send() that flipped DNS_FETCHOPT_TCP on a
query whose dispatch had already been bound as UDP in fctx_query() had
no effect on the transport actually used, but did leave a stale TCP
bit visible to downstream consumers (dnstap framing, cookie checks,
the AUTHORITY-NS spoofability guard).

The ineffective code has been removed from resquery_send().  The
TCP fallback functionality will be corrected and restored in the next
commit.

Assisted-by: Claude:claude-opus-4-7
2026-05-19 11:18:16 +02:00
Ondřej Surý
54f5210463 chg: usr: named could crash on concurrent TKEY DELETE for the same key
Some checks failed
CodeQL / Analyze (push) Has been cancelled
SonarCloud / Build and analyze (push) Has been cancelled
On a server configured with tkey-gssapi-keytab (or tkey-gssapi-credential),
an authenticated peer could crash named by sending two TKEY DELETE requests
for the same dynamic key in rapid succession.  This has been fixed.

Closes #6001

Merge branch '6001-tsig-tkey-delete-uaf' into 'main'

See merge request isc-projects/bind9!12041
2026-05-18 06:48:58 +02:00
Ondřej Surý
5c8dcd4419
Fix use-after-free in concurrent dns_tsigkey_delete()
Two TSIG-authenticated TKEY DELETE queries for the same dynamic key,
arriving on different worker loops, could each enter
dns_tsigkey_delete() and cause over-decrementing the key refcount.

This has been fixed by making dns_tsigkey_delete() idempotent.
2026-05-17 17:14:08 +02:00
Matthijs Mekking
9f84037814 fix: usr: The resolver now removes other RRsets at the same name when caching a CNAME
Some checks are pending
CodeQL / Analyze (push) Waiting to run
SonarCloud / Build and analyze (push) Waiting to run
When an RRset is in stale cache, and the authoritative server changes the record type to CNAME, the resolver fails to refresh the stale cache. This has been fixed.

Closes #5302

Merge branch '5302-serve-stale-cname-to-a' into 'main'

See merge request isc-projects/bind9!11758
2026-05-17 09:56:20 +00:00
Matthijs Mekking
69a560fff1 When caching names, check for CNAME RRsets
CNAME and other record types cannot coexist. DNSSEC records are the
exceptions to this rule.

If the answer contains a name with a CNAME, remove existing RRsets at
the same name from the cache.

If the answer contains a name without a CNAME, remove the CNAME RRset
at the same name from the cache.
2026-05-17 08:42:05 +00:00
Matthijs Mekking
4ee526cb6d Add serve-stale test case for CNAME to A
Add a serve-stale system test case where the authority changes a
CNAME RRset to A (at cname2.stale.test). The CNAME that is in the
cache is stale and should be refreshed. The target A record (at
a2.stale.test) has a longer TTL and is also still in the cache. The
next query should return the refreshed A RRset to the client.

Then the authority changes back the A RRset to CNAME. The A RRset
has become stale and should be refreshed. The next query should
return the refreshed CNAME RRset plus the already cached
a2.stale.test A record.

This test requires ns1 to allow dynamic updates to stale.test, and
prefetch to be disabled. The latter is to ensure the record is not
prefetched, but only refreshed when stale (and logs the expected
"an attempt to refresh the RRset" messages).
2026-05-17 08:42:05 +00:00
Matthijs Mekking
c95128ed47 Remove duplicate check in serve-stale test 2026-05-17 08:42:05 +00:00
Ondřej Surý
abe0369436 fix: nil: More changes to PR-Agent CI job
Some checks are pending
CodeQL / Analyze (push) Waiting to run
SonarCloud / Build and analyze (push) Waiting to run
Merge branch 'ondrej/use-claude-opus-4-6' into 'main'

See merge request isc-projects/bind9!12037
2026-05-17 00:04:49 +02:00
Ondřej Surý
ee5e933933
Add both Claude 4.6 and ChatGPT in two separate job pipelines 2026-05-16 22:26:05 +02:00
Ondřej Surý
dae0820f80
Allow failure to not block pipelines for the PR-Agent CI job 2026-05-16 17:53:20 +02:00
Ondřej Surý
99194aec84
Change the PR-Agent configuration to use Claude 4.6 2026-05-16 17:50:42 +02:00
Ondřej Surý
a44b91eae1 fix: nil: Properly use other_checks_jobs template for pr-agent CI job
Some checks are pending
CodeQL / Analyze (push) Waiting to run
SonarCloud / Build and analyze (push) Waiting to run
Merge branch 'ondrej/pr-agent-other-check' into 'main'

See merge request isc-projects/bind9!12035
2026-05-16 13:29:30 +02:00
Ondřej Surý
5550fb84ae
Properly use other_checks_jobs template for pr-agent CI job 2026-05-16 13:22:45 +02:00
Ondřej Surý
be727bd5e2 fix: dev: Run PR-Agent only when manually triggered
Merge branch 'ondrej/run-pr-agent-only-manually' into 'main'

See merge request isc-projects/bind9!12033
2026-05-16 12:50:19 +02:00
Ondřej Surý
4257454262
Run PR-Agent only when manually triggered 2026-05-16 12:49:54 +02:00
Ondřej Surý
9755fb6455 new: dev: Enable PR-Agent reviews on merge requests
Adds a CI job that runs PR-Agent against each merge request opened
from the canonical repository, posting an automated review and
code-improvement suggestions as MR comments. The job is gated to
same-project source branches so the OpenAI key and personal access
token are not exposed to fork pipelines.

Merge branch 'ondrej/add-pr-agent' into 'main'

See merge request isc-projects/bind9!12032
2026-05-16 12:30:01 +02:00
Ondřej Surý
07345b25d9
Add PR-Agent job to GitLab CI for merge-request review
Run PR-Agent's `review` and `improve` commands against each merge
request from the canonical repository, posting an automated review
and code-improvement suggestions as MR comments. The rule restricts
the job to MRs whose source project matches CI_PROJECT_PATH so the
OpenAI key and GitLab personal access token are never exposed to
fork pipelines.
2026-05-16 12:14:33 +02:00
Ondřej Surý
fce9f32367 chg: dev: Allow any valid DNS name as a TSIG/RNDC key name
Some checks are pending
CodeQL / Analyze (push) Waiting to run
SonarCloud / Build and analyze (push) Waiting to run
The key-generation tools (tsig-keygen, rndc-confgen) now accept any valid DNS name for key names.

Merge branch 'ondrej/allow-all-valid-keynames' into 'main'

See merge request isc-projects/bind9!12029
2026-05-15 11:00:31 +02:00