Commit graph

16273 commits

Author SHA1 Message Date
Arne Welzel
92565d4739 Supervisor: Handle EAGAIN error on stem pipe
util::safe_write() calls abort() in case of EAGAIN errors. This is
easily observed when starting clusters with 32 workers or more.

Add a custom write_message() function handling EAGAIN by retrying
after a small sleep. It's not clear a more complicated poll() would be
much better: The pipe might be ready for writing, but then our message
might not actually fit in, resulting in another EAGAIN error. And even
poll() would introduce blocking/sleeping code.

Take some precautions against the stem and the supervisor dead-locking
when both pipes are full by draining the other end on EAGAIN errors.

Closes #3043
2023-10-25 12:53:37 +02:00
Arne Welzel
9530f73ec4 fuzzer-setup: Allow customization without recompiling
This change allows to invoke a reproducer with different script options
and extra scripts to ease debugging and investigation. For example, enabling
the DPD debug stream and adding misc/dump-events can be done as follows after
this change:

    ZEEK_DEBUG_LOG_STDERR=1 ../../build/src/fuzzers/zeek-pop3-fuzzer <test-case> -- -B dpd misc/dump-events
2023-10-25 12:28:44 +02:00
Arne Welzel
560f8a4a84 ssl: Prevent unbounded ssl_history growth
The ssl_history field may grow unbounded (e.g., ssl_alert event). Prevent this
by capping using a configurable limit (default 100) and raise a weird once reached.
2023-10-25 09:35:45 +02:00
Arne Welzel
c960d279a2 ssl: Cap number of alerts parsed from SSL record
Limit the number of events raised from an SSL record with content_type
alert (21) to a configurable maximum number (default 10). For TLS 1.3,
the limit is set to 1 as specified in the RFC. Add a new weird cases
where the limit is exceeded.

OSS-Fuzz managed to generate a reproducer that raised ~660k ssl_plaintext
and ssl_alert events given ~810kb of input data. This change prevents this
with hopefully no negative side-effect in the real-world.
2023-10-25 09:35:10 +02:00
Arne Welzel
8f9d4a296b subdir-btest: Allow setting build_dir
We have that functionality in btest.cfg and it's actually nice to use
it for toggling between a debug/asan and release build.
2023-10-25 09:17:11 +02:00
Arne Welzel
ddcf75e934 Merge remote-tracking branch 'origin/topic/timw/verbose-cluster-testing-btests'
* origin/topic/timw/verbose-cluster-testing-btests:
  CI: Pass -A flag to btest for cluster-testing builds
2023-10-25 09:15:31 +02:00
zeek-bot
21814e144f Update doc submodule [nomail] [skip ci] 2023-10-25 01:30:08 +00:00
Tim Wojtulewicz
ac7685c679 CI: Pass -A flag to btest for cluster-testing builds 2023-10-24 15:42:21 -07:00
Tim Wojtulewicz
e0182e17bf Merge remote-tracking branch 'origin/topic/neverlord/cmake-submodule-update'
* origin/topic/neverlord/cmake-submodule-update:
  Update CMake submodule for caching fix
2023-10-24 13:06:04 -07:00
Arne Welzel
a0ad0f6871 Update doc submodule [nomail] [skip ci] 2023-10-24 20:32:03 +02:00
Arne Welzel
22fb445a7f Merge remote-tracking branch 'origin/topic/awelzel/3190-supervisor-eventmgr-shared-pipe-fix'
* origin/topic/awelzel/3190-supervisor-eventmgr-shared-pipe-fix:
  event: Reinitialize EventMgr's flare after fork() from stem
2023-10-24 19:35:35 +02:00
Arne Welzel
a9b65cc6d9 Update baselines 2023-10-24 19:10:11 +02:00
Arne Welzel
ce4cbac1ef ftp: Do not base seq on number of pending commands
Previously, seq was computed as the result of |pending_commands|+1. This
opened the possibility to override queued commands, as well as logging
the same pending ftp reply multiple times.

For example, when commands 1, 2, 3 are pending, command 1 may be dequeued,
but the incoming command then receives seq 3 and overrides the already
pending command 3. The second scenario happens when ftp_reply() selected
command 3 as pending for logging, but is then followed by many ftp_request()
events. This resulted in command 3's response being logged for every
following ftp_request() over and over again.

Avoid both scenarios by tracking the command sequence as an absolute counter.
2023-10-24 19:10:07 +02:00
Arne Welzel
631b30f5bb btest/Files/mmdb: golang-ci suggested fixes
Thanks Benjamin for the hint.
2023-10-24 15:08:58 +02:00
Arne Welzel
44b67894ac Merge remote-tracking branch 'origin/topic/awelzel/mmdb-fix-and-tests'
* origin/topic/awelzel/mmdb-fix-and-tests:
  base/frameworks/spicy: Do not load base/misc/version
  btest/core/mmdb: Basic lookup_autonomous_system / lookup_location tests
  btest/files: Add mmdb testing databases and generator code
  zeek.bif: Switch mmdb stale check to network_time
  Fix mmdb pointer destruction
2023-10-24 14:13:37 +02:00
Arne Welzel
54a08a74da base/frameworks/spicy: Do not load base/misc/version
Unsure what it's used for today and also results in the situation that on
some platforms we generate a reporter.log in bare mode, while on others
where spicy is disabled, we do not.

If we want base/frameworks/version loaded by default, should put it into
init-bare.zeek and possibly remove the loading of the reporter framework
from it - Reporter::error() would still work and be visible on stderr,
just not create a reporter.log.
2023-10-24 13:15:21 +02:00
Arne Welzel
baf30288ca btest/core/mmdb: Basic lookup_autonomous_system / lookup_location tests 2023-10-24 13:15:18 +02:00
Arne Welzel
05922132b3 btest/files: Add mmdb testing databases and generator code 2023-10-24 11:11:02 +02:00
Arne Welzel
688d68cbf6 zeek.bif: Switch mmdb stale check to network_time
Makes testing easier and aligns better with log rotation and timer
expiration. Should not have an effect in practice. Also, log detail
about whether inode or modification time changed, too.
2023-10-24 11:11:00 +02:00
Benjamin Bannier
254d7ebfa2 Merge remote-tracking branch 'origin/topic/bbannier/bump-spicy' 2023-10-24 10:10:54 +02:00
zeek-bot
c0e982f5d9 Update doc submodule [nomail] [skip ci] 2023-10-24 00:25:50 +00:00
peter.cullen
c391bdba5d Fix mmdb pointer destruction
The mmdb references needs to use reset() instead of release()
so that the destructor gets called and the stale DB is actually
cleaned up. Otherwise, the pointer is leaked and the stale DB
remains in memory.
2023-10-23 23:29:19 +02:00
Dominik Charousset
6451a4e750 Update CMake submodule for caching fix 2023-10-23 18:04:48 +02:00
Benjamin Bannier
603308f324 Bump auxil/spicy to latest development snapshot 2023-10-23 17:05:30 +02:00
Arne Welzel
ab157777e3 X509Common/SCT parsing: Fix memory leak in error case
Failed to free the copy of the OCSP extension's value the inner
octet string couldn't be parsed.
2023-10-23 16:57:15 +02:00
Benjamin Bannier
d3eaf587e7 Merge remote-tracking branch 'origin/topic/robin/gh-3370' 2023-10-23 11:30:12 +02:00
zeek-bot
1aa9de2811 Update doc submodule [nomail] [skip ci] 2023-10-21 00:23:06 +00:00
Arne Welzel
ebb8780d6a quic: Skip new test if have-quic is false 2023-10-20 20:57:19 +02:00
Tim Wojtulewicz
bf75f56ef7 Merge remote-tracking branch 'origin/topic/awelzel/quic-longer-but-configurable-history-max-length'
* origin/topic/awelzel/quic-longer-but-configurable-history-max-length:
  quic: Bump maximum history length, make configurable
2023-10-20 11:45:04 -07:00
Arne Welzel
6604010a05 quic: Bump maximum history length, make configurable
From zeek/spicy-quic#15
2023-10-20 20:42:30 +02:00
Arne Welzel
d8a0822221 event: Reinitialize EventMgr's flare after fork() from stem
Because EventMgr is defined globally as an object (rather than a global
pointer to an EventMgr object), its pipe is created even before main()
is entered. This further means that in the fork-based supervisor setup,
all Zeek processes created from the top-level supervisor process share
the same pipe object for the EventMgr. In turn, whenever any of the
processes enqueued an event, the flare was fired and ready for reading
on all other processes in the cluster, causing much contention and
unneeded overhead.

Closes #3190
2023-10-20 17:52:48 +02:00
zeek-bot
16a51218a5 Update doc submodule [nomail] [skip ci] 2023-10-20 00:24:08 +00:00
Arne Welzel
e632131e9e Merge remote-tracking branch 'origin/topic/awelzel/add-ssl-fuzzer'
* origin/topic/awelzel/add-ssl-fuzzer:
  fuzzers: Add SSL fuzzer
2023-10-19 20:00:04 +02:00
Arne Welzel
043f3216f7 fuzzers: Add SSL fuzzer
Corpus was generated from a few btest pcaps, fuzzing for 60 seconds
locally and minimizing afterwards as in the documentation.

List of pcaps:

    certificate-request-failed.pcap
    certificate-with-sct.pcap
    cert-no-cn.pcap
    chrome-34-google.trace
    chrome-63.0.3211.0-canary-tls_experiment.pcap
    heartbleed-encrypted.pcap
    heartbleed-encrypted-short.pcap
    heartbleed-encrypted-success.pcap
    heartbleed.pcap
    heartbleed-success.pcap
    ssl-v2.trace
    ssl.v3.trace
    tls1_1.pcap
    tls-1.2-handshake-failure.trace
    tls1.2-protocol-violation.pcap
    tls1.2.trace
    tls13_wolfssl.pcap
    tls-early-alert.trace
2023-10-19 18:20:49 +02:00
Arne Welzel
ee827a0a63 Merge remote-tracking branch 'origin/topic/robin/gh-3383'
* origin/topic/robin/gh-3383:
  Fix missing version number in `spicyz`.
2023-10-19 16:26:05 +02:00
Robin Sommer
ab78cfa5a2
Spicy: Avoid creating Zeek types multiple times.
We now cache the first time we create a (named) Zeek type so that we
can reuse it later when needed again.

Closes #3370.
2023-10-19 11:29:55 +02:00
Robin Sommer
8d10bf7178
Spicy: Unroll Zeek type registrations.
For records and enums, the type registration calls could get pretty
large, and then slow to compile. We now build up their vectors
entry by entry instead of all at once.
2023-10-19 11:29:50 +02:00
Robin Sommer
77f17ab4e5
Fix missing version number in spicyz.
Needs associated `cmake` PR.

Closes #3383.
2023-10-19 11:27:25 +02:00
Arne Welzel
a503c2a672 Merge remote-tracking branch 'origin/topic/awelzel/quic-ldap-event-prototypes'
* origin/topic/awelzel/quic-ldap-event-prototypes:
  ldap: Use longer event names
  ldap: Add spicy-events.zeek
  quic: Add spicy-events.zeek
2023-10-19 11:08:36 +02:00
Arne Welzel
e1864ec131 ldap: Use longer event names
It's unusual to compress and shorten event names of protocol analyzers,
switch to a slightly longer name instead.
2023-10-19 10:49:19 +02:00
Arne Welzel
fb31ad0c6e ldap: Add spicy-events.zeek 2023-10-19 10:48:34 +02:00
Arne Welzel
2389f6f6c5 quic: Add spicy-events.zeek 2023-10-19 10:48:24 +02:00
Tim Wojtulewicz
fc62bb477c Merge remote-tracking branch 'origin/topic/timw/3382-update-ssh-key-exchanges'
* origin/topic/timw/3382-update-ssh-key-exchanges:
  Add new SSH key exchange algorithms reported by OpenSSH 9.0
2023-10-18 12:05:37 -07:00
Tim Wojtulewicz
a0a1328e02 Add new SSH key exchange algorithms reported by OpenSSH 9.0 2023-10-18 12:05:00 -07:00
Arne Welzel
bccf1a9253 IEEE802_11: Fix buffer-overflow due to not accounting for the amsdu header
The fuzzer generated input where data length left was 14 and the amsdu_len
field set to 14. That caused buffer overread due not taking into account
the amsdu header length of 14.
2023-10-18 10:53:06 +02:00
Arne Welzel
a5b94f04fd Merge remote-tracking branch 'origin/topic/awelzel/better-gre-over-udp-pcap'
* origin/topic/awelzel/better-gre-over-udp-pcap:
  gre-over-udp: Update testing pcap with both endpoints
2023-10-17 19:34:01 +02:00
Arne Welzel
a17923da50 Merge branch 'ldap-asn1-fixes' of https://github.com/pauldokas/zeek
* 'ldap-asn1-fixes' of https://github.com/pauldokas/zeek:
  performance improvements for the LDAP ASN.1 analyzer
2023-10-17 17:20:53 +02:00
Arne Welzel
536686f02d gre-over-udp: Update testing pcap with both endpoints
The first pcap only contained packets from the originator, not the responder.

What stands out here is that the Linux kernel doesn't seem to use a symmetric
flow hash for the tunneled connection, resulting in a total of four tunnel
connections for the two inner connections. Sigh.
2023-10-17 12:30:14 +02:00
zeek-bot
ae0f8677b3 Update doc submodule [nomail] [skip ci] 2023-10-17 00:20:37 +00:00
Tim Wojtulewicz
d4993ebf7f Merge remote-tracking branch 'origin/topic/timw/3344-gre-over-udp'
* origin/topic/timw/3344-gre-over-udp:
  Add registration for GRE-over-UDP
2023-10-16 11:52:18 -07:00