Commit Graph
1799 Commits
Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek 06cd836342 resolved: inline trivial function 2021-02-25 14:07:21 +01:00
Joerg Behrmann fa02711758 treewide: fix spelling 2021-02-25 05:54:11 +09:00
Sergey Bugaev 2aaf376597 resolved: don't discard mDNS queries with bad flags
Even though RFC 6762 specifies these bits MUST be zero, it also says they MUST
be ignored on reception.
2021-02-24 17:17:03 +01:00
Sergey Bugaev 7675501540 resolved: don't discard mDNS packets with ip6.arpa RRs
ip6.arpa is also a valid domain name to put in mDNS packets.
2021-02-24 17:17:03 +01:00
Lennart Poettering 013668db32 resolved: don't dereference ->scope unless set
Coverity 1446388
2021-02-23 15:45:23 +01:00
Lennart Poettering 999c248629 resolved: fix minor memory leak
Coverity 1446992
2021-02-23 15:45:03 +01:00
Zbigniew Jędrzejewski-Szmek 2b767e9222 resolved: add another explanatory message to stub resolv.conf files
Apparently people do "cat /etc/resolv.conf" and not realize that they
are looking at a file in /run.
2021-02-23 17:20:23 +09:00
Lennart Poettering 048e043375 resolved: actually use the specified rrsig argument
The argument only exists to be used to override/fill in the RRSIG record
of the answer item. Hence actually use it instead of ignore it.

(Not sure how this got lost earlier.)

Fixes: #18714
2021-02-23 01:52:33 +01:00
Zbigniew Jędrzejewski-Szmek 67e700bad7 Merge pull request #18741 from poettering/stub-no-cname
resolved: don't follow CNAMEs in the stub anymore
2021-02-23 01:52:01 +01:00
Zbigniew Jędrzejewski-Szmek 267294e08d Merge pull request #18745 from keszybz/stop-using-fstrings
Stop using fstrings
2021-02-23 01:10:38 +01:00
Zbigniew Jędrzejewski-Szmek d6191ed529 test-dns-packet: fix leak of DnsResourceRecord object 2021-02-23 01:06:08 +01:00
Zbigniew Jędrzejewski-Szmek a5e5e102ba Merge pull request #18704 from keszybz/fallback-hostame-override
Allow overriding of fallback hostname through envvar and os-release field
2021-02-23 00:41:27 +01:00
Lennart Poettering 5bd7ebb332 resolved: stick CNAME targets into main answer section in stub replies 2021-02-22 23:55:13 +01:00
Lennart Poettering d1f8fbea9f resolved: add dns_resource_record_get_cname_target() helper
This determines the redirection target from a CNAME or DNAME RR given it
matches some given RR key.
2021-02-22 23:55:13 +01:00
Lennart Poettering 990e7e87ad resolved: remove duplicate comment
Practically the same comment is a few lines up covering both parts
anyway, let's remove one.
2021-02-22 23:55:13 +01:00
Lennart Poettering c6ebf89b8f resolved: update comment in DNS stub code a bit
There's no "answer_auxiliary" object anymore, it's all one "answer"
object, and we have per-item flags that tell us which section things are
from, i.e. from the main answer section, or the additional or
authoritative ones.
2021-02-22 23:55:13 +01:00
Lennart Poettering 2f4d8e577c resolved: don't follow CNAMEs in the stub anymore
CNAME following was broken by 775ae35403
where we'd not properly collect RRs along the CNAME path. Good thing
though is that we don't have to anymore: since we nowadays propagate all
sections of the upstream replies into the cache and back to stub clients
all the information should already be available anyway, and there's no
need for us to collect it.

Fixes: #18690
2021-02-22 23:55:13 +01:00
Zbigniew Jędrzejewski-Szmek f2ec239c2b Revert "generate-dns_type-gperf: modernize python syntax"
This reverts commit b0a336a669.

Fixes #18708.
2021-02-22 22:43:14 +01:00
Zbigniew Jędrzejewski-Szmek 05c6f341b1 Allow the fallback hostname to be overriden using an environment variable
See https://bugzilla.redhat.com/show_bug.cgi?id=1893417 for the back story:
the fallback hostname matters a lot in certain environments. Right now the only
way to configure the fallback hostname is by recompiling systemd, which is
obviously problematic in case when the fallback hostname shall differ between
different editions of the same distro that share a single compiled rpm.

By making this overridable through an envvar, we're providing an escape hatch
without making this a top-level api. Later on a way to set this through
os-release is added, but I think the approach with the variable is still
useful. It it very convenient for testing, or to override settings only in a
particular service, etc.
2021-02-22 20:10:55 +01:00
Sergey Bugaev bb4e030fcb resolved: set the AA bit for mDNS responses
This is required by RFC 6762.

Fixes https://github.com/systemd/systemd/issues/17972
2021-02-22 14:52:13 +03:00
Sergey Bugaev 4ad017cda5 resolved: set the AA bit for synthetic answers
The stub DNS server is authoritative for the RRs we synthesize, such as
localhost, _gateway, and entries from /etc/hosts, and also for trust anchors.

Partially fixes https://github.com/systemd/systemd/issues/17972
2021-02-22 14:51:29 +03:00
Zbigniew Jędrzejewski-Szmek 8b8024f1c2 shared/conf-parser: allow more than one location of the main config file
No functional change as long as only one path is passed.
2021-02-21 12:22:13 +01:00
Lennart Poettering 2306d1778f systemctl: don't search in the full argv[0] for the invocation name
argv[0] might be prefixed by a path, and we shouldn't get confused by
that. Hence provide a simple helper call that abstracts the checking
away, which we can use everywhere, and expose the same behaviour, even
if argv[0] is not set.

(While we are at it, port all other multi-call binaries over to the new
helper, too)

Follow-up for: d41a9e4fc1
2021-02-20 14:45:27 +01:00
Sven Mueller b87fbe5fd7 Fix grammar and a small typo on a comment
potentically -> potentially
(And a small grammar fix)
2021-02-19 12:43:10 +01:00
Yu Watanabe b480543cf0 tree-wide: fix typo 2021-02-19 07:56:22 +01:00
Zbigniew Jędrzejewski-Szmek 09db71a4a3 Recommend drop-ins over modifications to the main config file
As discussed in https://github.com/systemd/systemd/pull/18347.
2021-02-19 14:05:42 +09:00
Lennart Poettering f715584018 resolved: improve debug logging on incoming messages a bit 2021-02-18 20:34:18 +01:00
Lennart Poettering 669963968c Merge pull request #18664 from poettering/resolved-defrag
resolved: many UDP fragmentation tweaks
2021-02-18 18:20:36 +01:00
Lennart Poettering cbf23f3853 resolved: optimize change notification handling away if bus calls set the same values as were already set
Prompted-by: #17577 (but doesn't fix this, since this commit only
handles D-Bus-induced changes, not the ones made via networkd)
2021-02-18 16:38:27 +01:00
Lennart Poettering 980821f3f0 resolved: take fragment size into consideration when determining EDNS0 udp packet size 2021-02-18 15:55:58 +01:00
Lennart Poettering acbf761b5d resolved: let's track fragment sizes of servers/retry on fragmenting
Fragmenting sucks, let's avoid it. Thus let's start tracking the maximum
fragment size we receive.

Also, let's redo a transaction via TCP if we see fragmenting on UDP, as
effective mitigation against DNS fragment attacks.
2021-02-18 15:55:58 +01:00
Lennart Poettering d79677ab44 resolved: tweak how we calculate MTU for sending packets
Let's take all MTU info we possibly have into account, i.e. the one
reported via netlink, as before and the one the socket might now (from
PMTUD and such), clamped by our own ideas.
2021-02-18 15:55:58 +01:00
Lennart Poettering 4565863fff resolved: add udp_header_size() helper 2021-02-18 15:55:58 +01:00
Lennart Poettering 20a001bdd7 resolved: collect incoming fragment size when receiving UDP datagrams
We can later use this to adapt our announced EDNS buffer size in order
to avoid fragmentation to make the best of large datagrams while still
avoiding he security weaknesses of it.
2021-02-18 15:42:18 +01:00
Lennart Poettering eb170e75ab resolved: disable path MTU discovery for UDP traffic
This disables path MTU discovery both for our UDP upstream connections
and our UDP stub, following the suggestions of:

https://blog.apnic.net/2019/07/12/its-time-to-consider-avoiding-ip-fragmentation-in-the-dns/

This more or less follows the model of other DNS servers on this.
2021-02-18 15:42:18 +01:00
Zbigniew Jędrzejewski-Szmek d97a35e228 Merge pull request #18665 from poettering/resolved-fastopen
resolved: use TCP FASTOPEN on the local DNS stub
2021-02-18 12:55:10 +01:00
Lennart Poettering dc288ffeab Merge pull request #18596 from keszybz/systemctl-quiet-legend
systemctl: hide legends with --quiet, allow overriding
2021-02-17 23:40:04 +01:00
Lennart Poettering 2840d6f61d Merge pull request #18662 from yuwata/in-addr-is-set
in-addr-util: introduce in_addr_is_set() or friends
2021-02-17 23:13:27 +01:00
Lennart Poettering b850e51320 resolved: also use TCP tweaks on LLMNR (plus unify setsockopt() code) 2021-02-17 21:12:53 +01:00
Lennart Poettering 8624f1286a resolved: enable TCP_FASTOPEN + TCP_NODELAY on stub TCP socket
Latency matters. Four our local DNS stub it's not really that important,
but let's still do it, it's basically free after all.
2021-02-17 21:12:53 +01:00
Zbigniew Jędrzejewski-Szmek c3470872c6 tree-wide: use parse_boolean_argument() for variables with non-boolean type
This still works nicely, but we need to assign the return value ourselves.
As before, one nice effect is that error messages are uniform.
2021-02-17 21:08:47 +01:00
Zbigniew Jędrzejewski-Szmek 599c7c545f tree-wide: add a helper to parse boolean optarg
This nicely covers the case when optarg is optional. The same parser can be
used when the option string passed to getopt_long() requires a parameter and
when it doesn't.

The error messages are made consistent.
Also fixes a log error c&p in --crash-reboot message.
2021-02-17 21:06:31 +01:00
Yu Watanabe b1dea5cffa resolve: use sockaddr_in_addr() 2021-02-18 03:48:07 +09:00
Yu Watanabe bb3b08ad98 resolve: make manager_find_ifindex() or friends return earlier 2021-02-18 03:48:07 +09:00
Yu Watanabe 94876904bb tree-wide: use in_addr_is_set() or friends 2021-02-18 03:48:07 +09:00
Lennart Poettering e30a62bfe6 resolved: see if it's worth retrying a lookup on "failed-auxiliary" DNSSEC error
Maybe we learnt something about the server feature set, let's hence
retry.

Fixes: #11102
2021-02-17 19:25:13 +01:00
Lennart Poettering d96275d8eb resolved: in DNSSEC permissive mode, check if DO bit wasn't copied from request to response
If the server doesn't copy the DO bit from request to response, this is
a very early and easy indication that it doesn#t support DNSSEC
properly. Hence, let's immediately downgrade to non-DNSSEC mode if we
see this – if permissive mode is on and this is allowed.
2021-02-17 19:25:13 +01:00
Lennart Poettering 1ed4e584f3 resolved: address DVE-2018-0001
This is an updated version of #8608 with more restrictive logic. To
quite the original bug:

    Some captive portals, lie and do not respond with the captive portal
    IP address, if the query is with EDNS0 enabled and D0 bit set to
    zero. Thus retry "secure" domain name look ups with less secure
    methods, upon NXDOMAIN.

https://github.com/dns-violations/dns-violations/blob/master/2018/DVE-2018-0001.md

Yes, this fix sucks hard, but I guess this is what we need to do to make
sure resolved works IRL.

Heavily based on the original patch from Dimitri John Ledkov, and I
copied the commentary verbatim.

Replaces: #8608
2021-02-17 18:06:13 +01:00
Lennart Poettering 4a6eb82445 resolved: include NSID support to DNS stub
This adds minimal support for RFC5001 NSID to the stub resolver. This
useful to identify systemd-resolved when talking to the stub resolver,
and distuingishing the packets resolved answers itself (where NSID is
now set) from those which it proxies 1:1 upstream (where NSID will not
be set, or set to whatever the upstream server has it set to).

The NSID chosen consist of two parts:

1. The first part is derived from /etc/machine-id and identifies the
   resolved instance in a stable way.

2. The second part is the fixed string ".resolved.systemd.io".

This thus maybe used for a veriety of checks:

a. Am I talking to a resolved stub?
b. Am I talking to the same stub as last time?
c. Am I talking to the local resolved?

Given that the first part leaks the identity of the system in away two
protections are in place:

I) The NSID is only included on the main stub, not the extra stub. The
   main stub has with a TTL of 1 and other protections a lot of safety
   in place that the datagrams never leave the local system, thus the
   identifying info is only accessible to the local system — but
   /etc/machine-id is accessible to local software anyway.

II) The NSID is hashed from /etc/machine-id in a non-invertable way, so
    that the machine ID itself isn't leaked, but only an identifier
    derived from it.

Example dig run:

```
$ dig +nsid localhost @127.0.0.53

; <<>> DiG 9.11.23-RedHat-9.11.23-1.fc33 <<>> +nsid localhost @127.0.0.53
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 46917
;; flags: qr rd ra ad; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 65494
; NSID: 35 33 64 34 61 34 66 63 32 31 32 65 34 31 61 30 39 66 30 39 65 33 32 34 63 64 64 38 30 36 32 33 2e 72 65 73 6f 6c 76 65 64 2e 73 79 73 74 65 6d 64 2e 69 6f ("53d4a4fc212e41a09f09e324cdd80623.resolved.systemd.io")
;; QUESTION SECTION:
;localhost.			IN	A

;; ANSWER SECTION:
localhost.		0	IN	A	127.0.0.1

;; Query time: 0 msec
;; SERVER: 127.0.0.53#53(127.0.0.53)
;; WHEN: Do Nov 12 20:57:16 CET 2020
;; MSG SIZE  rcvd: 110
```
2021-02-17 09:42:07 +01:00
Benjamin Robin 0e2d092d43 resolve: Fix build for cleanup function (SSL_free + BIO_free)
Follow-up of #18616
2021-02-16 23:57:29 +01:00