Commit Graph

15195 Commits (suricata-7.0.4)
 

Author SHA1 Message Date
Shivani Bhardwaj d8bad3b1aa release: 7.0.4; update changelog 1 year ago
Philippe Antoine c0b9ddb32e ssh: limit length for banner logs
Ticket: 6770
(cherry picked from commit c4b8fb7aca)
1 year ago
Philippe Antoine f9ef96af30 ssh: avoid quadratic complexity from long banner
Ticket: 6799

When we find an overlong banner, we get into the state just
waiting for end of line, and we just want to skip the bytes
until then.
Returning AppLayerResult::incomplete made TCP engine retain
the bytes and grow the buffer that we parsed again and again...

(cherry picked from commit 271ed2008b)
1 year ago
Philippe Antoine d4acd0fb44 ci: update ubuntu22.04 builds with clang14+asan
using a workround about ASLR

(cherry picked from commit 632e52ca2b)
1 year ago
Philippe Antoine 8b78f5e6dc detect: flush when setting no_inspection
Ticket: 6578

When a protocol such as SSH sets no_inspection, we still have to
flush the current streams and packets that contain clear-text
for detection.

(cherry picked from commit cc3b4b01ec)
1 year ago
Philippe Antoine 14d4221095 detect: update packet action on protocol change
Ticket: #6305

When running FlowWorkerStreamTCPUpdate, one of the dequeued packet
may set the flow action to drop, without updating the not-pseudo
packet action, as is done usually with a previous call to
FlowHandlePacketUpdate

(cherry picked from commit 4c4f7ff1a2)
1 year ago
Victor Julien c8c72030bf yaml: remove newline from error message
(cherry picked from commit f53c4ab149)
1 year ago
Jonathan Perkins 05640d84dc napatech: emit HBA deprecation only once
Issue: 6313
This commit removes duplicate HBA deprecation messages from being
emitted.
1 year ago
Philippe Antoine 8e8efd2c01 decode/pppoe: skip useless loop unless debug
Looping over tags has no effects, except debug logging

(cherry picked from commit 59d18b9a68)
1 year ago
Philippe Antoine 14d969176d decode/pppoe: pointer cast consistency
Ticket: 6787

To do pointer arithmetic, we need to use uint8_t* pointer :
Pointer arithmetic in C is automatically scaled according
to the size of the data type.

Also simplifies the loop condition

(cherry picked from commit d2db8bfdca)
1 year ago
Lukas Sismis 9437c6cfcb dpdk: output unknown NIC's NUMA node message only on multi-node systems
Ticket: #6715
(cherry picked from commit 566e89a0d6)
1 year ago
Jeff Lucovsky dc8e177027 netmap: Avoid HW errors when using pipes
Issue: 6837

When using netmap pipes (with lb, for example), avoid direct hardware
related IOCTLs that will fail (not supported with pipes).

(cherry picked from commit af529a56a9)
1 year ago
Jason Ish 12ffd23170 plugins: initialize plugins earlier
Capture plugins need to be registered before LiveDeviceFinalize,
otherwise Suricata errors before the plugin gets a chance to load.

Bug: #6811
(cherry picked from commit 25d0e0b68c)
1 year ago
Jason Ish 1291272422 thread modules: separate initialization from registration
Move the zero'ing to the thread module array InitGlobal in an effort
to fix capture modules.

At some point device validation moved to a point in startup before
plugins are loaded meaning that capture plugins could not be
used. Moving plugin registration early enough caused some of their
registration to be wiped out as clearing the array was done after.

Bug: #6811
(cherry picked from commit 96e61b043c)
1 year ago
Lukas Sismis 38fec367fd dpdk: add a user warning on the change of RX/TX descriptors
Ticket: #6739
(cherry picked from commit 9185ca8f38)
1 year ago
Philippe Antoine e51b276660 output/filestore: delay snprintf until needed
Perf optimization so that we do not call snprintf in the
common code path.

Ticket: 6796
(cherry picked from commit d255a5c7a3)
1 year ago
Philippe Antoine 21ed3e3dac output/filestore: remove duplicate snprintf
Ticket: 6796
(cherry picked from commit 7641c07af9)
1 year ago
Philippe Antoine 2c81fe138b output: log tx only when there is a fresh app update
Ticket: 6796

Similar to commit for detection
9240ae250c

We only have more logging to do if the app update was fresh,
ie if p->app_update_direction != 0

If we have data acknowledged in one direction,
and then many packets in the other direction,
the APP_UPDATED flow flags did not get reset because we did not
run detection yet in this direction,
but there is nothing more to do after the first packet in the
other direction.

(cherry picked from commit c41540f839)
1 year ago
Juliana Fajardini 2efde5b87f userguide: fix explanation about bsize ranges
Our code handles Uint ranges as exclusive, but for bsize, our
documentation stated that they're inclusive.

Cf. from uint.rs:

    DetectUintMode::DetectUintModeRange => {
        if val > x.arg1 && val < x.arg2 {
            return true;
        }
    }

Task #6708

(cherry picked from commit 244a35d539)
1 year ago
Lukas Sismis 1814e81036 doc: mention the limited number of RX/TX descriptors on Intel NICs
Ticket: 6748
(cherry picked from commit 356f9ffa13)
1 year ago
Lukas Sismis 9aae9aaa16 dpdk: max cache size should be lower than one of the constraints
Ticket: 6741
(cherry picked from commit c65ff35819)
1 year ago
Lukas Sismis 98f965e47f dpdk: sanitize integer overflow in the configuration
Ticket: #6737
(cherry picked from commit cc2eb2d8b7)
1 year ago
Lukas Sismis 36e23a71f2 hugepages: run hugepage check only on DPDK runmode and on Linux
Previous implementation allowed FreeBSD to enter into the hugepage
analysis. It then failed with an error message because hugepage/
NUMA node paths that are used in the codebase to retrieve info about
the system are not the same with the structure in Linux.

Additionally, the messages were logged on error level. It has been
demoted to info level because the whole hugepage analysis checkup is
only for informational purposes and does not affect Suricata operation.

The hugepage analysis and the hugepage snapshots are now limited to
only run in the DPDK runmode.

Ticket: #6760
Ticket: #6762
(cherry picked from commit 4b0704db55)
1 year ago
Lukas Sismis 5f6a424ebd errors: add SC_ENOENT error
(cherry picked from commit f88bd2dd3f)
1 year ago
Jason Ish b6c609edbc pfring: fix leak of configuration data and in single mode
Fix leak of configuration data on exit. Also, in single mode set
thread count to one instead of the CPU count.

Bug: #4734
(cherry picked from commit 5f0853599b)
1 year ago
Jason Ish 3c83397cf0 pfring: fix leak of packet on exit
Bug: #4734
(cherry picked from commit 358f1e35ee)
1 year ago
Jeff Lucovsky e34e9c9669 cppcheck: Address cpcheck report of an FP
Issue: 6527

Address the FP raised by cppcheck -- note that although the code
corectly checks to ensure that `to_shift != &sb->reqion`, the logic was
detected as a FP. Rework the code to eliminate the FP.

(cherry picked from commit 40e3514e7a)
1 year ago
Victor Julien 56915b2cc1 detect/address: avoid cppcheck false positive
src/detect-engine-address.c:1386:5: error: Memory leak: map.string [memleak]
    return true;
    ^

Seems cppcheck looses track of the pointer after the unnecessary cast to
void.

Bug: #6527.
(cherry picked from commit 78703bbc86)
1 year ago
Jeff Lucovsky 0a93bf5834 cppcheck/detect: Address cppcheck memory leak
Issue: 6527

Ensure that the `map->string` memory isn't leaked following an error
return from `HashListTableAdd`

(cherry picked from commit 8b2fd434fc)
1 year ago
Victor Julien b225ac1b9b detect: fix memory leak in error handling
Pointed out by cppcheck:

src/detect-parse.c:1544:9: error: Memory leak: sig.init_data [memleak]
        SCFree(sig);
        ^

Bug: #6527.
(cherry picked from commit eb1d0c2cc2)
1 year ago
Victor Julien 554afa9958 runmode/unix-socket: fix cppcheck warnings
src/runmode-unix-socket.c:547:9: warning: %d in format string (no. 1) requires 'int' but the argument type is 'unsigned int'. [invalidPrintfArgType_sint]
        snprintf(tstr, sizeof(tstr), "%d", cfile->tenant_id);
        ^
src/runmode-unix-socket.c:1040:5: warning: %d in format string (no. 1) requires 'int' but the argument type is 'unsigned int'. [invalidPrintfArgType_sint]
    snprintf(prefix, sizeof(prefix), "multi-detect.%d", tenant_id);
    ^
src/runmode-unix-socket.c:1189:5: warning: %d in format string (no. 1) requires 'int' but the argument type is 'unsigned int'. [invalidPrintfArgType_sint]
    snprintf(prefix, sizeof(prefix), "multi-detect.%d", tenant_id);
    ^

(cherry picked from commit 872f007a14)
1 year ago
Victor Julien ae6a663640 detect/mpm: don't test for impossible condition
Functions can't get called with NULL signature or NULL
Signature::init_data.

(cherry picked from commit 124a8dea20)
1 year ago
Jeff Lucovsky e5b006beb9 mqtt: Improve frame parsing w/mult. PDUs
This commit improves the mqtt parsing of frames to handle multiple PDUs.

Issue: 6592
(cherry picked from commit f9a20dafc6)
1 year ago
Lukas Sismis 1b474cd45c tcp: do not assign TCP flags to pseudopackets
Previously pseudopackets were assigned with ACK flag which falsely turned
"SYN" flows to "SYN/ACK" flows when Suricata ran with raw content-matching
rules. The problem occured during the flow timeout or Suricata shutdown,
essentially, when the flow was being kicked out (with a pseudopacket).

When Suricata ran without raw content-matching rules (the ruleset did not
contain content matching keywords or it only contained keywords that are
app-layer content-matching) then raw stream reassembly tracking is turned off
(SignatureHasStreamContent()).
This in turn disabled a check in StreamNeedsReassembly() and the right edge
was not checked with the raw stream progress. In turn, it did not generate
a pseudopacket that would go through the detection engine. Suricata with
raw content-matching keywords would therefore on a flow with SYN packet only
return STREAM_HAS_UNPROCESSED_SEGMENTS_NEED_ONLY_DETECTION which would generate
the pseudopacket.

In Suricata versions <= 6.0.x, the flow output was correct because
only the commit 1bb6f44ff0 started to
differentiate the right edge calculation between the raw and application
layer streams. The older Suricata versions used only the application layer
right edge equation and therefore did not generate a pseudopacket.

Ticket: #6734
(cherry picked from commit ebf465a11b)
1 year ago
Victor Julien d93b21c524 multi-tenant: fix loader dead lock
A dead lock could occur at start up, where a loader thread would
get stuck on it's condition variable, while the main thread was
polling the loaders task results.

The vector to the dead lock is as follows:

main	                        loader
DetectEngineMultiTenantSetup
-DetectLoaderSetupLoadTenant
--DetectLoaderQueueTask
---lock loader
---add task
---unlock loader
	                        lock loader
	                        check/exec tasks
	                        unlock loader
---wake up threads
	                        lock ctrl mutx
	                        cond wait ctrl
	                        unlock ctrl
-DetectLoadersSync
--lock loader
--check tasks
--unlock loader

Between the main thread unlocking the loader and waking up the
threads, it is possible that the loader has already moved ahead
but not yet entered its conditional wait. The main thread sends
its condition signal, but since the loader isn't yet waiting on
it the signal is ignored. Then when the loader does enter its
conditional wait, the signal is not sent again.

This patch updates the logic to send signals much more often.
It also makes sure that the signal is sent under lock, as the
API requires.

Bug: #6768.

Co-authored-by: Shivani Bhardwaj <shivani@oisf.net>
1 year ago
Arne Welzel 15bb1d4841 stats: Add unittest for basic stats serialization
Main purpose is to validate that the 30 of bond0.30 isn't expanded into
a nested object during serialization.

(cherry picked from commit 08db0f302b)
1 year ago
Arne Welzel f8ec39208d stats: Do not expand dots of tm_name
When an interface with dots is used, per worker stats are nested by the
dot-separated-components of the interface due to the usage of
OutputStats2Json().

Prevent this by using OutputStats2Json() on a per-thread specific object
and setting this object into the threads object using the
json_object_set_new() which won't do the dot expansion.

This was tested by creating an interface with dots in the name
and checking the stats.

    ip link add name a.b.c type dummy

With Suricata 7.0.2, sniffing on the a.b.c interface results in the
following worker stats format:

    "threads": {
      "W#01-a": {
        "b": {
          "c": {
            "capture": {
              "kernel_packets": 0,

After this fix, the output looks as follows:

    "threads": {
      "W#01-a.b.c": {
        "capture": {
          "kernel_packets": 0,

Ticket: #6732
(cherry picked from commit b8b8aa69b4)
1 year ago
Simon Dugas a3eb58e21e detect-engine-iponly: improve ip list performance
The runtime complexity of insertion sort is approx. O(h*n)^2 where
h is the size of the HOME_NET and n is the number of ip only rules
that use the HOME_NET.

Replacing this with qsort significantly improves rule load time when
a large HOME_NET is used in combination with a moderate amount of ip
only rules.

(cherry picked from commit 17f9d7aecc)
1 year ago
Victor Julien 0cd1cd1c98 detect/tls.certs: fix direction handling
Direction flag was checked against wrong field, leading to undefined behavior.

Bug: #6778.
(cherry picked from commit 3c06457b74)
1 year ago
Jeff Lucovsky cf31c431f2 threads/mutex: Ensure mutex held before signaling
Ensure that the mutex protecting the condition variable is held before
signaling it. This ensures that the thread(s) awaiting the signal are
notified.

Issue: 6569
(cherry picked from commit 2a1a70b308)
1 year ago
Jeff Lucovsky 912b1bdca6 netmap: Release lock to avoid deadlock
Issue: 6755

When NetmapOpen encounters an error opening the netmap device, it'll
retry a bit. When the retry limit is reached, it'll shutdown Suricata.

This commit ensures that the device list lock is not held when before
closing all open devices before terminating Suricata.

(cherry picked from commit 364adeeb04)
1 year ago
Alexey Simakov e41018a80e util/mime: fix memory leak
Fix memory leak at util-decode-mime:MimeDecInitParser, which
root cause is not-freeing allocated memory for mimeMsg

Bug: #6745
(cherry picked from commit 231c892bef)
1 year ago
Philippe Antoine 5b93de0ec2 detect: respect directionality for filestore
Ticket: 6617

So that rules with keyword like `filestore:to_server,flow`
only store the files to server and not the ones to client...

Directionality only worked with the default scope, ie the
current file, and not the scope tx or scope flow.
For non-default scope, tx or flow, both directions were stored
whatever the directionality specified.

For these non-default scopes, this commit keeps a default
of both directions, but use only one direction if specified.

Need to split flag FLOWFILE_STORE per direction, so that Suricata
can retain this (optional) directional info from the filestore
keyword.

Fixes: 79499e4769 ("app-layer: move files into transactions")
(cherry picked from commit 63caa0b40a)
1 year ago
Philippe Antoine e917baafe7 app-layer/template: use a max number of txs
Ticket: 6773
(cherry picked from commit c99d93c257)
1 year ago
Philippe Antoine 07e0f0da24 detect: errors on 65k filestore signatures
Errors when a detection engine gets 65k filestore signatures to
avoid the hard limit to have 65k filestore per signature group
head

Ticket: #6393
(cherry picked from commit db99c45d23)
1 year ago
Victor Julien ae6d040ec3 detect/http: report error on alloc failure
(cherry picked from commit 7e4dba7dfb)
1 year ago
Philippe Antoine 6d69ed9534 detect/http_header: fix leak on realloc failure
(cherry picked from commit b48ec8a039)
1 year ago
Jason Ish a846ff76d4 detect-http: add superfluous alloc check for cocci
Add not-needed SCCalloc return check to satisfy our Cocci malloc
checks as it can't see that the caller immediately checks the return
value of this simple wrapper around SCCalloc.

(cherry picked from commit f800ed0f90)
1 year ago
Philippe Antoine 8df02ba0e4 rust: fix clippy ptr_arg warnings
error: writing `&Vec` instead of `&[_]` involves a new object where a slice will do
   --> src/dns/log.rs:371:29
    |
371 | pub fn dns_print_addr(addr: &Vec<u8>) -> std::string::String {
    |                             ^^^^^^^^ help: change this to: `&[u8]`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#ptr_arg

(cherry picked from commit 68b0052018)
1 year ago
Philippe Antoine a0254bfa03 ci: authors check using OISF repo
As flagged critical by codescan

(cherry picked from commit 7f5e98e6df)
1 year ago