Commit Graph

12326 Commits (9cc92b8dd59ea97e0a9051542d34680e53afc31b)
 

Author SHA1 Message Date
Philippe Antoine 83490d4e3c tftp: StringToAppProto case
So, fuzz_applayerparserparse_tftp will fuzz tftp

(cherry picked from commit c9d664b0a0)
4 years ago
Jason Ish fd57cf76bf detect-content: error on single char hex pairs
Fix parsing of content like "|aa b cc|" which was parsed as "|aa bc|"
without error or warning. This will now fail out, requiring all hex
values to be 2 chars.

Ticket #5201

(cherry picked from commit 8d1e4a1d0b)
4 years ago
Shivani Bhardwaj 0ddf39344e detect/dataset: cleanup dead code
(cherry picked from commit 7366396011)
4 years ago
Shivani Bhardwaj 5e084d4daa detect/dataset: fix space condition in rule lang
If there is a space following a keyword that does not expect a value,
the rule fails to load due to improper value evaluation.
e.g. Space after "set" command
alert http any any -> any any (http.user_agent; dataset:set  ,ua-seen,type string,save datasets.csv; sid:1;)

gives error
[ERRCODE: SC_ERR_UNKNOWN_VALUE(129)] - dataset action "" is not supported.

Fix this by handling values correctly for such cases.

(cherry picked from commit 6d2a2a0731)
4 years ago
Victor Julien b8305b1108 flow: fix and simplify locking
Since:

9551cd0535 ("threading: don't pass locked flow between threads")

`MoveToWorkQueue()` unconditionally unlocks the flow. This allows simpler
locking handling, including of tcp reuse flows.

The simpler logic also fixes a scenario where TCP reuse flows got "unlocked"
twice, once in `FlowGetFlowFromHash()` and once in `MoveToWorkQueue()`.

Bug: #5248.
Coverity: 1494354.
(cherry picked from commit 57533d3e47)
4 years ago
Jeff Lucovsky e0834b3047 log/stack: Propagate original signal
Issue: 4550

This commit modifies the "stack trace on signal" to propagate the
original signal received instead of always raising SIGABRT.

(cherry picked from commit a3443845fb)
4 years ago
Jeff Lucovsky 0e2d76f836 config: Make libunwind use configurable for 6.0
Issue: 4973

This commit makes stack-trace on fault configurable by
adding "--enable-libunwind" as a configure option.

By default, or if "--enable-libunwind=no" is specified, the libunwind
library will not be configured.

When "--enable-libunwind=yes" is specified, libunwind will be used iff
it can be found in one of the standard library locations.
4 years ago
Jeff Lucovsky 1306dbf268 doc/yaml: Signal-termination option description
(cherry picked from commit 93842aa14a)
4 years ago
Jeff Lucovsky 529e69b27b logging/diag: Enable stacktrace diagnostic if config'd
This commit adds a signal handler for SIGSEGV when configured. The
signal handler emits a one line stack trace using SCLogError. The intent
is to provide diagnostic information in deployments where core files are
not possible.

The diagnostic message is from the offending thread and includes the
stack trace; each frame includes the symbol + offset.

(cherry picked from commit 7f0f463b64)
4 years ago
Jeff Lucovsky c1506ebde4 logging: Stacktrace on signal term setting
This commit adds a configuration setting to enable a stack trace message
if Suricata receives a signal that terminates execution, such as
SIGSEGV, SIGABRT.

(cherry picked from commit 163f70be9d)
4 years ago
Jeff Lucovsky 9f68fc946a error: Add error code for sig-related diagnostics
This commit adds an error code for the diagnostic code used for
diagnostic messages following unexpected termination due to signals..

(cherry picked from commit 501c870a2c)
4 years ago
Jeff Lucovsky 285f57861e configure.ac: Support libunwind configuration
This commit adds support for enabling libunwind -- a library that can be
used to display stack information.

Libunwind is enabled and used by Suricata if present during
configuration.  A diagnostic message is displayed if libunwind
cannot be found.

(cherry picked from commit 303dd29b50)
4 years ago
Victor Julien 866d0872be nss: use 'atexit()' to cleanup
This avoids ASAN to report leaks in case of fatal errors in tests.
4 years ago
Arne Welzel 22c47396fd flow-manager: fix off-by-one in flow_hash row allocation
The current code doesn't cover all rows when more than one flow manager is
used. It leaves a single row between ftd->max and ftd->min of the next
manager orphaned. As an example:

    hash_size=1000
    flowmgr_number=3
    range=333

    instance  ftd->min  ftd->max
    0         0         333
    1         334       666
    2         667       1000

    Rows not covered: 333, 666

(cherry picked from commit 8ef066318d)
5 years ago
Philippe Antoine 16c52db465 ssl: first pass limit when allocating buffer for certificates
With this check, on the first packet of a certificate presenting
a length of 16Mbytes, we only allocate up to 65Kb

When we get to the point where need more than 65Kb, we realloc
to the true size.

With this check, it makes it more expensive for an attacket to use
this allocation as a way to trigger ressource exhaustion...

(cherry picked from commit 862e84877f)
5 years ago
Philippe Antoine 384611da1a fuzz: use fuzzing confyaml for protodetect target
As is done for other targets,
so that all app-layer protocols are enabled,
even the ones disabled by default such as enip

And resets protocol detection every time we try
so that probing_parser_toserver_alproto_masks are fresh.

(cherry picked from commit 09c84d0c26)
5 years ago
Philippe Antoine 5af5b125ee smtp: check if we have a current transaction
Ticket: 4948

This is not the perfect solution, but it prevents to trigger
the assert, and keep the assert.
A better solution would need to create transaction from
the reponse parsing, in case a later command was buffered and
not answered. But this would not be enough as NoNewTx prevents
the creation of a new transaction for RSET...

(cherry picked from commit 4247605d87)
5 years ago
Victor Julien ce69f79f6a smb1: apply close to direction
Instead of closing files in both direction when receiving a close request,
close only toserver files for the request and close toclient on receiving
a response.

(cherry picked from commit b336882008)
5 years ago
Steven Ottenhoff 9b1557b7a7 pppoe: fix protocol field length variation
Detect when protocol field is not a 16 bit field.
Added tests to prove logic

Ticket: 4810
(cherry picked from commit 6bf2117056)
5 years ago
Philippe Antoine e723ecb1ff smtp: check if there is a transaction to close
Ticket: 4948

When parsing the response for starttls

(cherry picked from commit 99b3443369)
5 years ago
Shivani Bhardwaj 0e9f42c744 doc/xbits: clarify noalert usage 5 years ago
Shivani Bhardwaj 2c5eead479 detect/xbits: parse keywords w strtok_r
Ticket: 4820
5 years ago
Jeff Lucovsky d04b32466f detect/ipproto: Use builtin protocol table
Issue 5072

This commit causes the built-in protocol table to be used for protocol
name and number validation.

(cherry picked from commit 4f2f745bed)
5 years ago
Jeff Lucovsky 834dcf65f6 detect/tests: Register protoname tests
Issue: 5072

This commit registers the proto-name unit tests.

(cherry picked from commit 3bd1d258a9)
5 years ago
Jeff Lucovsky d569efda66 detect/ipproto: Add init/release functions
Issue: 5072

This commit insures that the protocol name hashtables are initialized
and released.

(cherry picked from commit b524967257)
5 years ago
Jeff Lucovsky e0426237c2 util/proto: Protocol-name functions
Issue: 5072

This commit adds utility functions handling protocol names.

(cherry picked from commit ff0cf89738)
5 years ago
Jeff Lucovsky 442a859f6e error/hash: Add error code for hash add failures
Issue: 5072
(cherry picked from commit 1e2883602b)
5 years ago
Philippe Antoine 42e47decf9 util: export Djb2 hash string function
(cherry picked from commit 5cb996efcf)
5 years ago
Jeff Lucovsky 3a3840be2b proto: Remove dependency on /etc/protocols
This commit eliminates the dependency on /etc/protocols and equivalent
on other platforms by using a static table of IANA assigned protocol
values (names, description).

(cherry picked from commit e77e8dbe18)
5 years ago
Jeff Lucovsky 4e6a6e6467 threads: Honor per-thread stack size setting
Issue: 4550

This commit adjusts the per-thread stack size if a size has been
configured. If the setting has not been configured, the default
per-thread stack size provided by the runtime mechanisms are used.

(cherry picked from commit 6232c94235)
5 years ago
Jeff Lucovsky 9d66541128 config/thread: Use config'd per-thread stack size
Issue: 4550

This commit checks if there's a config setting for threading.stack-size
and assigns the value to a global variable for use during thread
creation.

(cherry picked from commit e4d60f451b)
5 years ago
Jeff Lucovsky 1b2ab0e8d4 suricata.yaml: Add per-thread stack size setting
Issue: 4550
(cherry picked from commit d79a317cea)
5 years ago
Jeff Lucovsky 9923083039 config/debug: Debug probe for getattr_np
This commit adds a probe for a non-portable function to be used in
diagnostic debug display of a thread's stack size.

(cherry picked from commit deb49862cd)
5 years ago
Jeff Lucovsky 00ab84fd63 doc: Describe per-thread stack size config setting
Issue: 4550

This commit documents the new per-thread stack-size setting. Some
systems have a small default value that is not suitable for Suricata's
multi-threaded architecture and adjustment may be required.

(cherry picked from commit 117e11b0ae)
5 years ago
Jeff Lucovsky e28d093ae7 general: Fix typo
(cherry picked from commit b53fced452)
5 years ago
Jeff Lucovsky 41f38bd5c0 config/ref: Raise errors for ref.config parsing
This commit raises an error in configuration test mode if there was an
error parsing reference.config.

Issue: 4659
(cherry picked from commit be2155b4ed)
5 years ago
Jason Ish e3638cfd04 logging: change ownership of application log if needed
When running with privilege dropping, the application log file
is opened before privileges are dropped resulting in Suricata
failing to re-open the file for file rotation.

If needed, chown the application to the run-as user/group after
opening.

Ticker #4523

(cherry picked from commit 59ac1fe277)
5 years ago
Jason Ish 38db09bbb5 startup: initialize run as user info sooner
Initialize the run-as user info after loading the config, but
before setting up logging (previously it was done while initializing
signal handlers). This will allow the log file to be given the
correct permissions if Suricata is configured to run as a non-root
user.

(cherry picked from commit 08518df373)
5 years ago
Victor Julien 7b47bffda8 swf: fix coverity warnings
*** CID 1499365:    (UNINIT)
/src/util-file-swf-decompression.c: 98 in FileSwfZlibDecompression()
92         infstream.avail_in = (uInt)compressed_data_len;
93         infstream.next_in = (Bytef *)compressed_data;
94         infstream.avail_out = (uInt)decompressed_data_len;
95         infstream.next_out = (Bytef *)decompressed_data;
96
97         inflateInit(&infstream);

>>>     CID 1499365:    (UNINIT)
>>>     Using uninitialized value "infstream.total_out" when calling "inflate".
98         int result = inflate(&infstream, Z_NO_FLUSH);
99         switch(result) {
100             case Z_STREAM_END:
101                 break;
102             case Z_OK:
103                 break;

/src/util-file-swf-decompression.c: 98 in FileSwfZlibDecompression()
92         infstream.avail_in = (uInt)compressed_data_len;
93         infstream.next_in = (Bytef *)compressed_data;
94         infstream.avail_out = (uInt)decompressed_data_len;
95         infstream.next_out = (Bytef *)decompressed_data;
96
97         inflateInit(&infstream);

>>>     CID 1499365:    (UNINIT)
>>>     Using uninitialized value "infstream.total_out" when calling "inflate".
98         int result = inflate(&infstream, Z_NO_FLUSH);
99         switch(result) {
100             case Z_STREAM_END:
101                 break;
102             case Z_OK:
103                 break;

*** CID 1499363:  Error handling issues  (CHECKED_RETURN)
/src/util-file-swf-decompression.c: 97 in FileSwfZlibDecompression()
91
92         infstream.avail_in = (uInt)compressed_data_len;
93         infstream.next_in = (Bytef *)compressed_data;
94         infstream.avail_out = (uInt)decompressed_data_len;
95         infstream.next_out = (Bytef *)decompressed_data;
96
>>>     CID 1499363:  Error handling issues  (CHECKED_RETURN)
>>>     Calling "inflateInit_(&infstream, "1.2.11", 112)" without checking return value. This library function may fail and return an error code.
97         inflateInit(&infstream);
98         int result = inflate(&infstream, Z_NO_FLUSH);
99         switch(result) {
100             case Z_STREAM_END:
101                 break;
102             case Z_OK:

Bug: #5079.
(cherry picked from commit e1f7c63fa8)
5 years ago
Shivani Bhardwaj 45745ed2ea doc: add usage of flowbits OR op
Ticket 5130

(cherry picked from commit 015c9fe1e3)
5 years ago
Victor Julien 8438dab412 unittests: clean up packet clear logic
(cherry picked from commit 0437ca61ff)
5 years ago
Shivani Bhardwaj 20f4fb7e12 applayer: fix clang formatting 5 years ago
Victor Julien b04a8bdb96 decode: release refs from PacketFree
Mostly helps unittests.

(cherry picked from commit f07d5b2d89)
5 years ago
Victor Julien 8d12189a08 detect/iprep: fix host locking issues
Separate the code paths between reusing a Packet stored host reference
and fetching a new reference from the host hash.

This addresses the issue where in some conditions use_cnt could get
desync'd.

Bug: #2802.
(cherry picked from commit 49a36bb323)
5 years ago
Victor Julien 1ec3a574c7 iprep: unify free handling
Introduce a new util function to free a Hosts iprep code. It also
handles the Host use_cnt decrement.

This change makes sure we also decrement the use_cnt when cleaning
up when shutting down the host table.

Move the BUG_ON check for use_cnt into the HostClearMemory() func
to check it in more cases.

(cherry picked from commit 172d2b28a5)
5 years ago
Victor Julien 5753833e2e detect/iponly: add tests for 5170
(cherry picked from commit 935ea745f5)
5 years ago
Victor Julien 9605cca6fa detect/address: minor unittest cleanup
(cherry picked from commit 053b2b3b5b)
5 years ago
Victor Julien 1932cc1d6b detect/iponly: validate netmask
Only accept netmask in dotted quad notation if they can be turned
into a CIDR.

According to rfc 4632, CIDR (compat) netmasks are all that should be
used.

Bug: #5168.
(cherry picked from commit 79b7b7a0dd)
5 years ago
Victor Julien 8f1644594f detect/address: validate netmasks
Only accept netmask in dotted quad notation if they can be turned
into a CIDR.

According to rfc 4632, CIDR (compat) netmasks are all that should be
used.

Bug: #5168.
(cherry picked from commit 259bd8aa92)
5 years ago
Victor Julien 20171f9be1 detect/iponly: break out range insert code
So we can reuse it.

(cherry picked from commit 4020e2faa7)
5 years ago