2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-29 13:38:26 +00:00

38716 Commits

Author SHA1 Message Date
Mark Andrews
0a8f44a8f7 Make dnssec-keygen FIPS mode aware
- Reject SHA1 based key generation
- Increase the minimum RSA key size to 2048 bits
2023-04-03 12:05:29 +10:00
Mark Andrews
e7aa100e9b Use isc_fips_mode() and isc_fips_set_mode() in
bin/named/server.c and lib/dns/openssl_link.c
2023-04-03 12:05:29 +10:00
Michal Nowak
4d094f6b51 Disable failing MD5 unit tests in FIPS mode
With FIPS mode enabled 'isc_hmac_init_test' and 'isc_hmac_md5_test'
tests of hmac_test and 'isc_md_init_test' and 'isc_md_md5_test' test
of md_test fail.

This is due to leveraging MD5, which is disabled in FIPS mode.
2023-04-03 12:05:29 +10:00
Mark Andrews
6e8de4bcdc Allow FIPS mode to be enabled at run time in named
If FIPS mode is supported by the OS 'named -F' will turn on FIPS
mode.
2023-04-03 12:05:29 +10:00
Mark Andrews
5a2e82557e Define isc_fips_mode() and isc_fips_set_mode()
isc_fips_mode() determines if the process is running in FIPS mode

isc_fips_set_mode() sets the process into FIPS mode
2023-04-03 12:05:28 +10:00
Mark Andrews
6e64ec2af4 Detect if FIPS mode is configured at the OS level
Always look for FIPS_mode and EVP_default_properties_enable_fips
rather than just when requested by --enable-fips.
2023-04-03 12:04:58 +10:00
Mark Andrews
7aa9b80f83 Probe for EVP_default_properties_enable_fips
FIPS_mode is not available in OpenSSL 3.0.0
2023-04-03 12:04:58 +10:00
Evan Hunt
c774aed465 add --enable-fips-mode to configure summary
Report when FIPS mode is enabled or disabled in the configure
summary output.
2023-04-03 12:04:58 +10:00
Michal Nowak
e987a0c249 Enable FIPS testing in Pairwise
It's useful to configure and build with FIPS mode in Pairwise testing
because it exposes some parts of the code otherwise hiden.
2023-04-03 12:04:58 +10:00
Michal Nowak
60e50c6e15 Add scheduled FIPS mode jobs 2023-04-03 12:04:58 +10:00
Mark Andrews
e10947872a Merge branch '3980-add-timeouts-to-unit-tests' into 'main'
Resolve "Add timeouts to unit tests."

Closes #3980

See merge request isc-projects/bind9!7762
2023-04-03 00:42:27 +00:00
Mark Andrews
3d5c7cd46c Kill unit tests that run more than 1200 seconds
The CI doesn't provide useful forensics when a system test locks
up.  Fork the process and kill it with ABRT if it is still running
after 20 minutes.  Pass the exit status to the caller.
2023-04-03 00:15:43 +00:00
Tony Finch
8ac962fc1c Merge branch 'fanf-trampoline-go-jump' into 'main'
Simplify thread spawning

See merge request isc-projects/bind9!7293
2023-03-31 17:11:04 +00:00
Tony Finch
555690a3c9 Simplify thread spawning
The `isc_trampoline` module had a lot of machinery to support stable
thread IDs for use by hazard pointers. But the hazard pointer code
is gone, and the `isc_loop` module now has its own per-loop thread
IDs.

The trampoline machinery seems over-complicated for its remaining
tasks, so move the per-thread initialization into `isc/thread.c`,
and delete the rest.
2023-03-31 17:21:52 +01:00
Ondřej Surý
1736900b4e Merge branch 'ondrej/simplify-isc_time_now' into 'main'
Refactor isc_time_now() to return time, and not result

See merge request isc-projects/bind9!7761
2023-03-31 15:51:15 +00:00
Ondřej Surý
a5f5f68502
Refactor isc_time_now() to return time, and not result
The isc_time_now() and isc_time_now_hires() were used inconsistently
through the code - either with status check, or without status check,
or via TIME_NOW() macro with RUNTIME_CHECK() on failure.

Refactor the isc_time_now() and isc_time_now_hires() to always fail when
getting current time has failed, and return the isc_time_t value as
return value instead of passing the pointer to result in the argument.
2023-03-31 15:02:06 +02:00
Ondřej Surý
da039ec2b3 Merge branch '3982-remove-isc_fsaccess-API' into 'main'
Replace isc_fsaccess API with more secure file creation

Closes #3982

See merge request isc-projects/bind9!7766
2023-03-31 12:53:22 +00:00
Ondřej Surý
f853672e41 Add CHANGES note for [GL #3982] 2023-03-31 12:52:59 +00:00
Ondřej Surý
263d232c79 Replace isc_fsaccess API with more secure file creation
The isc_fsaccess API was created to hide the implementation details
between POSIX and Windows APIs.  As we are not supporting the Windows
APIs anymore, it's better to drop this API used in the DST part.

Moreover, the isc_fsaccess was setting the permissions in an insecure
manner - it operated on the filename, and not on the file descriptor
which can lead to all kind of attacks if unpriviledged user has read (or
even worse write) access to key directory.

Replace the code that operates on the private keys with code that uses
mkstemp(), fchmod() and atomic rename() at the end, so at no time the
private key files have insecure permissions.
2023-03-31 12:52:59 +00:00
Ondřej Surý
aca7dd3961 Add isc_os_umask() function to get current umask
As it's impossible to get the current umask without modifying it at the
same time, initialize the current umask at the program start and keep
the loaded value internally.  Add isc_os_umask() function to access the
starttime umask.
2023-03-31 12:52:59 +00:00
Ondřej Surý
d664e3c612 Merge branch 'ondrej/squash-dns_name_fullhash-and-dns_name_hash' into 'main'
Squash dns_name_fullhash() and dns_name_hash()

See merge request isc-projects/bind9!7759
2023-03-31 12:43:50 +00:00
Ondřej Surý
956155f613 Squash dns_name_fullhash() and dns_name_hash()
The only place where dns_name_hash() was being used is the old hash
table in the dns_badcache unit.  Squash the dns_name_fullhash() and
dns_name_hash() into single dns_name_hash() function that's always
case-insensitive as it doesn't make to do case-sensitive hashing of the
domain names and we were not using this anywhere.
2023-03-31 12:43:30 +00:00
Ondřej Surý
1ca0fb0e02 Merge branch 'ondrej/add-isc_stdtime_now' into 'main'
Provide isc_stdtime_now(void) that returns value

See merge request isc-projects/bind9!7757
2023-03-31 11:58:13 +00:00
Ondřej Surý
a568a3d52a
Add CHANGES note for [GL !7757] 2023-03-31 13:33:18 +02:00
Ondřej Surý
4bd6096d4b
Remove isc_stdtime_get() macro
Now that isc_stdtime_get() macro is unused, remove it from the header
file.
2023-03-31 13:33:16 +02:00
Ondřej Surý
46f06c1d6e
Apply the semantic patch to remove isc_stdtime_get()
This is a simple replacement using the semantic patch from the previous
commit and as added bonus, one removal of previously undetected unused
variable in named/server.c.
2023-03-31 13:32:56 +02:00
Ondřej Surý
0ec8d7b6f3
Add a semantic patch to change isc_stdtime_get() to isc_stdtime_now
Add a simple semantic patch to rewrite all uses of isc_stdtime_get(&t)
to simpler t = isc_stdtime_now().
2023-03-31 13:16:28 +02:00
Ondřej Surý
c11af0448a
Provide isc_stdtime_now(void) that returns value
As isc_stdtime_get() cannot fail, the API seems to be too complicated,
add new isc_stdtime_now() that returns the unixtime as a return value.
2023-03-31 13:16:28 +02:00
Tony Finch
3e106b3a8f Merge branch '3970-dighost-signal-crash' into 'main'
Fix a crash when dig or host receive a signal

Closes #3970

See merge request isc-projects/bind9!7756
2023-03-31 09:54:05 +00:00
Tony Finch
194621a74e Fix a crash when dig or host receive a signal
When the loopmanager is shutting down following a signal,
`dig` and `host` should stop cleanly. Before this commit
they were oblivious to ISC_R_SHUTTINGDOWN.

The `isc_signal` callbacks now report this kind of mistake
with a stack backtrace.
2023-03-31 09:52:54 +00:00
Matthijs Mekking
aacd05be4b Merge branch 'matthijs-checkconf-kasp-test-bug' into 'main'
Fix kasp system test bug

See merge request isc-projects/bind9!7750
2023-03-31 08:33:24 +00:00
Matthijs Mekking
106497b011 Fix kasp system test bug
This test was succeeding for the wrong reason (policy not found, rather
than bad key length).
2023-03-31 08:33:01 +00:00
Ondřej Surý
aa760f997d Merge branch 'ondrej/add-maybe_unused-attribute-macro' into 'main'
Replace __attribute__((unused)) with ISC_ATTR_UNUSED attribute macro

See merge request isc-projects/bind9!7345
2023-03-30 22:16:49 +00:00
Ondřej Surý
2c0a9575d7
Replace __attribute__((unused)) with ISC_ATTR_UNUSED attribute macro
Instead of marking the unused entities with UNUSED(x) macro in the
function body, use a `ISC_ATTR_UNUSED` attribute macro that expans to
C23 [[maybe_unused]] or __attribute__((__unused__)) as fallback.
2023-03-30 23:29:25 +02:00
Ondřej Surý
1176bf0552
Use C23 attributes if available, add ISC_ATTR_UNUSED
Use C23 attribute styles if available:

  * Add new ISC_ATTR_UNUSED attribute macro that either expands to C23's
    [[maybe_unused]] or __attribute__((__unused__));

  * Add default expansion of the `noreturn` to [[noreturn]] if available;

  * Move the FALLTHROUGH from <isc/util.h> to <isc/attributes.h>
2023-03-30 22:43:39 +02:00
Michal Nowak
0086dcd4da Merge branch 'mnowak/replace-enable_dnsprs_dl-with-enable_dnsrps_dl' into 'main'
Replace enable_dnsprs_dl with enable_dnsrps_dl

See merge request isc-projects/bind9!7745
2023-03-30 17:51:42 +00:00
Michal Nowak
1dcfe6bfbd
Replace enable_dnsprs_dl with enable_dnsrps_dl
"enable_dnsprs_dl" is a typo where "enable_dnsrps_dl" was intended.
2023-03-30 19:44:34 +02:00
Artem Boldariev
f3579b1760 Merge branch 'artem-tlsstream-followup-to-2846888c573fcc610cdf71bcdd5bb6f92ffaf499' into 'main'
TLS Stream: remove incorrect/obsolete INSIST()s from tls_do_bio()

See merge request isc-projects/bind9!7751
2023-03-30 16:41:05 +00:00
Artem Boldariev
43e21d653f TLS Stream: remove incorrect/obsolete INSIST()s from tls_do_bio()
With the changes to tls_try_handshake() made in
2846888c573fcc610cdf71bcdd5bb6f92ffaf499 there are some incorrect
INSISTS() related to handshake handling which better to be removed.
2023-03-30 18:21:50 +03:00
Ondřej Surý
696b2c8c89 Merge branch 'ondrej/reduce-atomic-use-in-netmgr' into 'main'
Refactor the use of atomics in netmgr

See merge request isc-projects/bind9!7724
2023-03-30 14:26:38 +00:00
Ondřej Surý
2846888c57
Attach the accept "client" socket to .listener member of the socket
When accepting a TCP connection in the higher layers (tlsstream,
streamdns, and http) attach to the socket the connection was accepted
on, and use this socket instead of the parent listening socket.

This has an advantage - accessing the sock->listener now doesn't break
the thread boundaries, so we can properly check whether the socket is
being closed without requiring .closing member to be atomic_bool.
2023-03-30 16:10:08 +02:00
Ondřej Surý
45365adb32
Convert sock->active to non-atomic variable, cleanup rchildren
The last atomic_bool variable sock->active was converted to non-atomic
bool by properly handling the listening socket case where we were
checking parent socket instead of children sockets.

This is no longer necessary as we properly set the .active to false on
the children sockets.

Additionally, cleanup the .rchildren - the atomic variable was used for
mutex+condition to block until all children were listening, but that's
now being handled by a barrier.

Finally, just remove dead .self and .active_child_connections members of
the netmgr socket.
2023-03-30 16:10:08 +02:00
Ondřej Surý
e1a4572fd6
Refactor the use of atomics in netmgr
Now that everything runs on their own loop and we don't cross the thread
boundaries (with few exceptions), most of the atomic_bool variables used
to track the socket state have been unatomicized because they are always
accessed from the matching thread.

The remaining few have been relaxed: a) the sock->active is now using
acquire/release memory ordering; b) the various global limits are now
using relaxed memory ordering - we don't really care about the
synchronization for those.
2023-03-30 16:10:08 +02:00
Ondřej Surý
ea8e00e7a5 Merge branch '3961-add-fast-isc_loop_run' into 'main'
Refactor isc_job_run to not-make any allocations

Closes #3961

See merge request isc-projects/bind9!7722
2023-03-30 14:09:50 +00:00
Ondřej Surý
5d64306b72
Add CHANGES for [GL #3961] 2023-03-30 16:07:41 +02:00
Ondřej Surý
f5fc224af3
Add isc_async_current() macro to run job on current loop
Previously, isc_job_run() could have been used to run the job on the
current loop and the isc_job_run() would take care of allocating and
deallocating the job.  After the change in this MR, the isc_job_run()
is more complicated to use, so we introduce the isc_async_current()
macro to suplement isc_async_run() when we need to run the job on the
current loop.
2023-03-30 16:07:41 +02:00
Ondřej Surý
1844590ad9
Refactor isc_job_run to not-make any allocations
Change the isc_job_run() to not-make any allocations.  The caller must
make sure that it allocates isc_job_t - usually as part of the argument
passed to the callback.

For simple jobs, using isc_async_run() is advised as it allocates its
own separate isc_job_t.
2023-03-30 16:00:52 +02:00
Ondřej Surý
639d5065a3
Refactor the isc__nm_uvreq_t to have idle callback
Change the isc__nm_uvreq_t to have the idle callback as a separate
member as we always need to use it to properly close the uvreq.

Slightly refactor uvreq_put and uvreq_get to remove the unneeded
arguments - in uvreq_get(), we always use sock->worker, and in
uvreq_put, we always use req->sock, so there's not reason to pass those
extra arguments.
2023-03-29 21:16:44 +02:00
Ondřej Surý
476198f26c
Use uv_idle API for calling asynchronous connect/read/send callback
Instead of using isc_job_run() that's quite heavy as it allocates memory
for every new job, add uv_idle_t to uvreq union, and use uv_idle API
directly to execute the connect/read/send callback without any
additional allocations.
2023-03-29 21:16:44 +02:00
Ondřej Surý
670df3da74
Re-add the comment to streamdns_readmore()
Put the comment back, so it's more obvious that we are only restarting
timer when there's a last handle attached to the socket; there has to be
always at least one.
2023-03-29 21:16:44 +02:00