Commit graph

11782 commits

Author SHA1 Message Date
Michał Kępień
1d0bb1de10 Address GCC 9.1 -O3 compilation warnings
Compiling with -O3 triggers the following warnings with GCC 9.1:

    task.c: In function ‘isc_taskmgr_create’:
    task.c:1386:43: warning: ‘%04u’ directive output may be truncated writing between 4 and 10 bytes into a region of size 6 [-Wformat-truncation=]
     1386 |   snprintf(name, sizeof(name), "isc-worker%04u", i);
          |                                           ^~~~
    task.c:1386:32: note: directive argument in the range [0, 4294967294]
     1386 |   snprintf(name, sizeof(name), "isc-worker%04u", i);
          |                                ^~~~~~~~~~~~~~~~
    task.c:1386:3: note: ‘snprintf’ output between 15 and 21 bytes into a destination of size 16
     1386 |   snprintf(name, sizeof(name), "isc-worker%04u", i);
          |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    private_test.c: In function ‘private_nsec3_totext_test’:
    private_test.c:113:9: warning: array subscript 4 is outside array bounds of ‘uint32_t[1]’ {aka ‘unsigned int[1]’} [-Warray-bounds]
      113 |  while (*sp == '\0' && slen > 0) {
          |         ^~~
    private_test.c:106:11: note: while referencing ‘salt’
      106 |  uint32_t salt;
          |           ^~~~

Prevent these warnings from being triggered by increasing the size of
the relevant array (task.c) and reordering conditions (private_test.c).

(cherry picked from commit ce796ac1f4)
2019-06-11 10:19:04 +02:00
Mark Andrews
f33d9a825f POST(optlen)
(cherry picked from commit 4e97f7dccc)
2019-06-04 15:48:52 +10:00
Mark Andrews
65ece077c2 teach cppcheck that _assert_int_equal and _assert_int_not_equal don't return on failure
(cherry picked from commit 5d5d751c7f)
2019-06-04 15:23:49 +10:00
Witold Kręcicki
b6d11230b2 Fix a possible race between udp dispatch and socket code
There's a small possibility of race between udp dispatcher and
socket code - socket code can still hold internal reference to a
socket while dispatcher calls isc_socket_open, which can cause
an assertion failure. Fix it by relaxing the assertion test, and
instead simply locking the socket in isc_socket_open.

(cherry picked from commit e517c18d98)
2019-05-31 12:32:37 -07:00
Witold Kręcicki
60d0da833b Use experimental "_ A" minimization in relaxed mode.
qname minimization, even in relaxed mode, can fail on
some very broken domains. In relaxed mode, instead of
asking for "foo.bar NS" ask for "_.foo.bar A" to either
get a delegation or NXDOMAIN. It will require more queries
than regular mode for proper NXDOMAINs.

(cherry picked from commit ae52c2117e)
2019-05-31 09:25:44 +02:00
Witold Kręcicki
8b29a7cbf4 Don't SERVFAIL on lame delegations when doing minimization in relaxed mode.
qname minimization in relaxed mode should fall back to regular
resolution in case of failure.

(cherry picked from commit 2691e729f0)
2019-05-31 09:25:23 +02:00
Mark Andrews
6ca95b5478 fix Ed448 length values for precomputed ASN.1 prefix blobs
(cherry picked from commit 5da97eeea6)
2019-05-30 23:09:23 +10:00
Ondřej Surý
d0181cb97d Revert "Merge branch '996-wrong-key-id-is-displayed-for-rsamd5-keys' into 'master'"
This reverts commit ea131d2e6a, reversing
changes made to e79dd268b6.

(cherry picked from commit 52a8fb31c7)
2019-05-30 14:32:58 +02:00
Ondřej Surý
8464fef786 Pull the values for LFS_{CFLAGS,LDFLAGS,LIBS} from autoconf instead using them directly in make
(cherry picked from commit d4596baed4)
2019-05-29 13:34:55 +02:00
Ondřej Surý
f7050fc728 Use getconf LFS_{CFLAGS,LDFLAGS,LIBS} to get flags to compile lib/dns/gen
On some systems (namely Debian buster armhf) the readdir() call fails
with `Value too large for defined data type` unless the
_FILE_OFFSET_BITS=64 is defined.  The correct way to fix this is to
get the appropriate compilation parameters from getconf system
interface.

(cherry picked from commit 4c7345bcb6)
2019-05-29 10:30:39 +02:00
Ondřej Surý
a17eb8dec4 Exit the ./gen program on failed readdir() call
(cherry picked from commit 05b7c08a16)
2019-05-29 10:30:39 +02:00
Witold Kręcicki
000fdd8fa5 Fix a possible deadlock in TCP accepting
Each network thread holds an array of locks, indexed by a hash
of fd. When we accept a connection we hold a lock in accepting thread.
We then generate the thread number and lock bucket for the new
connection socket - if we hit the same thread and lock bucket as
accepting socket we get a deadlock. Avoid this by checking if we're
in the same thread/lock bucket and not locking in this case.

(cherry picked from commit 75815c1581)
2019-05-24 12:50:15 +02:00
Ondřej Surý
2b343d1fc1 Use SO_REUSEPORT_LB on FreeBSD if available
(cherry picked from commit 94cb73d96c)
2019-05-17 07:45:21 +02:00
Ondřej Surý
5d8d65bfdc Add safeguard against the other usage of SO_REUSEPORT
(cherry picked from commit 1c672367a0)
2019-05-17 07:45:21 +02:00
Witold Kręcicki
0617148792 Remove UNSPEC rrtype
(cherry picked from commit a8e2ca6f7d)
2019-05-13 10:52:48 +07:00
Mark Andrews
4de58ee1c8 arm: just use the compiler's default yield support
(cherry picked from commit f546769b8b)
2019-05-13 12:19:26 +10:00
Tinderbox User
d7862ea81c prep 9.14.2 2019-05-10 04:51:22 +00:00
Michał Kępień
c6bf43a821 Make NTAs work with validating forwarders
If named is configured to perform DNSSEC validation and also forwards
all queries ("forward only;") to validating resolvers, negative trust
anchors do not work properly because the CD bit is not set in queries
sent to the forwarders.  As a result, instead of retrieving bogus DNSSEC
material and making validation decisions based on its configuration,
named is only receiving SERVFAIL responses to queries for bogus data.
Fix by ensuring the CD bit is always set in queries sent to forwarders
if the query name is covered by an NTA.

(cherry picked from commit 5e80488270)
2019-05-09 20:37:37 -07:00
Ondřej Surý
c10f361f44 Make lib/dns/gen.c compatible with reproducible builds.
The gen.c will now use SOURCE_DATE_EPOCH[1] if found in environment
to make the build more reproducible build friendly.

1. https://reproducible-builds.org/specs/source-date-epoch/

(cherry picked from commit c8cb612d39)
2019-05-09 16:05:12 +07:00
Mark Andrews
07f8daf536 Recognise EDNS Client Tag and EDNS Server Tag
(cherry picked from commit ee7cf180b3)
2019-05-09 18:19:29 +10:00
Evan Hunt
9b59425d06 warn about the use of trusted-keys and managed-keys for the same name 2019-05-08 21:59:35 -07:00
Mark Andrews
7dd4fa9da3 enforce known SSHFP finger print lengths
(cherry picked from commit 1722728c80)
2019-05-09 08:48:28 +10:00
Mark Andrews
8c7052e1cf only test provideixfr if the transport is TCP
(cherry picked from commit 18c49853e3)
2019-05-07 13:43:14 +10:00
Mark Andrews
dbbbed29e9 clear pointer before hash table
(cherry picked from commit 4886701c03)
2019-05-07 11:07:32 +10:00
Mark Andrews
0e6a620432 fix whitespace
(cherry picked from commit 32ba5a0494)
2019-05-07 10:27:18 +10:00
Mark Andrews
2ffdbe9eff return rdatasets when processing ANY queries in client_resfind
(cherry picked from commit 127333c71f)
2019-05-07 10:27:18 +10:00
Evan Hunt
fb58d23a94 simplify the isc_stat structure to take avantage of atomics
(cherry picked from commit 4e5edb35e4)
2019-05-06 14:02:41 -07:00
Evan Hunt
524d36bc2d attach memory context sooner so that cleanup will work correctly
(cherry picked from commit 0fd344e77a)
2019-04-26 15:53:48 -07:00
Ondřej Surý
e203d4d65a Replace atomic operations in bin/named/client.c with isc_refcount reference counting
(cherry picked from commit ef49780d30)
2019-04-26 21:33:50 +02:00
Tinderbox User
02cbca91d7 prep 9.14.1
(cherry picked from commit c7004347bc)
2019-04-25 17:00:56 +02:00
Evan Hunt
86e9e54766 restore allowance for tcp-clients < interfaces
in the "refactor tcpquota and pipeline refs" commit, the counting
of active interfaces was tightened in such a way that named could
fail to listen on an interface if there were more interfaces than
tcp-clients. when checking the quota to start accepting on an
interface, if the number of active clients was above zero, then
it was presumed that some other client was able to handle accepting
new connections. this, however, ignored the fact that the current client
could be included in that count, so if the quota was already exceeded
before all the interfaces were listening, some interfaces would never
listen.

we now check whether the current client has been marked active; if so,
then the number of active clients on the interface must be greater
than 1, not 0.

(cherry picked from commit 02365b87ea0b1ea5ea8b17376f6734c811c95e61)
(cherry picked from commit cae79e1bab)
2019-04-25 16:20:50 +02:00
Evan Hunt
a78af2f1d3 refactor tcpquota and pipeline refs; allow special-case overrun in isc_quota
- if the TCP quota has been exceeded but there are no clients listening
  for new connections on the interface, we can now force attachment to the
  quota using isc_quota_force(), instead of carrying on with the quota not
  attached.
- the TCP client quota is now referenced via a reference-counted
  'ns_tcpconn' object, one of which is created whenever a client begins
  listening for new connections, and attached to by members of that
  client's pipeline group. when the last reference to the tcpconn
  object is detached, it is freed and the TCP quota slot is released.
- reduce code duplication by adding mark_tcp_active() function
- convert counters to stdatomic

(cherry picked from commit a8dd133d270873b736c1be9bf50ebaa074f5b38f)
(cherry picked from commit 4a8fc979c4)
2019-04-25 16:20:50 +02:00
Evan Hunt
a41c9dbfc1 better tcpquota accounting and client mortality checks
- ensure that tcpactive is cleaned up correctly when accept() fails.
- set 'client->tcpattached' when the client is attached to the tcpquota.
  carry this value on to new clients sharing the same pipeline group.
  don't call isc_quota_detach() on the tcpquota unless tcpattached is
  set.  this way clients that were allowed to accept TCP connections
  despite being over quota (and therefore, were never attached to the
  quota) will not inadvertently detach from it and mess up the
  accounting.
- simplify the code for tcpquota disconnection by using a new function
  tcpquota_disconnect().
- before deciding whether to reject a new connection due to quota
  exhaustion, check to see whether there are at least two active
  clients. previously, this was "at least one", but that could be
  insufficient if there was one other client in READING state (waiting
  for messages on an open connection) but none in READY (listening
  for new connections).
- before deciding whether a TCP client object can to go inactive, we
  must ensure there are enough other clients to maintain service
  afterward -- both accepting new connections and reading/processing new
  queries.  A TCP client can't shut down unless at least one
  client is accepting new connections and (in the case of pipelined
  clients) at least one additional client is waiting to read.

(cherry picked from commit 427a2fb4d17bc04ca3262f58a9dcf5c93fc6d33e)
(cherry picked from commit 0896841272)
2019-04-25 16:20:49 +02:00
Michał Kępień
010e6f4bd7 use reference counter for pipeline groups (v3)
Track pipeline groups using a shared reference counter
instead of a linked list.

(cherry picked from commit 31f392db20207a1b05d6286c3c56f76c8d69e574)
(cherry picked from commit 2211120222)
2019-04-25 16:20:49 +02:00
Witold Kręcicki
ef28e8879b tcp-clients could still be exceeded (v2)
the TCP client quota could still be ineffective under some
circumstances.  this change:

- improves quota accounting to ensure that TCP clients are
  properly limited, while still guaranteeing that at least one client
  is always available to serve TCP connections on each interface.
- uses more descriptive names and removes one (ntcptarget) that
  was no longer needed
- adds comments

(cherry picked from commit 9e74969f85329fe26df2fad390468715215e2edd)
(cherry picked from commit d7e84cee0b)
2019-04-25 16:20:49 +02:00
Witold Kręcicki
4ca208adb8 fix enforcement of tcp-clients (v1)
tcp-clients settings could be exceeded in some cases by
creating more and more active TCP clients that are over
the set quota limit, which in the end could lead to a
DoS attack by e.g. exhaustion of file descriptors.

If TCP client we're closing went over the quota (so it's
not attached to a quota) mark it as mortal - so that it
will be destroyed and not set up to listen for new
connections - unless it's the last client for a specific
interface.

(cherry picked from commit eafcff07c25bdbe038ae1e4b6660602a080b9395)
(cherry picked from commit 9e7617cc84)
2019-04-25 16:20:49 +02:00
Matthijs Mekking
6b22e1f4fe Fix nxdomain-redirect assertion failure
- Always set is_zonep in query_getdb; previously it was only set if
  result was ISC_R_SUCCESS or ISC_R_NOTFOUND.
- Don't reset is_zone for redirect.
- Style cleanup.

(cherry picked from commit a85cc641d7a4c66cbde03cc4e31edc038a24df46)
(cherry picked from commit 486a201149)
2019-04-25 15:59:43 +02:00
Witold Kręcicki
434ef46661 When resuming from qname-minimization increase fetches-per-zone counters for the 'new' zone
(cherry picked from commit 7043c6eaf5)
2019-04-24 11:03:37 +10:00
Mark Andrews
1b432b3633 compute the RSAMD5 key id
(cherry picked from commit ffaa5a07dd)
2019-04-24 08:51:50 +10:00
Mark Andrews
ca51ee2bb3 use isc_refcount_decrement to decrement NEWCONNSOCK(dev)->references; use isc_refcount_increment instead of isc_refcount_init in socket_create
(cherry picked from commit 265554f895)
2019-04-23 14:47:20 +10:00
Mark Andrews
ff2c10cced add assertions to silence clang false positive
(cherry picked from commit bed9ad79ba)
2019-04-23 14:05:47 +10:00
Evan Hunt
fcd2c2b644 force SERVFAIL response in the gotanswer failure case
- named could return FORMERR if parsing iterative responses
  ended with a result code such as DNS_R_OPTERR. instead of
  computing a response code based on the result, in this case
  we now just force the response to be SERVFAIL.

(cherry picked from commit 7402615697)
2019-04-22 19:11:41 -07:00
Mark Andrews
d5d4ddd764 using 0 instead of false
(cherry picked from commit da7f683abf)
2019-04-23 11:45:33 +10:00
Ondřej Surý
3349792aa3 On non-GNUC systems, use uintmax_t in the ISC_ALIGN macro
(cherry picked from commit 2e40cc94dc)
2019-04-18 13:17:21 +02:00
Ondřej Surý
cd40d65e1b Refactor the DNS_RDATASET_FIXED code to use constants instead of ifdefs
(cherry picked from commit 4edbb773a1)
2019-04-17 11:34:17 +02:00
Evan Hunt
19f249ffa5 if recursion is allowed and minimal-responses is no, search other databases
this restores functionality that was removed in commit 03be5a6b4e,
allowing named to search in authoritative zone databases outside the
current zone for additional data, if and only if recursion is allowed
and minimal-responses is disabled.

(cherry picked from commit 7fff3295f5)
2019-04-15 11:38:28 -07:00
Matthijs Mekking
f4dc62f33b With update-check-ksk also consider offline keys
The option `update-check-ksk` will look if both KSK and ZSK are
available before signing records.  It will make sure the keys are
active and available.  However, for operational practices keys may
be offline.  This commit relaxes the update-check-ksk check and will
mark a key that is offline to be available when adding signature
tasks.

(cherry picked from commit 3cb8c49c73)
2019-04-12 11:33:06 +02:00
Matthijs Mekking
244870844c Style: some curly brackets
(cherry picked from commit 2e83e3255a)
2019-04-12 11:33:06 +02:00
Evan Hunt
f6c3b13522 dnstap: if recursion is not available, log queries as AQ instead of CQ
(cherry picked from commit 1f578cdb12)
2019-04-11 15:45:52 -07:00
Mark Andrews
b27ef87c38 Add debug printfs
(cherry picked from commit b78e128a2f)
2019-04-11 19:47:44 +10:00