Commit Graph

7899 Commits (b3e9d397719a972d16b4a4eb2c6fa4a456a4d281)
 

Author SHA1 Message Date
Victor Julien b3e9d39771 stream: remove unused zero copy setting 8 years ago
Victor Julien bbb0df14d2 stream: safety check in overlap handling 8 years ago
Victor Julien 8c9f521707 tcp: streaming implementation
Make stream engine use the streaming buffer API for it's data storage.

This means that the data is stored in a single reassembled sliding
buffer. The subleties of the reassembly, e.g. overlap handling, are
taken care of at segment insertion.

The TcpSegments now have a StreamingBufferSegment that contains an
offset and a length. Using this the segment data can be retrieved
per segment.

Redo segment insertion. The insertion code is moved to it's own file
and is simplified a lot.

A major difference with the previous implementation is that the segment
list now contains overlapping segments if the traffic is that way.
Previously there could be more and smaller segments in the memory list
than what was seen on the wire.

Due to the matching of in memory segments and on the wire segments,
the overlap with different data detection (potential mots attacks)
is much more accurate.

Raw and App reassembly progress is no longer tracked per segment using
flags, but there is now a progress tracker in the TcpStream for each.

When pruning we make sure we don't slide beyond in-use segments. When
both app-layer and raw inspection are beyond the start of the segment
list, the segments might not be freed even though the data in the
streaming buffer is already gone. This is caused by the 'in-use' status
that the segments can implicitly have. This patch accounts for that
when calculating the 'left_edge' of the streaming window.

Raw reassembly still sets up 'StreamMsg' objects for content
inspection. They are set up based on either the full StreamingBuffer,
or based on the StreamingBufferBlocks if there are gaps in the data.

Reworked 'stream needs work' logic. When a flow times out the flow
engine checks whether a TCP flow still needs work. The
StreamNeedsReassembly function is used to test if a stream still has
unreassembled segments or uninspected stream chunks.

This patch updates the function to consider the app and/or raw
progress. It also cleans the function up and adds more meaningful
debug messages. Finally it makes it non-inline.

Unittests have been overhauled, and partly moved into their own files.

Remove lots of dead code.
8 years ago
Victor Julien 3fa2e8689c streaming: remove BUG_ON and other improvements
Can be triggered by memory limits.
8 years ago
Victor Julien d789dc7e6d streaming: add blocklist
Add list of 'blocks'. This list contains offsets and lengths to
continuous data blocks. This is useful for TCP tracking where we
can have data gaps.

The blocks don't contain any data themselves, instead they contain
lenght and offsets. This way no extra copying is needed.

On inserting new data, existing blocks are expanded instead of
having multiple neighbouring blocks.
8 years ago
Victor Julien 9e1470d81c stream-tcp: StreamTcpUTAddPayload unittest helper 8 years ago
Victor Julien 3411697106 profile: account flow-worker tcp-prune step 8 years ago
Victor Julien 245a89b7e7 doc: http keywords update 8 years ago
Victor Julien 595f6d1f26 detect: implement http_content_len sticky buffer
This implements inspection of the Content-Length buffer as a content
sticky buffer.
8 years ago
Victor Julien d96cbddbe4 detect: implement http_content_type sticky buffer 8 years ago
Victor Julien 46febef7cd detect: implement http_accept_enc sticky buffer
Inspects Accept-Encoding header.
8 years ago
Victor Julien 9d5bbc3af6 detect: implement http_accept_lang sticky buffer
Inspects Accept-Language header
8 years ago
Victor Julien 1d1176b0d5 detect: implement http_connection sticky buffer 8 years ago
Victor Julien 5714129e32 detect: implement http referer sticky buffer 8 years ago
Victor Julien 88cfb99910 detect: http_accept sticky buffer + common code
Implement common code to easily add more per HTTP header detection
keywords.

Implement http_accept sticky buffer. It operates on the HTTP Accept
header.
8 years ago
Ray Ruvinskiy 7539973109 tls: logging for session resumption
We assume session resumption has occurred if the Client Hello message
included a session id, we have not seen the server certificate, but
we have seen a Change Cipher Spec message from the server.

Previously, these transactions were not logged at all because the
server cert was never seen.

Ticket: https://redmine.openinfosecfoundation.org/issues/1969
8 years ago
Ray Ruvinskiy 0dc57c937e device: fix warning about NULL device
Fix '[ERRCODE: SC_ERR_INVALID_VALUE(130)] - Name of device should not be null'
warning on start-up with pfring.

Ticket: https://redmine.openinfosecfoundation.org/issues/2097
8 years ago
Victor Julien 29c8125758 redis: use SCCalloc to reduce risk of unitialized vars 8 years ago
fooinha a64e5e77c7 eve: async mode for redis output
eve: detects libevent for async redis at configure
eve: moves redis output code to new file - util-log-redis.{c,h}
eve: redis ECHO and QUIT commands for async mode
eve: redis output defaults if conf is missing
8 years ago
fooinha 36667ab8a1 doc: async mode for redis eve output
async: true ## if redis replies are read asynchronously
8 years ago
Victor Julien c3b4dd5a7d qa: add --no-random commandline option 8 years ago
Victor Julien ba61265403 qa: add rand/rand_r to banned functions 8 years ago
Victor Julien 535d9e3529 random: convert stream and htp to new call 8 years ago
Victor Julien dd70b3fda0 random: improve random logic
Improve random logic for hash tables.

Implement Windows random API if it is available.
8 years ago
Victor Julien ec964ebf84 mingw: don't use uint type as mingw doesn't have it 8 years ago
Victor Julien 8f15e30a58 common: improve byte order and wordsize detection 8 years ago
Victor Julien a4dce24151 core dumps: check for sys/resource.h 8 years ago
Victor Julien 618f351210 cleanup: get rid of %llu format specifiers
Use more explicit types instead.
8 years ago
psanders240 1223de4208 doc: Napatech docs improvement
Fix errors and simplify filters.
8 years ago
Jason Ish e69ce30d87 template script: typo in app-layer setup script
Check for ed was failing, as it was actually looking for edx.
8 years ago
Victor Julien cee5c9fa60 pcre: on ppc64 disable only for specific versions
Disable jit only for libpcre 8.39 and 8.40 as those were the buggy
versions.

Thanks to Zoltán Herczeg.
8 years ago
Victor Julien aca27ff383 doc: expand on bpf 8 years ago
Jason Ish 9ff8882cbd detect: don't consider an empty rule file an error 8 years ago
Jason Ish 8436a892f9 logging: only do non-blocking writes if live
If running against a pcap there is no reason to drop events,
a blocking socket is fine here. So only do non-blocking writes
when running off a live device.
8 years ago
Jason Ish 673549e5cf eve: log number of events dropped at exit 8 years ago
Jason Ish 59b98649de logging: don't block on socket writes
Writing to a unix socket can cause Suricata to block in the
packet path. This could happen if the read-endpoint of the
unix socket stays connected, but stops reading, or simply
can't read fast enough as part of its event processing.

To choose packets over events, do non-blocking socket
writes and drop the event if the write would block and
update a dropped counter.
8 years ago
Mats Klepsland 8b9f84bff2 doc: add documentation for date modifiers in eve-log 8 years ago
Mats Klepsland 37a12fe799 doc: add documentation for eve-log file rotation 8 years ago
Mats Klepsland ffbf8cec16 logging: create log directories when needed
Recursively create new log directories when needed. This makes it
possible to use date modifiers in the file path to create
directories based on date, e.g.:

  /var/log/suricata/2017/02/14/
8 years ago
Mats Klepsland 47a5b493d7 output-json: rotate log file based on time
Rotate log file based on time. Support both rotating based on a timer (XXs,
XXm, XXd, XXw) and rotating based on a absolute time, like each minute,
hour or day.
8 years ago
Mats Klepsland db6c80fd8e logging: support date modifiers in log filenames
Allow log filenames to contain date modifiers, e.g.:

  - eve-log:
    filename: eve-%Y-%m-%d-%H:%M:%S.json
8 years ago
Victor Julien bc480fa8c3 pcre: disable jit on powerpc64
It appears that both using gcc and clang something gets misoptimised
around pcre's jit. So disable jit for now.
8 years ago
Jason Ish 845e18f25a defrag: (windows) detect more overlaps 8 years ago
Jason Ish 7922f9be1b defrag: (linux) fix an error in overlapping fragments
If a subsequent fragment has a lower offset than a previous
one and overlaps, trim off the beginning of the previous
fragment.

Based on an issue reported privately.
8 years ago
Jason Ish ca92be896e defrag: use new unit test macros
Also reformat unit test functions to Suricata style.
8 years ago
Jason Ish 00cd47b2bf travis: use new container build infrastructure
Migrate to the new Travis container build system. This build system does
not allow use of sudo, so required packages must be done declaratively
which required reworking how we install packages that are conditional
based on the build being done.

Mac builds are still done with sudo=true.
8 years ago
Jason Ish ff30d924db unix-socket: return failure on failure
UnixManagerThreadInit needs to return a failure code if the socket
fails to initialize to avoid entering the UnixManager loop which
will continuously fail on the call to bind, as no listening
socket was setup.

This can occur when the socket fails to initialize due to a
permissions error and fatal init errors is not on.
8 years ago
fooinha 20d4d40051 log: tls custom format log 8 years ago
fooinha af174c82bb log: common custom format output 8 years ago
Victor Julien d5a0eb4b2c geoip: fix compiler warning
detect-geoip.c:78:40: error: incompatible pointer types assigning to 'int (*)(ThreadVars *, DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *)' from 'int (ThreadVars *, DetectEngineThreadCtx *, Packet *, Signature *, const SigMatchCtx *)' [-Werror,-Wincompatible-pointer-types]
    sigmatch_table[DETECT_GEOIP].Match = DetectGeoipMatch;
                                       ^ ~~~~~~~~~~~~~~~~
1 error generated.

Bug #2045
8 years ago