Commit Graph

2194 Commits

Author SHA1 Message Date
Simon Kelley
467fbd1086 Fix argument-order thinko on call to new lookup_frec() 2024-11-03 23:07:54 +00:00
Simon Kelley
7b7aef903e Handle error return from blockdata_alloc in all cases. 2024-11-02 22:37:51 +00:00
Simon Kelley
09a1839272 Don't send suspect answer as query to next server in DNS TCP codepath. 2024-11-02 22:18:56 +00:00
Simon Kelley
1b76e1c8ec Remove hash-questions.c - no longer required. 2024-11-02 21:29:47 +00:00
Simon Kelley
959d991d10 Replace query hashing in TCP code path. 2024-11-02 21:09:17 +00:00
Simon Kelley
ed6d29a784 Remove query hashing in UDP DNS code path.
Now we're always saving the query, this is no longer necessary,
and allows the removal of a lot of quite hairy code.

Much more code removal to come, once the TCP code path is also purged.
2024-11-02 15:33:37 +00:00
Simon Kelley
5d6399b71c DOn't churn a query though the blockdata store twice when forwarding it. 2024-11-01 16:50:15 +00:00
Simon Kelley
3b6df06fb8 Always save forwarded query locally.
We do this in many cases anyway (DNSSEC, fast-retry) and doing
it unconditionally allows much simplification of knarly code, to follow.
2024-11-01 16:06:58 +00:00
Simon Kelley
a9d46d42cb Tweak packet-reduction code going from TCP->UDP. 2024-10-13 23:09:48 +01:00
Simon Kelley
0338aa4586 Don't log bogus source address when doing fast retry. 2024-10-13 00:09:26 +01:00
Simon Kelley
d15d371051 Handle truncated response UDP-to-TCP to downstream queries when validating.
A relatively common situation is that the reply to a downstream query
will fit in a UDP packet when no DNSSEC RRs are present, but overflows
when the RRSIGS, NSEC ect are added. This extends the automatic
move from UDP to TCP to downstream queries which get truncated replies,
in the hope that once stripped of the DNSSEC RRs, the reply can be returned
via UDP, nwithout making the downstream retry with TCP.

If the downstream sets the DO bit, (ie it wants the DNSSEC RRs, then
this path is not taken, since the downstream will have to get a truncated
repsonse and retry to get a correct answer.
2024-10-12 22:32:21 +01:00
Simon Kelley
1c26ec2876 UDP-to-TCP bugfix: wrong calls to extract_name and
suppress rapid (UDP) retry once we've switched to TCP.
2024-10-04 17:20:33 +01:00
Simon Kelley
e9a7cd0a50 Fix DNSSEC work counting when swapping from UDP to TCP 2024-10-04 17:20:33 +01:00
Simon Kelley
f5cdb007d8 Improve handling of truncated replies to DNSSEC queries.
Heretofore, when a validating the result of an external query triggers
a DNSKEY or DS query and the result of that query is truncated, dnsmasq
has forced the whole validation process to move to TCP by returning a
truncated reply to the original requestor. This forces the original
requestor to retry the query in TCP mode, and the DNSSEC subqueries
also get made via TCP and everything works.

Note that in general the actual answer being validated is not large
enough to trigger truncation, and there's no reason not to return that
answer via UDP if we can validate it successfully. It follows that
a substandard client which can't do TCP queries will still work if the
answer could be returned via UDP, but fails if it gets an artifically
truncated answer and cannot move to TCP.

This patch teaches dnsmasq to move to TCP for DNSSEC queries when
validating UDP answers. That makes the substandard clients mentioned
above work, and saves a round trip even for clients that can do TCP.
2024-10-04 17:20:33 +01:00
Simon Kelley
46288c7e90 Tidy up parameters to sendmsg() syscall.
The msg_controllen field passed to sendmsg is computed using the
CMSG_SPACE(), which is correct, but CMSG_SPACE() can include
padding bytes at the end of the passed structure if they are required
to align subsequent structures in the buffer. Make sure these
bytes are zeroed to avoid passing uninitiased memory to the kernel,
even though it will never touch these bytes.

Also tidy up the mashalling code in send_from to use pointers to
the structure being filled out, rather than a temporary copy which
then gets memcpy()'d into place. The DHCP sendmsg code has always
worked like this.

Thanks to  Dominik Derigs for running Memcheck as submitting the
initial patch.
2024-10-04 17:20:24 +01:00
Simon Kelley
d7d682637d Merge branch 'master' of ssh://thekelleys.org.uk/var/local/git/dnsmasq 2024-10-04 17:03:55 +01:00
Simon Kelley
f006be7842 Fix crash when reloading DHCP config on SIGHUP.
Confusion in the code to free old DHCP configuration when it's
being reloaded causes invalid pointers to be followed and a crash.

https://lists.thekelleys.org.uk/pipermail/dnsmasq-discuss/2024q4/017764.html

has a more complete explanation of the problem.
2024-10-04 16:59:14 +01:00
Simon Kelley
550c368ade Treat cache insertion failure of DNSKEY and DS records as
another resource problem and fail validation with suitable logging.
2024-03-27 16:00:06 +00:00
Simon Kelley
b8ff4bb762 Remove debian directory and replace with a git submodule. 2024-02-22 22:45:37 +00:00
Simon Kelley
9adbf009a6 The DHCPv4 server doesn't need CAP_NET_ADMIN if always broadcasting.
CAP_NET_ADMIN is needed in the DHCPv4 code to place entries into
the ARP cache. If it's configured to unconditionally broadcast
to unconfigured clients, it never touches the ARP cache and
doesn't need CAP_NET_ADMIN.

Thanks to Martin Ivičič <max.enhanced@gmail.com> for prompting this.
2024-02-21 00:46:25 +00:00
renmingshuai
ccff85ad72 [PATCH] Fix error introduced in 51471cafa5
Signed-off-by: renmingshuai <renmingshuai@huawei.com>
2024-02-21 00:24:25 +00:00
Simon Kelley
4c590320ec Fix breakage in DBus FilterA and FilterAAAA methods.
In generalising the RR filter code, the Dbus methods
controlling filtering A and AAAA records
got severely broken. This, and the previous commit,
fixes things.
2024-02-20 23:38:26 +00:00
Simon Kelley
89aad01468 Fix infinite loop when invoking SetFilterA dbus method more than once.
Also applies to SetFilterAAAA.

Thanks to Clayton Craft for spotting the issue.
2024-02-19 23:21:58 +00:00
Simon Kelley
de6f914654 Add missing CHANGELOG entries for 2.90 2024-02-19 13:22:09 +00:00
Simon Kelley
1ed783b8d7 Fix spurious "resource limit exceeded" messages.
Replies from upstream with a REFUSED rcode can result in
log messages stating that a resource limit has been exceeded,
which is not the case.

Thanks to Dominik Derigs and the Pi-hole project for
spotting this.
2024-02-19 12:22:43 +00:00
Simon Kelley
3705ec5592 Relax limits imposed by d/t/functions.d/ip-addr.patterns in Debian autotest. 2024-02-15 09:55:57 +00:00
Simon Kelley
b6769234bc Bump Debian version. 2024-02-13 13:49:15 +00:00
Simon Kelley
214a046f47 Merge branch 'dnssec-limit'
This merges security fixes for CVE-2023-50387 and CVE-2023-50868

Keytrap - extreme CPU consumption in the DNSSEC validator.
2024-02-13 13:27:25 +00:00
Simon Kelley
b38da6b191 Reverse suppression of ANY query answer logging. 2024-02-13 13:26:24 +00:00
Simon Kelley
9621c16a78 Add CHANGELOG entry for DNSSEC security fixes. 2024-02-12 23:11:35 +00:00
Simon Kelley
3ae7f1ab0d Add --dnssec-limits option. 2024-02-12 23:11:35 +00:00
Simon Kelley
39de57499e Better allocation code for DS digest cache. 2024-02-12 23:11:35 +00:00
Simon Kelley
3c91bca943 Better stats and logging from DNSSEC resource limiting. 2024-02-12 23:11:35 +00:00
Simon Kelley
76bceb06c4 Overhaul data checking in NSEC code. 2024-02-12 23:11:35 +00:00
Simon Kelley
6f23a0a75e Rework validate-by-DS to avoid DoS vuln without arbitrary limits.
By calculating the hash of a DNSKEY once for each digest algo,
we reduce the hashing work from (no. DS) x (no. DNSKEY) to
(no. DNSKEY) x (no. distinct digests)

The number of distinct digests can never be more than 255 and
it's limited by which hashes we implement, so currently only 4.
2024-02-12 23:11:35 +00:00
Simon Kelley
06945c4b77 Update EDE code -> text conversion. 2024-02-12 23:11:35 +00:00
Simon Kelley
c5aa221e44 Parameterise work limits for DNSSEC validation. 2024-02-12 23:11:35 +00:00
Simon Kelley
bfefd6e38c Fix error introduced in 635bc51cac3d5d7dd49ce9e27149cf7e402b7e79 2024-02-12 23:11:35 +00:00
Simon Kelley
59d30390c9 Measure cryptographic work done by DNSSEC. 2024-02-12 23:11:34 +00:00
Simon Kelley
51471cafa5 Update NSEC3 iterations handling to conform with RFC 9276. 2024-02-12 23:11:34 +00:00
Simon Kelley
be73efc020 Update header with new EDE values. 2024-02-12 23:11:34 +00:00
Simon Kelley
40595f80d9 Protection against pathalogical DNSSEC domains.
An attacker can create DNSSEC signed domains which need a lot of
work to verfify. We limit the number of crypto operations to
avoid DoS attacks by CPU exhaustion.
2024-02-12 23:11:34 +00:00
Simon Kelley
8c8e5385fd Close debian bug. 2024-02-12 23:11:03 +00:00
Simon Kelley
3de7289bd6 Make --filter-rr=ANY filter the answer to ANY queries.
Thanks to Dominik Derigs for an earlier patch which inspired this.
2024-02-12 20:45:20 +00:00
Simon Kelley
febeea9d01 Tweak logging and special handling of T_ANY in rr-filter code. 2024-02-12 13:42:07 +00:00
Heikki Linnakangas
762a3f2430 Don't create a useless inotify file desrcriptor when --port=0
If there are no dynamic configuration directories configured with
dhcp-hostsdir, dhcp-optsdir and hostsdir then we need to use inotify
only to track changes to resolv-files, but we don't need to do
that when DNS is disabled (port=0) or no resolv-files are configured.

It turns out that inotify slots can be a scarce resource, so not
using one when it's not needed is a Goood Thing.

Patch by HL, description above from SRK.
2024-02-07 14:44:49 +00:00
Simon Kelley
6d35601da4 Refactor the accumulated crud of years in process_reply(). 2024-02-05 22:33:09 +00:00
Simon Kelley
a827127c77 Handle caching SOA for negative PTR queries.
Also deal with the fact that a root SOA is a thing.
2024-02-03 20:46:23 +00:00
Simon Kelley
d4a6f3a93e Fix logic error in signed RR handling.
In extract_addresses() the "secure" argument is only set if the
whole reply is validated (ie the AD bit can be set). Even without
that, some records may be validated, and should be marked
as such in the cache.

Related, the DNS doctor code has to update the flags for individual
RRs as it works, not the global "secure" flag.
2024-02-02 21:36:56 +00:00
Simon Kelley
86c15032ba Fix compiler warning. 2024-02-02 00:26:44 +00:00