Commit Graph

15119 Commits (0b6b015e26e92d88ebfd7ddac6ee34646fc0a57c)
 

Author SHA1 Message Date
Thomas Winter a284f01c1d iprep: fix parsing ip-rep data with carriage return
Commit e7c0f0ad91 removed uses of atoi with a new number parsing
functions. This broke parsing ip-reputation data files that contained
trailing carriage returns as it was being included in the number
string to convert.

Bug: #6243.
2 years ago
Victor Julien becb8cefcc threading: set min thread stack size; set it early
Multi-tenancy uses loader threads that initialize detection engines. During
this, esp the AC family of MPM implementations, there is significant stack
usage. In most OS' threads have a lower stack size by default. In Linux, when
using the Musl C library, a thread by default gets 128KiB.

This patch does 2 things:

1. it centralizes the handling of the `threading.stack-size`. It it is not
   longer handled by the runmodes, but called from the global initialization
   logic.

2. it sets a minimum per thread stack size of 512k, unless `threading.stack-size`
   is set.

Ticket: #6265.
2 years ago
Philippe Antoine 92fce2fdc0 mpm: allocate StateQueue on the heap
So that we can have multi-tenant on MacOS without stack
overflows because of the size of the structure...

Ticket: #6263.
2 years ago
Victor Julien f312370fd2 detect/loader: minor code cleanups 2 years ago
Shivani Bhardwaj a4f670622e workflows: use s-v --debug-failed 2 years ago
Victor Julien 04aee5f099 detect: fix path creation in Windows
Fixes file loading for rule files and Lua scripts.

Bug: #6095.
2 years ago
Victor Julien c0201d3212 doc/userguide: add reload-tenant(s) doc 2 years ago
Victor Julien de598f12a6 multi-tenant: add reload-tenants command
Command to reload all tenants. Their original yaml path will be
used.

Ticket: #6267.
2 years ago
Victor Julien 6ba0956a75 multi-tenant: allow reload w/o yaml path
Store yaml path in de ctx, for reloads w/o path.

This allows for a simpler `reload-tenant N`, where the previously
used yaml is reloaded.
2 years ago
Victor Julien 227caf1315 multi-tenant: don't init config twice in tenant reload 2 years ago
Victor Julien c87803ea0e detect: add multi-detect.config-path
Add option to specify path from which to load the tenants.

Mostly meant to be used in testing.
2 years ago
Victor Julien a4d80bc7c4 detect: free all tenant detect engines
Free all tenants registered in the master.
2 years ago
Victor Julien 228caa640b path: new funcs to merge paths
Take windows directory separators into account.

Path is not checked or "resolved".
2 years ago
Victor Julien 269f751d36 stat: add wrappers to isolate OS_WIN32 specifics 2 years ago
Victor Julien 0cc6f4f281 threshold: minor code cleanups 2 years ago
Victor Julien f052b524bc threshold: fix multi-tenant file parsing
Switch to DetectParseRegex and use a local pcre2_match_data to
avoid concurrency issues.

Bug: #6247.
2 years ago
Victor Julien e5e58d5647 output: deinit last so logging can happen until the end 2 years ago
Victor Julien b130234b26 var-names: reimplement var name handling
Implement a new design for handling var name id's. The old logic
was aware of detection engine versions and generally didn't work
well for multi-tenancy cases. Other than memory leaks and crashes,
logging of var names worked or failed based on which tenant was
loaded last.

This patch implements a new approach, where there is a global store
of vars and their id's for the lifetime of the program.

Overall Design:

Base Store: "base"

Used during keyword registration. Operates under lock. Base is shared
between all detect engines, detect engine versions and tenants.
Each variable name is ref counted.

During the freeing of a detect engine / tenant, unregistration decreases
the ref cnt.

Base has both a string to id and a id to string hash table. String to
id is used during parsing/registration. id to string during unregistration.

Active Store Pointer (atomic)

The "active" store atomic pointer points to the active lookup store. The call
to `VarNameStoreActivate` will build a new lookup store and hot swap
the pointer.

Ensuring memory safety. During the hot swap, the pointer is replaced, so
any new call to the lookup functions will automatically use the new store.
This leaves the case of any lookup happening concurrently with the pointer
swap. For this case we add the old store to a free list. It gets a timestamp
before which it cannot be freed.

Free List

The free list contains old stores that are waiting to get removed. They
contain a timestamp that is checked before they are freed.

Bug: #6044.
Bug: #6201.
2 years ago
Victor Julien 575fbdfbf3 detect/pcre: use local match data during parsing
Fixes multi-tenant multi-loader crashes.

Bug: #6247.
2 years ago
Jason Ish 3802a51552 eve/schema: add host
The "host" field is added to EVE events if the "sensor-name" field is
configured in suricata.yaml.
2 years ago
Jason Ish edb8cca825 eve: fix double free of sensor-name on error
Remove the free of "sensor_name" on error in output-json as this is
cleaned up by the LogFileCtx.

Bug: #6256
2 years ago
Shivani Bhardwaj d4dd53c95f af-packet: terminate on same interface & copyiface
If the interface and copy-iface are same for an af-packet IPS device
setting then fataly exit else it leads to a segfault in later stages.

Bug 5870
2 years ago
Shivani Bhardwaj 3d73538a5b af-packet: check out_iface not NULL 2 years ago
Victor Julien c5d83d081e detect/file: use util to turn keyword to nocase
This changes the way the pattern is stored by making it lowercase.
2 years ago
Victor Julien ef936acdba detect/content: cleanup nocase conversion 2 years ago
jason taylor be324d7856 doc: update file.magic information
Signed-off-by: jason taylor <jtfas90@gmail.com>
2 years ago
jason taylor 008cc78a03 doc: update fileext keyword information
Signed-off-by: jason taylor <jtfas90@gmail.com>
2 years ago
jason taylor e99b1787a2 doc: update file.name keyword information
Signed-off-by: jason taylor <jtfas90@gmail.com>
2 years ago
Alexandre Iooss c80941dd8d doc/userguide: improve SCStreamingBuffer example
Add direction indication in SCStreamingBuffer usage example.
This adds documentation for the changes introduced by commit
5b1d8c7e94.
2 years ago
Victor Julien 2786ccb086 dpdk/mlx5: fix shutdown crash in IPS mode
Make sure to first close all ports before freeing device mempools.

Thread 1 "Suricata-Main" received signal SIGSEGV, Segmentation fault.
0x00007ffff456a3fb in ?? () from /usr/lib/x86_64-linux-gnu/dpdk/pmds-20.0/librte_pmd_mlx5.so
(gdb) bt
 #0  0x00007ffff456a3fb in ?? () from /usr/lib/x86_64-linux-gnu/dpdk/pmds-20.0/librte_pmd_mlx5.so
 #1  0x00007ffff469a948 in ?? () from /usr/lib/x86_64-linux-gnu/dpdk/pmds-20.0/librte_pmd_mlx5.so
 #2  0x00007ffff45606aa in ?? () from /usr/lib/x86_64-linux-gnu/dpdk/pmds-20.0/librte_pmd_mlx5.so
 #3  0x00007ffff6d4ed8d in rte_eth_dev_close () from /usr/lib/x86_64-linux-gnu/librte_ethdev.so.20.0
 #4  0x000000000055fc4c in DPDKCloseDevice (ldev=ldev@entry=0xe3a400) at util-dpdk.c:53
 #5  0x000000000055f4eb in LiveDeviceListClean () at util-device.c:331
 #6  0x00000000005511c8 in GlobalsDestroy (suri=<optimized out>) at suricata.c:381
 #7  0x0000000000550a76 in SuricataMain (argc=<optimized out>, argv=<optimized out>) at suricata.c:3059
 #8  0x00007ffff6a24083 in __libc_start_main (main=0x54cca0 <main>, argc=8, argv=0x7fffffffe4c8, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fffffffe4b8) at ../csu/libc-start.c:308
 #9  0x000000000054cbde in _start ()

Bug: #5619.
2 years ago
Juliana Fajardini 5cef8fdfdf userguide/ppa: fix typo
The launchpad repo for suricata-beta read 'oisd' instead of 'oisf'
2 years ago
Jeff Lucovsky c8615bcd47 detect/analysis: Move globals to engine ctx
Issue: 6239

This commit moves the global variables associated with engine analysis
into the detect engine context. Doing so provides encapsulation of the
analysis components as well as thread-safe operation in a multi-tenant
(context) deployment.
2 years ago
Juliana Fajardini 4fd3205bf0 userguide/install: add info on ubuntu ppa installs
Bringing info that was only in our Redmine wiki to our documentation.

Task #6231
2 years ago
Juliana Fajardini 765b05f139 docs: miscellanea updates
- Fix a DPDK reference link, add some line breaks.
- Exemplify what a good commit message looks
like, for Suricata's commit style.
2 years ago
Jason Ish ae5c65fb49 github-ci: disable some workflows on doc only changes
Don't run the following GitHub workflows on documentation only
changes:
- cifuzz
- codeql
- formatting
- rust
- scan-build
2 years ago
Jason Ish 3e2a62915b doc/userguide: display version on front page
When viewing the docs online at Readthedocs, or similar it might be
immediately apparent what version of the documentation is being
displayed. Display the version on the first line before the table of
contents to make it clear.
2 years ago
Victor Julien 89f1837625 rust: update cargo.lock 2 years ago
jason taylor c1c9b1c5ee detect: update filename buffer description name
Signed-off-by: jason taylor <jtfas90@gmail.com>
2 years ago
Victor Julien b63374bf5f stream: special handling for RST data
Data on RST packets is not invalid, but also shouldn't be used
in reassembly.

RFC 1122:

  4.2.2.12  RST Segment: RFC-793 Section 3.4

    A TCP SHOULD allow a received RST segment to include data.

    DISCUSSION
        It has been suggested that a RST segment could contain
        ASCII text that encoded and explained the cause of the
        RST.  No standard has yet been established for such
        data.

RST data will be presented to the detection engine per packet,
but will not be part of stream reassembly.

Bug: #6244.
2 years ago
Victor Julien 9ba55b8a28 stream: add stream.rst_with_data event for RST with data 2 years ago
Victor Julien 4e19454152 ftp: reenable debug check; improve debug log 2 years ago
Victor Julien 33fca4d4db pcap/file: normalize file timestamps
Normalize the timestamps that are too far in the past to epoch.

Bug: #6240.
2 years ago
Victor Julien 8dc12f5f14 threads: improve spawn failure error reporting 2 years ago
Andreas Herz 26130d903f doc: add note about cpu prio overwrite behavior 2 years ago
Andreas Herz da68692547 doc: dataset - add type to be mandatory 2 years ago
Jeff Lucovsky 427d2a71d5 radix: Detect duplicate netblocks
This commit prevents duplicate IPV4/IPV6 netblocks from being added to the
radix tree.

Contributed by Giuseppe Longo <giuseppe@glongo.it>

Issue: 5748
2 years ago
Jeff Lucovsky a559d7c670 error: Add SC_EEXIST for dups
Issue: 5748

This commit adds SC_EEXIST to be used for cases where an
item/resource/artifact with the same attributes already exists.
2 years ago
Jeff Lucovsky 06158223d2 gen/bool: Use bool type instead of ints
This commit converts usages of `int` to `bool` within the radix utility
code.
2 years ago
Jeff Lucovsky c666317038 reputation: Release memory on key add fails
Ensure that memory for the reputation key is released on failed adds.

Contributed by Giuseppe Longo <giuseppe@glongo.it>

Issue: 5748
2 years ago
Jeff Lucovsky ca0b2b4daa gen/typos: Correct misc. typos. 2 years ago