Commit Graph

8081 Commits (889a6de926c02c96e2d86f3a0cf9d551c4f13f3a)
 

Author SHA1 Message Date
Victor Julien ee00a6f2ec stream: validate code 8 years ago
Victor Julien e1aba7d6c2 detect: only do flow dependent cleanup if a flow is present 8 years ago
Victor Julien 61c35d3c39 detect: make SigMatchSignatures void
None of the callers cared for it's retval, so get rid of it.
8 years ago
Victor Julien f49150ddb9 detect: turn single detect flag into bool 8 years ago
Victor Julien 6f76cbb870 detect: remove unused detect flag 8 years ago
Victor Julien 04b24cf24e stream: improve needs reassembly code 8 years ago
Victor Julien 55e19bfb89 stream: more aggressive StreamReassembleRawHasDataReady 8 years ago
Victor Julien bf3f3ce6b2 app-layer: change logic of setting 'no reassembly'
Instead of killing all reassembly instantly do things slightly more
gracefully:
1. disable app-layer reassembly immediately
2. flag raw reassembly not to accept new data

This will allow the current data to be inspected still.

After detect as run the raw reassembly will be fully disabled and
thus all reassembly will be as well.
8 years ago
Victor Julien de4f4e23a0 stream: new depth / disable raw logic
Depth reach sets NOREASSEMBLY after detect.

No new raw sets NORAW after detect.
8 years ago
Victor Julien 7c56c9ada0 stream: allow raw reassembly catch up
If raw reassembly falls behind, for example because no raw mpm is
active, then we need to sync up to the app progress if that is
available, or to the generic tcp tracking otherwise.
8 years ago
Victor Julien 89d0267df2 stream: detect stream GAP also during reassembly 8 years ago
Victor Julien 0c1ec17c92 debug-validation: add stream checks 8 years ago
Victor Julien 69519bda48 stream: StreamTcpReassembleRawCheckLimit cleanup 8 years ago
Victor Julien b099008b94 stream: handle no stream scanning case
Now that detect moves the raw progress forward, it's important
to deal with the case where detect don't consider raw inspection.

If no 'stream' rules are active, disable raw. For this the disable
raw flag is now per stream.
8 years ago
Victor Julien 0ef46a8fd2 stream: raw content inspection inline mode
Implement the inline mode for raw content inspection. Packets
are leading, and when a packet's payload has been added to the
stream, the packet is inspected in the context of the stream.

Reassembly will return a buffer with the packet data with older
data in front of it and after it, if available.
8 years ago
Victor Julien 149e324060 flow/stream: reduce/disable pseudo packet injections
At flow timeout, we no longer need to first run reassembly in
one dir, then inspection in the other. We can do both in single
packet now.

Disable pseudo packets when receiving stream end packets. Instead
call the app-layer parser in the packet direction for stream end
packets and flow end packets.

These changes in handling of those stream end packets make the
pseudo packets unnecessary.
8 years ago
Victor Julien 2d223b69cd stream: set 'trigger raw' per direction 8 years ago
Victor Julien 971ab18b95 detect / stream: new 'raw' stream inspection
Remove the 'StreamMsg' approach from the engine. In this approach the
stream engine would create a list of chunks for inspection by the
detection engine. There were several issues:

1. the messages had a fixed size, so blocks of data bigger than ~4k
   would be cut into multiple messages

2. it lead to lots of data copying and unnecessary memory use

3. the StreamMsgs used a central pool

The Stream engine switched over to the streaming buffer API, which
means that the reassembled data is always available. This made the
StreamMsg approach even clunkier.

The new approach exposes the streaming buffer data to the detection
engine. It has to pay attention to an important issue though: packet
loss. The data may have gaps. The streaming buffer API tracks the
blocks of continuous data.

To access the data for inspection a callback approach is used. The
'StreamReassembleRaw' function is called with a callback and data.
This way it runs the MPM and individual rule inspection code. At
the end of each detection run the stream engine is notified that it
can move forward it's 'progress'.
8 years ago
Victor Julien 564c0bd2c1 stream: constify StreamTcpReassembleRawCheckLimit 8 years ago
Victor Julien 0bff0de516 unittests: fail if TCP memory still in use
abort() so test can be analyzed.
8 years ago
Victor Julien 807312320f stream-tcp: implement thread pool for segments
Config option:

stream:
  reassembly:
    segment-prealloc: 2048
8 years ago
Victor Julien bd821f57f2 stream: implement memory handling functions 8 years ago
Victor Julien c2a5b9c393 stream: use static instead of dynamic streaming buffer structure 8 years ago
Victor Julien dd2b8bb298 stream: test cleanups and fixes 8 years ago
Victor Julien 8924653cd4 stream: add insert failure counters 8 years ago
Victor Julien 91f57200c7 stream: add stream.reassembly.check-overlap-different-data option 8 years ago
Victor Julien f02dc377ef stream: add tcp.overlap and tcp.overlap_diff_data counters 8 years ago
Victor Julien 8c36e52d93 stream: improve no app and no raw case 8 years ago
Victor Julien 5ee36a0c8b stream: make raw_progress relative to STREAM_BASE_OFFSET 8 years ago
Victor Julien fa2a832022 stream: make app_progress relative to STREAM_BASE_OFFSET 8 years ago
Victor Julien 187e2381c8 stream: reduce space used for progress tracking
Instead of the explicit base_seq_offset, use a macro instead. The
macro points to the stream buffer offset. The two were always
in sync.
8 years ago
Victor Julien 9bd11bcda5 stream: small cleanups 8 years ago
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