]> git.ipfire.org Git - thirdparty/chrony.git/log
thirdparty/chrony.git
3 years agomain: add assertions for timespec signedness
Miroslav Lichvar [Tue, 23 Nov 2021 13:41:08 +0000 (14:41 +0100)] 
main: add assertions for timespec signedness

Some of the code (e.g. util and clientlog) may work with negative
values. Require that time_t and the tv_nsec types are signed. This seems
to be the case on all supported systems, but it it is not required by
POSIX.

3 years agoutil: reset GetRandom functions in helpers after fork
Miroslav Lichvar [Tue, 23 Nov 2021 12:17:26 +0000 (13:17 +0100)] 
util: reset GetRandom functions in helpers after fork

Close /dev/urandom and drop cached getrandom() data after forking helper
processes to avoid them getting the same sequence of random numbers
(e.g. two NTS-KE helpers generating cookies with identical nonces).
arc4random() is assumed to be able to detect forks and reseed
automatically.

This is not strictly necessary with the current code, which does not use
the GetRandom functions before the NTS-KE helper processes are forked,
but that could change in future.

Also, call the reset function before exit to close /dev/urandom in order
to avoid valgrind reporting the file object as "still reachable".

3 years agontp: fix exp1 EF search in process_response()
Miroslav Lichvar [Tue, 23 Nov 2021 09:35:22 +0000 (10:35 +0100)] 
ntp: fix exp1 EF search in process_response()

Don't ignore the magic field when searching for the exp1 extension
field in a received response. If there were two exp1 fields in the
packet, and only one of them had the expected magic value, it should
pick the right one.

Fixes: 2319f72b29a9 ("ntp: add client support for experimental extension field")
3 years agontp: make default NTP version with xleave to be always 4
Miroslav Lichvar [Mon, 22 Nov 2021 15:44:24 +0000 (16:44 +0100)] 
ntp: make default NTP version with xleave to be always 4

If the xleave option is enabled, ignore the key option and the hash
length. Always use version 4 as the default to get interleaved responses
from new chrony servers.

3 years agontp: limit interleaved responses to NTPv4
Miroslav Lichvar [Mon, 22 Nov 2021 15:33:46 +0000 (16:33 +0100)] 
ntp: limit interleaved responses to NTPv4

The interleaved modes are being specified for NTPv4 only. As a server,
detect interleaved requests only in NTPv4 packets.

Clients and peers can still send interleaved requests in lower-version
packets if configured with the version option.

3 years agontp: suppress monotonic timestamp if smoothing is enabled
Miroslav Lichvar [Mon, 22 Nov 2021 14:52:01 +0000 (15:52 +0100)] 
ntp: suppress monotonic timestamp if smoothing is enabled

Frequency transfer and time smoothing are conflicting features. Set the
monotonic timestamp in the experimental extension field to zero
(invalid) if time smoothing is activated.

3 years agontp: add special value to experimental root delay/disp
Miroslav Lichvar [Mon, 22 Nov 2021 10:39:29 +0000 (11:39 +0100)] 
ntp: add special value to experimental root delay/disp

The maximum value of the new 32-bit fields is slightly less than 16,
which can cause the NTP test #7 to pass for a server which has a zero
root delay but maximum root dispersion.

Interpret the maximum value as the maximum value of the original 32-bit
fields (~65536.0 seconds) for better compatibility with NTPv4.

3 years agotest: add 144-exp1 test
Miroslav Lichvar [Mon, 15 Nov 2021 09:11:03 +0000 (10:11 +0100)] 
test: add 144-exp1 test

3 years agontp: add client support for experimental extension field
Miroslav Lichvar [Mon, 15 Nov 2021 09:08:34 +0000 (10:08 +0100)] 
ntp: add client support for experimental extension field

Add "extfield F323" option to include the new extension field in
requests. If the server responds with this field, use the root
delay/dispersion and monotonic timestamp. Accumulate changes in the
offset between the monotonic and real-time receive timestamps and use
it for the correction of previous offsets in sourcestats. In the
interleaved mode, cancel out the latest change in the offset in
timestamps of the previous request and response, which were captured
before the change actually happened.

3 years agosourcestats: add function to correct accumulated offsets
Miroslav Lichvar [Wed, 10 Nov 2021 14:34:26 +0000 (15:34 +0100)] 
sourcestats: add function to correct accumulated offsets

This will be needed to follow server time corrections in order to
better estimate frequency.

3 years agontp: add server support for experimental extension field
Miroslav Lichvar [Wed, 10 Nov 2021 13:56:31 +0000 (14:56 +0100)] 
ntp: add server support for experimental extension field

Maintain a server monotonic timescale needed for the experimental
extension field. It follows the best estimate of frequency without
time corrections. Implement it as an offset relative to the NTP time,
starting at zero, using a slew handler to cancel time corrections of the
NTP clock. The 32-bit epoch ID is set to a random value on start and
every step of the system clock.

3 years agoutil: add functions for converting new root delay/dispersion
Miroslav Lichvar [Mon, 15 Nov 2021 09:25:35 +0000 (10:25 +0100)] 
util: add functions for converting new root delay/dispersion

3 years agoutil: add function to subtract NTP timestamps
Miroslav Lichvar [Wed, 10 Nov 2021 13:28:53 +0000 (14:28 +0100)] 
util: add function to subtract NTP timestamps

This will be needed to work with monotonic timestamps, which don't have
a stable epoch and cannot be converted to timespec.

3 years agontp: add pre-NTPv5 experimental extension field
Miroslav Lichvar [Wed, 10 Nov 2021 13:52:04 +0000 (14:52 +0100)] 
ntp: add pre-NTPv5 experimental extension field

Add an experimental extension field for some features that were proposed
for NTPv5. Higher-resolution root delay and dispersion (using 28-bit
fraction) are added. A monotonic receive timestamp will allow a
frequency transfer between the server and client. The client will be
able to separate the server's time corrections from frequency
corrections by tracking the offset between the real-time and monotonic
receive timestamps.

The field has a type of 0xF323 from the new experimental range proposed
by the NTP working group. Include a magic 32-bit value in the field to
avoid interoperability issues if a different implementation choses the
same type for its own experimental field. The value will be changed on
incompatible changes to avoid issues between two different chrony
versions.

3 years agontp: prepare for non-authentication extension fields
Miroslav Lichvar [Mon, 8 Nov 2021 15:35:47 +0000 (16:35 +0100)] 
ntp: prepare for non-authentication extension fields

Add a new variable to the packet info structure with flags for extension
fields included in received packets and add a new parameter to
transmit_packet() to add the fields to transmitted packets.

3 years agontp: move initial packet parsing from ntp_auth to ntp_core
Miroslav Lichvar [Mon, 8 Nov 2021 15:06:03 +0000 (16:06 +0100)] 
ntp: move initial packet parsing from ntp_auth to ntp_core

Since commit fdfcabd79bd3 ("ntp: drop support for long NTPv4 MACs"), the
parser doesn't need to check validify of MACs in NTPv4 packets to
distinguish them from extension fields. Move the parser to ntp_core to
avoid having a separate iteration looking for non-authentication
extension fields.

3 years agosocket: increase message buffer length
Miroslav Lichvar [Tue, 26 Oct 2021 13:40:09 +0000 (15:40 +0200)] 
socket: increase message buffer length

Add extra space to the socket message buffer to be able to receive
maximum-length NTP-over-PTP SW/HW-timestamped messages from the Linux
error queue (which are looped back as layer-2 frames).

3 years agontp: use previous root delay/disp in interleaved mode
Miroslav Lichvar [Tue, 26 Oct 2021 12:41:49 +0000 (14:41 +0200)] 
ntp: use previous root delay/disp in interleaved mode

When calculating the root delay and dispersion of a sample measured in
the interleaved mode, use the root delay and dispersion values from
the previous response (to which the TX timestamp corresponds). If the TX
timestamp is combined with the RX timestamp of the latest response (e.g.
in the symmetric mode), use the maximum of the previous and latest root
delay/dispersion.

3 years agotest: extend 122-xleave test
Miroslav Lichvar [Tue, 26 Oct 2021 10:22:55 +0000 (12:22 +0200)] 
test: extend 122-xleave test

3 years agoclientlog: undo clock adjustments in updated TX timestamps
Miroslav Lichvar [Mon, 25 Oct 2021 15:00:28 +0000 (17:00 +0200)] 
clientlog: undo clock adjustments in updated TX timestamps

When the server clock was updated between saving of the RX timestamp and
updating the TX timestamp, a client using interleaved mode with the four
timestamps which minimize error in measured delay (e.g. chrony) had the
server clock adjustment included in the measured delay, which could
disrupt the sample filtering and weighting.

Add a handler to track the slew epoch and remember the last offset. Undo
the adjustment in TX timestamps which have their RX timestamp in the
previous epoch to fix the delay observed by the clients.

If an unknown clock step is detected, drop all timestamps.

3 years agontp: don't save timestamps if transmit_packet() failed
Miroslav Lichvar [Mon, 25 Oct 2021 08:23:41 +0000 (10:23 +0200)] 
ntp: don't save timestamps if transmit_packet() failed

Don't save server RX and TX timestamp to clientlog if the transmission
or authentication failed (e.g. packet is handled in ntp_signd). They
will not be needed.

3 years agontp: initialize saved TX timestamp
Miroslav Lichvar [Mon, 25 Oct 2021 08:18:27 +0000 (10:18 +0200)] 
ntp: initialize saved TX timestamp

Zero the initial TX timestamp which is saved for the interleaved
mode in case there is no previous timestamp saved in clientlog and
transmit_packet() does not generate a new one (e.g. due to failure in
authentication).

Fixes: 5f4cbaab7e0e ("ntp: optimize detection of clients using interleaved mode")
3 years agocmdmon: add interleaved stats to serverstats
Miroslav Lichvar [Wed, 20 Oct 2021 14:10:21 +0000 (16:10 +0200)] 
cmdmon: add interleaved stats to serverstats

Report the number of received interleaved requests and current timestamp
count with their span.

Expand the serverstats description in chronyc man page.

3 years agotest: improve clientlog unit test
Miroslav Lichvar [Mon, 18 Oct 2021 10:25:47 +0000 (12:25 +0200)] 
test: improve clientlog unit test

Test also timestamp maps with smaller maximum sizes.

3 years agontp: don't capture TX timestamps if clientlog is disabled
Miroslav Lichvar [Mon, 18 Oct 2021 09:29:58 +0000 (11:29 +0200)] 
ntp: don't capture TX timestamps if clientlog is disabled

When responding to a request, don't waste time with TX timestamping
if the timestamp will not be saved (i.e. clientlog is disabled).

Fixes: 5f4cbaab7e0e ("ntp: optimize detection of clients using interleaved mode")
3 years agodoc: improve clientloglimit description
Miroslav Lichvar [Thu, 14 Oct 2021 10:29:47 +0000 (12:29 +0200)] 
doc: improve clientloglimit description

3 years agontp: optimize detection of clients using interleaved mode
Miroslav Lichvar [Thu, 14 Oct 2021 10:03:49 +0000 (12:03 +0200)] 
ntp: optimize detection of clients using interleaved mode

Use the lowest bit of the server RX and TX timestamp as a flag
indicating RX timestamp. This allows the server to detect potential
interleaved requests without having to save all its RX timestamps. It
significantly reduces the amount of memory needed to support clients
using the interleaved mode if most of the server's clients are using the
basic mode (e.g. a public server).

Capture the TX timestamp on the first response to the request which has
the flag set to not further delay the first interleaved response.

False positives are possible with broken clients which set the origin
timestamp to something else than zero or the server RX or TX timestamp.
This causes an unnecessary RX timestamp to be saved and TX timestamp
captured and saved.

3 years agontp: move authentication calls in transmit_packet()
Miroslav Lichvar [Thu, 14 Oct 2021 09:52:21 +0000 (11:52 +0200)] 
ntp: move authentication calls in transmit_packet()

Move the calls resetting and generating authentication data out of the
loop checking for unique TX timestamp. This allows the timestamps to be
manipulated after the check.

3 years agoclientlog: separate NTP timestamps from IP addresses
Miroslav Lichvar [Mon, 11 Oct 2021 11:27:35 +0000 (13:27 +0200)] 
clientlog: separate NTP timestamps from IP addresses

Instead of keeping one pair of RX and TX timestamp for each address, add
a separate RX->TX map using an ordered circular buffer. Save the RX
timestamps as 64-bit integers and search them with a combined linear
interpolation and binary algorithm.

This enables the server to support multiple interleaved clients sharing
the same IP address (e.g. NAT) and it will allow other improvements to
be implemented later. A drawback is that a single broken client sending
interleaved requests at a high rate (without spoofing the source
address) can now prevent clients on other addresses from getting
interleaved responses.

The total number of saved timestamps does not change. It's still
determined by the clientloglimit directive. A new option may be added
later if needed. The whole buffer is allocated at once, but only on
first use to not waste memory on client-only configurations.

3 years agoclientlog: fix debug message for maximum number of records
Miroslav Lichvar [Thu, 14 Oct 2021 10:31:52 +0000 (12:31 +0200)] 
clientlog: fix debug message for maximum number of records

3 years agosys_linux: fix seccomp filter for BINDTODEVICE option
Miroslav Lichvar [Wed, 6 Oct 2021 08:02:34 +0000 (10:02 +0200)] 
sys_linux: fix seccomp filter for BINDTODEVICE option

The BINDTODEVICE socket option is the first option in the seccomp filter
setting a string instead of int. Remove the length check from the
setsockopt rules to allow a device name longer than 3 characters.

This was reported in Debian bug #995207.

Fixes: b9f5ce83b02e ("sys_linux: allow BINDTODEVICE option in seccomp filter")
3 years agoexamples: improve chronyd service
Miroslav Lichvar [Mon, 4 Oct 2021 08:54:40 +0000 (10:54 +0200)] 
examples: improve chronyd service

Allow writing logfiles (enabled by logdir or -l option) to /var/log and
don't require /var/spool to exist.

3 years agoexamples: harden systemd services
Miroslav Lichvar [Wed, 29 Sep 2021 13:25:48 +0000 (15:25 +0200)] 
examples: harden systemd services

Add various settings to the example chronyd and chrony-wait services to
decrease the exposure reported by the "systemd-analyze security"
command. The original exposure was high as the analyzer does not check
the actual process (e.g. that it dropped the root privileges or that it
has its own seccomp filter).

Limit read-write access to /run, /var/lib/chrony, and /var/spool.
Access to /run (instead of /run/chrony) is needed for the refclock
socket expected by gpsd.

The mailonchange directive is most likely to break as it executes
/usr/sbin/sendmail, which can do unexpected operations depending on the
implementation. It should work with a setuid/setgid binary, but it is
not expected to write outside of /var/spool and the private /tmp.

3 years agontp: check software timestamps on Linux
Miroslav Lichvar [Thu, 23 Sep 2021 11:00:24 +0000 (13:00 +0200)] 
ntp: check software timestamps on Linux

Apparently some routers with hardware NAT acceleration have a bug
causing the kernel timestamps to be corrupted and break NTP. Similarly
to the sanity check applied to hardware timestamps, require the
kernel/driver timestamps to be within one second of the daemon timestamp
to be accepted.

3 years agontp: print stratum 1 refid in ASCII in debug message
Miroslav Lichvar [Thu, 23 Sep 2021 10:39:54 +0000 (12:39 +0200)] 
ntp: print stratum 1 refid in ASCII in debug message

3 years agodoc: show arguments of ratelimit options
Miroslav Lichvar [Thu, 23 Sep 2021 08:08:07 +0000 (10:08 +0200)] 
doc: show arguments of ratelimit options

3 years agouse round() for rounding
Miroslav Lichvar [Thu, 23 Sep 2021 08:01:50 +0000 (10:01 +0200)] 
use round() for rounding

Replace casting of values incremented by +0.5/-0.5 with round().

3 years agotest: fix incorrect use of RAND_MAX
Miroslav Lichvar [Thu, 23 Sep 2021 07:34:47 +0000 (09:34 +0200)] 
test: fix incorrect use of RAND_MAX

On some systems (e.g. Solaris/OpenIndiana) rand() and random() have
different ranges. RAND_MAX is the maximum value returned by rand(),
but random() should always have a range of 0 through 2^31-1.

This fixes multiple failures in different tests.

3 years agoclient: replace allow/deny parser
Miroslav Lichvar [Wed, 22 Sep 2021 15:06:38 +0000 (17:06 +0200)] 
client: replace allow/deny parser

Use the new cmdparse function for parsing the (cmd)allow/deny commands
and refactor the code a bit to reduce the number of functions needed for
all the (cmd)allow/deny(all) combinations.

3 years agoconf: rework allow/deny parser
Miroslav Lichvar [Wed, 22 Sep 2021 13:54:50 +0000 (15:54 +0200)] 
conf: rework allow/deny parser

Refactor the (cmd)allow/deny parser and make it more strict in what
input it accepts. Check the scanned numbers and require whole input to
be processed.

Move the parser to cmdparse to make it available to the client.

3 years agocmdmon: move comment to make its scope clearer
Miroslav Lichvar [Wed, 22 Sep 2021 08:34:51 +0000 (10:34 +0200)] 
cmdmon: move comment to make its scope clearer

3 years agotest: extend 110-chronyc test
Miroslav Lichvar [Wed, 22 Sep 2021 07:59:03 +0000 (09:59 +0200)] 
test: extend 110-chronyc test

3 years agotest: fix chronyc test with disabled IPv6 support
Miroslav Lichvar [Tue, 21 Sep 2021 13:42:07 +0000 (15:42 +0200)] 
test: fix chronyc test with disabled IPv6 support

3 years agotest: add 143-manual test
Miroslav Lichvar [Mon, 20 Sep 2021 15:40:09 +0000 (17:40 +0200)] 
test: add 143-manual test

3 years agotest: enable chronyc to use Unix domain socket
Miroslav Lichvar [Wed, 15 Sep 2021 14:57:09 +0000 (16:57 +0200)] 
test: enable chronyc to use Unix domain socket

3 years agotest: fix 002-scanbuild test
Miroslav Lichvar [Thu, 23 Sep 2021 12:48:25 +0000 (14:48 +0200)] 
test: fix 002-scanbuild test

3 years agotest: update compilation tests
Miroslav Lichvar [Wed, 1 Sep 2021 14:33:41 +0000 (16:33 +0200)] 
test: update compilation tests

3 years agocmac: add gnutls support
Miroslav Lichvar [Thu, 2 Sep 2021 07:56:48 +0000 (09:56 +0200)] 
cmac: add gnutls support

Similarly to hashing, add support for AES-CMAC in gnutls to avoid
linking directly with nettle.

3 years agohash: allow non-security MD5 use in FIPS mode
Miroslav Lichvar [Thu, 2 Sep 2021 09:44:15 +0000 (11:44 +0200)] 
hash: allow non-security MD5 use in FIPS mode

gnutls running in the FIPS140-2 mode does not allow MD5 to be
initialized, which breaks chronyd using MD5 to calculate reference ID
of IPv6 addresses. Specify a new hash algorithm for non-security MD5 use
and temporarily switch to the lax mode when initializing the hash
function.

3 years agohash: add gnutls support
Miroslav Lichvar [Wed, 1 Sep 2021 12:46:38 +0000 (14:46 +0200)] 
hash: add gnutls support

Add support for crypto hash functions in gnutls (internally using
nettle). This can be useful to avoid directly linking with nettle to
avoid ABI breaks.

3 years agoconfigure: fix SIV detection in gnutls
Miroslav Lichvar [Thu, 2 Sep 2021 08:36:03 +0000 (10:36 +0200)] 
configure: fix SIV detection in gnutls

gnutls_aead_cipher_init() is declared in gnutls/crypto.h. If the
compiler handles implicit declarations as errors, the SIV support was
not detected. Fix the check to use the correct header.

3 years agosiv: deinit gnutls on unsupported SIV
Miroslav Lichvar [Thu, 2 Sep 2021 07:56:58 +0000 (09:56 +0200)] 
siv: deinit gnutls on unsupported SIV

3 years agoprivops: allow binding to PTP port
Miroslav Lichvar [Thu, 2 Sep 2021 11:27:23 +0000 (13:27 +0200)] 
privops: allow binding to PTP port

Fixes: be3158c4e5b2 ("ntp: add support for NTP over PTP")
3 years agodoc: improve ptpport example
Miroslav Lichvar [Wed, 1 Sep 2021 12:44:48 +0000 (14:44 +0200)] 
doc: improve ptpport example

3 years agodoc: remove obsolete comment in maxslewrate description
Miroslav Lichvar [Wed, 18 Aug 2021 12:38:16 +0000 (14:38 +0200)] 
doc: remove obsolete comment in maxslewrate description

3 years agodoc: shorten lock_all description
Miroslav Lichvar [Wed, 18 Aug 2021 12:35:00 +0000 (14:35 +0200)] 
doc: shorten lock_all description

3 years agotest: add 142-ptpport test
Miroslav Lichvar [Wed, 18 Aug 2021 10:57:40 +0000 (12:57 +0200)] 
test: add 142-ptpport test

3 years agontp: add support for NTP over PTP
Miroslav Lichvar [Wed, 18 Aug 2021 10:42:07 +0000 (12:42 +0200)] 
ntp: add support for NTP over PTP

Allow NTP messages to be exchanged as a payload of PTP messages to
enable full hardware timestamping on NICs that can timestamp PTP packets
only. Implemented is the protocol described in this draft (version 00):

https://datatracker.ietf.org/doc/draft-mlichvar-ntp-over-ptp/

This is an experimental feature. It can be changed or removed in future.
The used PTP domain is 123 and the NTP TLV type is 0x2023 from the "do
not propagate" experimental range.

The ptpport directive enables NTP-over-PTP as a server and as a client
for all sources that have the port option set to the PTP port. The port
should be the PTP event port (319) to trigger timestamping in the
hardware.

The implementation is contained to ntp_io. It is transparent to
ntp_core.

3 years agontp: add PTP rxfilter
Miroslav Lichvar [Wed, 18 Aug 2021 08:44:48 +0000 (10:44 +0200)] 
ntp: add PTP rxfilter

Setting rxfilter to ptp enables timestamping of PTPv2 packets (UDP or
all transports). It will be needed for NTP-over-PTP support.

3 years agontp: provide remote port to NIO_OpenServerSocket()
Miroslav Lichvar [Mon, 16 Aug 2021 12:51:01 +0000 (14:51 +0200)] 
ntp: provide remote port to NIO_OpenServerSocket()

This will allow selection of different protocols based on the remote
port. Zero means the default (NTP).

3 years agodoc: fix chronyd platform support for -P and -m
Stefan R. Filipek [Sat, 7 Aug 2021 14:35:15 +0000 (10:35 -0400)] 
doc: fix chronyd platform support for -P and -m

A while back, support for memory locking and real-time scheduling was
added to more platforms. The chronyd documentation wasn't updated at
that time (chronyd.conf was). This patch fixes that.

3 years agosys_linux: allow clone3 and pread64 in seccomp filter
Miroslav Lichvar [Mon, 9 Aug 2021 09:48:21 +0000 (11:48 +0200)] 
sys_linux: allow clone3 and pread64 in seccomp filter

These seem to be needed with the latest glibc.

4 years agortc: avoid printing and scanning time_t
Miroslav Lichvar [Thu, 5 Aug 2021 12:07:17 +0000 (14:07 +0200)] 
rtc: avoid printing and scanning time_t

With the latest glibc it's now possible to define _TIME_BITS=64 to get
64-bit time_t on 32-bit Linux systems. This breaks the %ld printf/scanf
modifier used with the RTC drift timestamp. Process it as a double.

4 years agodoc: improve ntsserverkey/cert description
Miroslav Lichvar [Wed, 7 Jul 2021 14:45:46 +0000 (16:45 +0200)] 
doc: improve ntsserverkey/cert description

The files are read after dropping root privileges. They need to be
readable by the chrony user. The error message "Could not set
credentials : Error while reading file." does not make this requirement
very obvious.

4 years agodoc: update NEWS 4.1
Miroslav Lichvar [Thu, 6 May 2021 14:31:33 +0000 (16:31 +0200)] 
doc: update NEWS

4 years agoupdate copyright years
Miroslav Lichvar [Mon, 10 May 2021 13:47:10 +0000 (15:47 +0200)] 
update copyright years

4 years agotest: make 007-cmdmon test more reliable
Miroslav Lichvar [Wed, 12 May 2021 11:03:45 +0000 (13:03 +0200)] 
test: make 007-cmdmon test more reliable

Reorder the local off command with respect to offline and online to
prevent the client from getting an unsynchronized response.

4 years agotest: allow inaccurate math in util unit test
Miroslav Lichvar [Mon, 10 May 2021 16:08:33 +0000 (18:08 +0200)] 
test: allow inaccurate math in util unit test

Don't require timespec/timeval-double conversion tests to produce
correctly rounded results to handle x86 and other archs with wider
intermediate results.

4 years agotest: disable privdrop in nts test
Miroslav Lichvar [Mon, 10 May 2021 13:09:38 +0000 (15:09 +0200)] 
test: disable privdrop in nts test

They are unrelated features. Not setting privdrop avoids a skip due to
the nobody user not having access to the test directory.

4 years agosys_linux: check if execveat is defined
Miroslav Lichvar [Thu, 6 May 2021 13:41:52 +0000 (15:41 +0200)] 
sys_linux: check if execveat is defined

The syscall is missing on older systems.

4 years agosys_linux: add second scfilter level
Miroslav Lichvar [Wed, 5 May 2021 09:21:39 +0000 (11:21 +0200)] 
sys_linux: add second scfilter level

Add level "2" to enable a filter which blocks only specific system calls
like fork and exec* instead of blocking everything unknown. It should
be reliable with respect to changes in libraries, but it provides only a
very limited protection.

4 years agosys_linux: allow getuid32 in seccomp filter
Miroslav Lichvar [Thu, 29 Apr 2021 14:53:40 +0000 (16:53 +0200)] 
sys_linux: allow getuid32 in seccomp filter

This was triggered on x86 in an NTS test.

4 years agosourcestats: check samples loaded from dump files
Miroslav Lichvar [Tue, 4 May 2021 12:06:33 +0000 (14:06 +0200)] 
sourcestats: check samples loaded from dump files

When loading a dump file with the -r option, check also sanity of the
sample time, offset, peer/root delay/dispersion, and the sample order to
better handle corrupted files.

4 years agosource: don't print duplicated address in selection message
Miroslav Lichvar [Tue, 4 May 2021 09:49:54 +0000 (11:49 +0200)] 
source: don't print duplicated address in selection message

Don't print the original IP address in parentheses in the "Selected
source ..." message if it is identical to the current address. That is
expected to be the usual case for sources specified by IP address.

4 years agoconf: log error when source cannot be added
Miroslav Lichvar [Tue, 4 May 2021 09:08:59 +0000 (11:08 +0200)] 
conf: log error when source cannot be added

Log an error message when adding of a source fails, e.g. due to the new
limit on number of sources, or when the same address is specified
multiple times.

4 years agonts: close file after loading cookies
Miroslav Lichvar [Mon, 3 May 2021 12:15:28 +0000 (14:15 +0200)] 
nts: close file after loading cookies

Don't forget to close the file with cookies in ntsdumpdir if
successfully loaded.

Fixes: 2fa83b541c36 ("nts: save and load cookies on client")
4 years agonts: ignore long non-critical records
Miroslav Lichvar [Mon, 3 May 2021 10:48:23 +0000 (12:48 +0200)] 
nts: ignore long non-critical records

In the NTS-KE client don't reject the response if it has non-critical
records that are too long for the processing buffer. This is not
expected to happen with the current specification, but it might be
needed with future extensions.

Fixes: 7925ed39b81f ("nts: fix handling of long server negotiation record")
4 years agotest: fix date use in 010-nts system test
Miroslav Lichvar [Thu, 29 Apr 2021 12:45:30 +0000 (14:45 +0200)] 
test: fix date use in 010-nts system test

Avoid using nonportable -d option of date.

4 years agotest: remove logs before chronyd start in system tests
Miroslav Lichvar [Thu, 29 Apr 2021 11:15:03 +0000 (13:15 +0200)] 
test: remove logs before chronyd start in system tests

4 years agotest: extend configuration in system tests
Miroslav Lichvar [Thu, 29 Apr 2021 11:14:11 +0000 (13:14 +0200)] 
test: extend configuration in system tests

4 years agotest: rework seccomp testing
Miroslav Lichvar [Thu, 29 Apr 2021 11:18:39 +0000 (13:18 +0200)] 
test: rework seccomp testing

Instead of a single test with enabled seccomp, rerun all other
non-destructive and destructive tests for each seccomp level.

4 years agosys_linux: allow BINDTODEVICE option in seccomp filter
Miroslav Lichvar [Thu, 29 Apr 2021 10:35:49 +0000 (12:35 +0200)] 
sys_linux: allow BINDTODEVICE option in seccomp filter

Fixes: 4ef944b73436 ("socket: add support for binding sockets to device")
4 years agodoc: warn about -F and mailonchange in chronyd man page
Miroslav Lichvar [Thu, 29 Apr 2021 07:18:49 +0000 (09:18 +0200)] 
doc: warn about -F and mailonchange in chronyd man page

4 years agonts: avoid assumption about cookie record
Miroslav Lichvar [Tue, 27 Apr 2021 13:39:59 +0000 (15:39 +0200)] 
nts: avoid assumption about cookie record

The cookie record is currently assumed to be the longest record that
needs to be accepted by the client, but that does not have to be always
the case. Define the processing buffer using the maximum body record
constant instead and add an assertion to make sure it's not smaller than
the maximum accepted cookie length.

4 years agonts: fix handling of long server negotiation record
Miroslav Lichvar [Tue, 27 Apr 2021 09:18:04 +0000 (11:18 +0200)] 
nts: fix handling of long server negotiation record

Recent change in handling of the NTPv4 server negotiation record (commit
754097944be2) increased the length of the instance name buffer to make
room for the trailing dot. This allowed a record with body truncated in
the processing buffer to be accepted and caused an over-read of 1 byte
in the memcpy() call saving the name to the instance buffer.

Modify the client to accept only records that fit in the processing
buffer.

Fixes: 754097944be2 ("nts: handle negotiated server as FQDN")
4 years agodoc: update NEWS 4.1-pre1
Miroslav Lichvar [Tue, 20 Apr 2021 12:16:11 +0000 (14:16 +0200)] 
doc: update NEWS

4 years agodoc: update README
Miroslav Lichvar [Tue, 20 Apr 2021 10:37:40 +0000 (12:37 +0200)] 
doc: update README

4 years agontp: fix address in error message
Miroslav Lichvar [Wed, 21 Apr 2021 13:56:51 +0000 (15:56 +0200)] 
ntp: fix address in error message

4 years agonameserv: avoid sockaddr_in6 with disabled IPv6 support
Miroslav Lichvar [Wed, 21 Apr 2021 12:40:12 +0000 (14:40 +0200)] 
nameserv: avoid sockaddr_in6 with disabled IPv6 support

Fixes: 10c760a80c15 ("nameserv: require getaddrinfo() and getnameinfo()")
4 years agotest: extend 129-reload test
Miroslav Lichvar [Wed, 21 Apr 2021 10:50:47 +0000 (12:50 +0200)] 
test: extend 129-reload test

4 years agosources: fix loading of refclock dump files
Miroslav Lichvar [Wed, 21 Apr 2021 10:52:17 +0000 (12:52 +0200)] 
sources: fix loading of refclock dump files

Allow zero stratum in loaded dump files.

Fixes: f8610d69f08f ("sources: improve handling of dump files and their format")
4 years agosources: don't print NULL string to dump file
Miroslav Lichvar [Wed, 21 Apr 2021 10:51:07 +0000 (12:51 +0200)] 
sources: don't print NULL string to dump file

For reference clocks, which don't have a name, print "." instead of
NULL.

Fixes: f8610d69f08f ("sources: improve handling of dump files and their format")
4 years agonts: handle negotiated server as FQDN
Miroslav Lichvar [Wed, 21 Apr 2021 07:37:40 +0000 (09:37 +0200)] 
nts: handle negotiated server as FQDN

The NTS RFC requires the recipient of the Server Negotiation NTS-KE
record to handle the name as a fully qualified domain name. Add a
trailing dot if not present to force the name to be resolved as one.

4 years agotest: extend 106-refclock test
Miroslav Lichvar [Tue, 20 Apr 2021 15:43:20 +0000 (17:43 +0200)] 
test: extend 106-refclock test

4 years agodoc: improve description of allow directive
Miroslav Lichvar [Tue, 20 Apr 2021 07:54:52 +0000 (09:54 +0200)] 
doc: improve description of allow directive

Prefer CIDR notation, clarify use of hostnames and order of allow/deny
directives, refer to the accheck command.

4 years agosys_timex: remove workaround for broken ntp_adjtime on macOS
Bryan Christianson [Mon, 19 Apr 2021 21:32:52 +0000 (09:32 +1200)] 
sys_timex: remove workaround for broken ntp_adjtime on macOS

Early beta releases of macOS Big Sur had a signed/unsigned error in
Apple's implementation of ntp_adjtime. Apple have since fixed this error
and the workaround is no longer required.

4 years agodoc: improve FAQ
Miroslav Lichvar [Tue, 13 Apr 2021 10:07:38 +0000 (12:07 +0200)] 
doc: improve FAQ

4 years agoconf: require sourcedir files to be terminated by newline
Miroslav Lichvar [Thu, 15 Apr 2021 07:43:01 +0000 (09:43 +0200)] 
conf: require sourcedir files to be terminated by newline

When reading a *.sources file require that each line is termined by the
newline character to avoid processing an unfinished line, e.g. due to an
unexpected call of the reload command when the file is being written in
place.

4 years agotest: make system tests more reliable
Miroslav Lichvar [Thu, 15 Apr 2021 09:26:29 +0000 (11:26 +0200)] 
test: make system tests more reliable

4 years agotest: update and extend 110-chronyc test
Miroslav Lichvar [Tue, 13 Apr 2021 14:34:34 +0000 (16:34 +0200)] 
test: update and extend 110-chronyc test