Commit Graph

17613 Commits (20a0575d96e936ed5d297e78d17d5c92a8faecc0)
 

Author SHA1 Message Date
Victor Julien c3f054b625 time: replace usleep by SleepUsec/SleepMsec
Helps cross platform support, esp Windows
3 months ago
Victor Julien 35e711d00a threads: clean up module flags
Remove unused TM_FLAG_STREAM_TM.

Rename TM_FLAG_DETECT_TM to TM_FLAG_FLOWWORKER_TM as it was mostly used
to check if a thread is a flow worker. TM_FLAG_DETECT_TM was always set
for a flow worker, even when there was no detection in use.
3 months ago
Victor Julien bdac028fc7 threading: fix shutdown of IPS autofp modes
For IPS modes with a verdict thread in autofp there was an issue with
the verdict thread not shutting down, leading to a long shutdown time
until an error condition was reached.

The problem was that when the packet threads, of which the verdict
thread is one, were told to enter their flow timeout loop the verdict
thread got stuck as it immediately progressed to THV_RUNNING_DONE
instead of the expected THV_FLOW_LOOP.

This patch updates the shutdown logic to only apply the flow timeout
logic to the relevant threads, and skip the verdict thread(s).

Add TM_FLAG_VERDICT_TM to indicate a thread has a verdict module to more
explicitly shut it down.

Fixes: 12f8f03532 ("threads: fix autofp shutdown race condition")

Bug: #7681.
3 months ago
Philippe Antoine 6dbc421825 rust: bindgen AppLayerParserConfParserEnabled
Ticket: 7667
3 months ago
Philippe Antoine 49b2a2be5d rust: bindgen SCAppLayerParserRegisterLogger
Ticket: 7667
3 months ago
Philippe Antoine 7bfef2e1e8 rust: bindgen AppLayerParserRegisterParserAcceptableDataDirection
Ticket: 7667
3 months ago
Philippe Antoine 1ff4dbfc24 rust: bindgen AppLayerParserSetStreamDepth
Ticket: 7667
3 months ago
Philippe Antoine b29d46d81f rust: bindgen SCAppLayerParserStateIssetFlag
Ticket: 7667
3 months ago
Philippe Antoine 6d56beffef rust: bindgen AppLayerParserStateSetFlag
Ticket: 7667
3 months ago
Philippe Antoine 249131e9de src: clean includes for app-layer-parser.h
To prepare bindgening
3 months ago
Victor Julien f2faba5a23 detect/config: add flow tracking doc 3 months ago
Victor Julien 00336c45f4 detect/config: remove unused include 3 months ago
Victor Julien 67902c791d detect/config: add func docs 3 months ago
Victor Julien ec6081363c detect/config: remove filestore reference from comments 3 months ago
Victor Julien 6e0a6abb0b detect/config: add support for skipping flow tracking
Allow rules in the `pre_flow` hook to disable flow tracking for a
packet:

    config:packet tcp:pre_flow any any <> any 12345 (           \
        config: tracking disable, type flow, scope packet;      \
        sid:1;)

This rule will be evaluated before a packet is handled by the flow
engine, and a match will ensure that the flow engine is skipped.

Ticket: #7715.
3 months ago
Victor Julien f1fdc1801e detect: set detect table for non-firewall mode as well
This also exposed a difference between the handling of TD alerts in
firewall vs non-firewall mode. In firewall mode the table/hook is also
part of the alert ordering to make sure actions from packet:td are
applied before app:td. Handle that explicitly for now.
3 months ago
Victor Julien 7896148798 detect/config: allow setting a scope for action config 3 months ago
Victor Julien b554c43ab9 util/config: comment out unused types 3 months ago
Victor Julien 4836c3c46b detect/config: clean up keyword value parsing 3 months ago
Victor Julien 0de19d61aa detect: clean up signature validate logic
`SigValidate` was doing more than just validation. Break out the
function into validation steps and consolidation steps.
3 months ago
Victor Julien 12f2f3f9f1 detect: tables support per keyword
Allow keywords to specify in which detect table they can function.

E.g. the pre_flow table will not support flow keywords, as no flow is
availble at this time.
3 months ago
Victor Julien a88d58e531 detect: use accept:hook policy for pre_* hooks
Set firewall policy in scratch pad. Default to drop:packet for filter tables,
use accept:hook for pre_stream and pre_hook.
3 months ago
Victor Julien df7fe5b0ce detect: add pre_flow hook
Allows dropping of packets before a flow is created/updated.
Directionless as direction is inferred from the flow.

Ticket: #7714.
3 months ago
Victor Julien 8f2b925e09 detect: add pre_stream hook
Meant to be used from the detection engine, to allow rules to drop
traffic before it modifies the stream state.

Ticket: #7712.
3 months ago
Victor Julien ecbcccf355 detect: add tcp.wscale keyword
Allows matching on wscale option value in TCP header options.

Ticket: #7713.
3 months ago
Victor Julien 0246668de7 flow-worker: use explicit type for DetectEngineThreadCtx 3 months ago
Victor Julien 860bb11692 detect: only reset packet alert things in unittest mode 3 months ago
Victor Julien afa88757fe detect: pass de_ctx around as const 3 months ago
Victor Julien a90938c55a detect/bsize: constify signature pointer in callback 3 months ago
Victor Julien 325f0cc02a detect/absent: constify signature pointer in callback 3 months ago
Victor Julien 17ed70dcb5 eve/schema: reformat with clang-format 3 months ago
Jason Ish 1aaf5cb7d2 rust: allow some lints in suricatactl and suricatasc
These are lints we allow in the Suricata Rust source code for style
reasons.
3 months ago
Jason Ish 89ba53272c suricatasc: reconnect on loss of connection
If the connection is lost (for example, Suricata is restarted), try to
re-open the connect and re-execute the command.

This was the behavior of the Python implementation.

Ticket: #7746
3 months ago
Lukas Sismis da03461f71 affinity: avoid zero-division in the CPU selector
Ticket: 7747
3 months ago
Lukas Sismis b71bb41bc5 runmodes: remove redundant NULL check
Ticket: 7747
3 months ago
Jeff Lucovsky cd4e728b77 detect: Ensure byte* variable usages is for same buffers
Issue: 7549

Use the active buffer list to fetch SM variables to ensure that they are
part of the same list so a variable created with bytemath or byteextract
will have context when used with bytejump, e.g

Not needed for content modifiers.
3 months ago
Jason Ish f7a05f1e8e dns: log addresses in order of packet
DNS logs have always been logged in flow direction, this can be
confusing as DNS responses have a src_ip of the client, but it makes
more sense to have the src_ip for the server, as that is the src_ip of
the response packet.

As this is a breaking change, limit it DNS v3 logging which was
introduced, and is the default for Suricata 8.0.

Ticket: #6400
3 months ago
Jason Ish 25e32f4f7a output: delayed initialization for custom loggers
When a plugin is first initialized, it is too early to register
transaction loggers. Instead, a plugin can register a callback to be
called when Suricata is ready for outputs like transaction loggers to
be registered.

Likewise for library users, there is a window in SuricataInit where
transaction loggers can be registered that library users don't have
access to. So a lifecycle callback useful here as well.

Ticket #7236
3 months ago
Juliana Fajardini 656b24004e pgsql: install rules 3 months ago
Shivani Bhardwaj ab01a1b211 smtp: trigger raw stream inspection
Internals
---------
Suricata's stream engine returns data for inspection to the detection
engine from the stream when the chunk size is reached.

Bug
---
Inspection triggered only in the specified chunk sizes may be too late
when it comes to inspection of smaller protocol specific data which
could result in delayed inspection, incorrect data logged with a transaction
and logs misindicating the pkt that triggered an alert.

Fix
---
Fix this by making an explicit call from all respective applayer parsers to
trigger raw stream inspection which shall make the data available for inspection
in the following call of the stream engine. This needs to happen per direction
on the completion of an entity like a request or a response.

Important notes
---------------
1. The above mentioned behavior with and without this patch is
affected internally by the following conditions.
- inspection depth
- stream depth
In these special cases, the inspection window will be affected and
Suricata may not consider all the data that could be expected to be
inspected.
2. This only applies to applayer protocols running over TCP.
3. The inspection window is only considered up to the ACK'd data.
4. This entire issue is about IDS mode only.

SMTP parser can handle multiple command lines per direction, however an
SMTP transaction comprises of the full communication starting from HELO
till there's a RST or QUIT request. Appropriate calls to trigger raw stream
inspection have been added on succesful parsing of each full request and response.

Task 7026
Bug 7004
3 months ago
Shivani Bhardwaj 16eb56aa73 sip: fix inspection direction 3 months ago
Shivani Bhardwaj 8bf7e9abcc dnp3: trigger raw stream inspection
Internals
---------
Suricata's stream engine returns data for inspection to the detection
engine from the stream when the chunk size is reached.

Bug
---
Inspection triggered only in the specified chunk sizes may be too late
when it comes to inspection of smaller protocol specific data which
could result in delayed inspection, incorrect data logged with a transaction
and logs misindicating the pkt that triggered an alert.

Fix
---
Fix this by making an explicit call from all respective applayer parsers to
trigger raw stream inspection which shall make the data available for inspection
in the following call of the stream engine. This needs to happen per direction
on the completion of an entity like a request or a response.

Important notes
---------------
1. The above mentioned behavior with and without this patch is
affected internally by the following conditions.
- inspection depth
- stream depth
In these special cases, the inspection window will be affected and
Suricata may not consider all the data that could be expected to be
inspected.
2. This only applies to applayer protocols running over TCP.
3. The inspection window is only considered up to the ACK'd data.
4. This entire issue is about IDS mode only.

DNP3 parser creates a transaction per direction. Appropriate calls to trigger
raw stream inspection have been added on succesful parsing of each request and
response.

Task 7026
Bug 7004
3 months ago
Lukas Sismis f48f808f33 threading: add unittests for cpu affinity YAML parsing 3 months ago
Lukas Sismis daca1d1a24 affinity: error out on defining CPUs outside valid range 3 months ago
Lukas Sismis ba7a42b4eb threading: let cpu set building callback return a value 3 months ago
Lukas Sismis 8817a959e8 threading: support thread autopinning and interface-specific affinity
Using the new configuration format, it is now possible to set CPU affinity
settings per interface.

The threading.autopin option has been added to automatically use CPUs from the
same NUMA node as the interface. The autopin option requires
hwloc-devel / hwloc-dev to be installed and --enable-hwloc flag in configure
script.

Ticket: 7036
3 months ago
Lukas Sismis 1a1789eb29 doc: remove title in threading section with no content 3 months ago
Lukas Sismis 6c654e30ac threading: support previous threading configuration format
Provide backward compatibility with the previous configuration
format to allow smooth transition to the new format.
The commit adds docs about the new format and the introduced changes.
3 months ago
Lukas Sismis 733cf34ad7 threading: transform *-cpu-set nodes from list items to nodes
Part of Ticket 2321 work to remove unnecessary lists from
the config file.

Ticket: 2321
3 months ago
Lukas Sismis 390baad7dc util-affinity: move properties of *-cpu-set node one layer up in YAML 3 months ago