2020-07-31 09:20:56 -04:00
|
|
|
include $(top_srcdir)/Makefile.top
|
|
|
|
|
|
Avoid using C99 variable length arrays
From an attacker's point of view, a VLA declaration is essentially a
primitive for performing arbitrary arithmetic on the stack pointer. If
the attacker can control the size of a VLA they have a very powerful
tool for causing memory corruption.
To mitigate this kind of attack, and the more general class of stack
clash vulnerabilities, C compilers insert extra code when allocating a
VLA to probe the growing stack one page at a time. If these probes hit
the stack guard page, the program will crash.
From the point of view of a C programmer, there are a few things to
consider about VLAs:
* If it is important to handle allocation failures in a controlled
manner, don't use VLAs. You can use VLAs if it is OK for
unreasonable inputs to cause an uncontrolled crash.
* If the VLA is known to be smaller than some known fixed size,
use a fixed size array and a run-time check to ensure it is large
enough. This will be more efficient than the compiler's stack
probes that need to cope with arbitrary-size VLAs.
* If the VLA might be large, allocate it on the heap. The heap
allocator can allocate multiple pages in one shot, whereas the
stack clash probes work one page at a time.
Most of the existing uses of VLAs in BIND are in test code where they
are benign, but there was one instance in `named`, in the GSS-TSIG
verification code, which has now been removed.
This commit adjusts the style guide and the C compiler flags to allow
VLAs in test code but not elsewhere.
2022-03-18 10:50:36 -04:00
|
|
|
AM_CFLAGS += \
|
|
|
|
|
$(TEST_CFLAGS)
|
|
|
|
|
|
2020-07-31 09:20:56 -04:00
|
|
|
AM_CPPFLAGS += \
|
|
|
|
|
$(LIBISC_CFLAGS) \
|
|
|
|
|
$(LIBDNS_CFLAGS) \
|
Refactor qp-trie to use QSBR
The first working multi-threaded qp-trie was stuck with an unpleasant
trade-off:
* Use `isc_rwlock`, which has acceptable write performance, but
terrible read scalability because the qp-trie made all accesses
through a single lock.
* Use `liburcu`, which has great read scalability, but terrible
write performance, because I was relying on `rcu_synchronize()`
which is rather slow. And `liburcu` is LGPL.
To get the best of both worlds, we need our own scalable read side,
which we now have with `isc_qsbr`. And we need to modify the write
side so that it is not blocked by readers.
Better write performance requires an async cleanup function like
`call_rcu()`, instead of the blocking `rcu_synchronize()`. (There
is no blocking cleanup in `isc_qsbr`, because I have concluded
that it would be an attractive nuisance.)
Until now, all my multithreading qp-trie designs have been based
around two versions, read-only and mutable. This is too few to
work with asynchronous cleanup. The bare minimum (as in epoch
based reclamation) is three, but it makes more sense to support an
arbitrary number. Doing multi-version support "properly" makes
fewer assumptions about how safe memory reclamation works, and it
makes snapshots and rollbacks simpler.
To avoid making the memory management even more complicated, I
have introduced a new kind of "packed reader node" to anchor the
root of a version of the trie. This is simpler because it re-uses
the existing chunk lifetime logic - see the discussion under
"packed reader nodes" in `qp_p.h`.
I have also made the chunk lifetime logic simpler. The idea of a
"generation" is gone; instead, chunks are either mutable or
immutable. And the QSBR phase number is used to indicate when a
chunk can be reclaimed.
Instead of the `shared_base` flag (which was basically a one-bit
reference count, with a two version limit) the base array now has a
refcount, which replaces the confusing ad-hoc lifetime logic with
something more familiar and systematic.
2022-12-22 09:55:14 -05:00
|
|
|
$(LIBUV_CFLAGS) \
|
2020-07-31 09:20:56 -04:00
|
|
|
-DFUZZDIR=\"$(abs_srcdir)\"
|
|
|
|
|
|
2020-09-28 03:09:21 -04:00
|
|
|
AM_LDFLAGS += \
|
2020-07-31 09:20:56 -04:00
|
|
|
$(FUZZ_LDFLAGS)
|
|
|
|
|
|
2021-04-21 08:22:18 -04:00
|
|
|
LDADD += \
|
2020-07-31 09:20:56 -04:00
|
|
|
libfuzzmain.la \
|
2022-06-12 10:52:35 -04:00
|
|
|
$(LIBDNS_LIBS) \
|
|
|
|
|
$(LIBISC_LIBS)
|
2020-07-31 09:20:56 -04:00
|
|
|
|
|
|
|
|
check_LTLIBRARIES = libfuzzmain.la
|
|
|
|
|
libfuzzmain_la_SOURCES = \
|
2020-08-06 03:10:06 -04:00
|
|
|
fuzz.h \
|
2020-07-31 09:20:56 -04:00
|
|
|
main.c
|
|
|
|
|
|
|
|
|
|
check_PROGRAMS = \
|
2021-02-19 12:08:36 -05:00
|
|
|
dns_master_load \
|
2022-03-02 05:48:26 -05:00
|
|
|
dns_message_checksig \
|
2020-08-25 03:51:40 -04:00
|
|
|
dns_message_parse \
|
2020-07-31 09:20:56 -04:00
|
|
|
dns_name_fromtext_target \
|
2022-11-07 11:22:48 -05:00
|
|
|
dns_name_fromwire \
|
2021-02-18 15:29:33 -05:00
|
|
|
dns_rdata_fromtext \
|
2020-07-31 09:20:56 -04:00
|
|
|
dns_rdata_fromwire_text \
|
|
|
|
|
isc_lex_getmastertoken \
|
|
|
|
|
isc_lex_gettoken
|
|
|
|
|
|
|
|
|
|
EXTRA_DIST = \
|
2021-02-19 12:08:36 -05:00
|
|
|
dns_master_load.in \
|
2022-03-02 05:48:26 -05:00
|
|
|
dns_message_checksig.in \
|
2020-08-25 03:51:40 -04:00
|
|
|
dns_message_parse.in \
|
2020-07-31 09:20:56 -04:00
|
|
|
dns_name_fromtext_target.in \
|
2022-11-07 11:22:48 -05:00
|
|
|
dns_name_fromwire.in \
|
2022-06-12 10:52:35 -04:00
|
|
|
dns_qp.in \
|
|
|
|
|
dns_qpkey_name.in \
|
2021-02-18 15:29:33 -05:00
|
|
|
dns_rdata_fromtext.in \
|
2020-07-31 09:20:56 -04:00
|
|
|
dns_rdata_fromwire_text.in \
|
|
|
|
|
isc_lex_getmastertoken.in \
|
|
|
|
|
isc_lex_gettoken.in
|
|
|
|
|
|
2022-11-07 11:22:48 -05:00
|
|
|
dns_name_fromwire_SOURCES = \
|
|
|
|
|
dns_name_fromwire.c \
|
|
|
|
|
old.c \
|
|
|
|
|
old.h
|
|
|
|
|
|
2022-06-12 10:52:35 -04:00
|
|
|
if HAVE_CMOCKA
|
|
|
|
|
|
|
|
|
|
check_PROGRAMS += \
|
|
|
|
|
dns_qp \
|
|
|
|
|
dns_qpkey_name
|
|
|
|
|
|
|
|
|
|
AM_CPPFLAGS += \
|
|
|
|
|
-I$(top_srcdir)/lib/dns \
|
|
|
|
|
-I$(top_srcdir)/lib/isc \
|
|
|
|
|
-I$(top_srcdir)/tests/include
|
|
|
|
|
|
|
|
|
|
# libisc needs to appear after libtest
|
|
|
|
|
LDADD += \
|
|
|
|
|
$(top_builddir)/tests/libtest/libtest.la \
|
|
|
|
|
$(LIBISC_LIBS)
|
|
|
|
|
|
|
|
|
|
endif HAVE_CMOCKA
|
|
|
|
|
|
2020-07-31 09:20:56 -04:00
|
|
|
TESTS = $(check_PROGRAMS)
|
|
|
|
|
|
|
|
|
|
if HAVE_FUZZ_LOG_COMPILER
|
|
|
|
|
LOG_COMPILER = $(srcdir)/$(FUZZ_LOG_COMPILER)
|
|
|
|
|
AM_LOG_FLAGS = $(srcdir)
|
|
|
|
|
endif HAVE_FUZZ_LOG_COMPILER
|
|
|
|
|
|
|
|
|
|
unit-local: check
|