Commit Graph

5884 Commits (3e14aa729ae83616e4724ff626a346bd75713ee8)
 

Author SHA1 Message Date
Ken Steele f83022d818 Implement MPM opt for ac-bs and ac-gfbs
Copies sids changes from ac.
10 years ago
Ken Steele d03f124445 Implement MPM opt for b2g, b3g, wumanber
Found problems in b2gm and b2gc, so those are removed.
10 years ago
Ken Steele edaefe5af2 Fix AC-tile for new pattern ID array. 10 years ago
Victor Julien 29074af9a6 AC: use local bit array
Use a local pattern bit array to making sure we don't match more than
once, in addition to the pmq bitarray that is still used for results
validation higher up in the rule matching process.

Why: pmq->pattern_id_bitarray is currently sometimes used in a
'stateful' way, meaning that for a single packet we run multiple
MPM's on the same pmq w/o resetting it.

The new bitarray is used to determine wherther we need to append the
patterns associated 'sids' list to the pmq rule_id_array.

It has been observed that MPM1 matches for PAT1, and MPM2 matches for
PAT1 as well. However, in MPM1 PAT1 doesn't have the same sids list.
In this case MPM2 would not add it's sids to the list, leading to missed
detection.
10 years ago
Victor Julien 7876277119 detect: move checks from prefilter to rule detect
Move the prefilter checks to the main detect loop.
10 years ago
Victor Julien d1d895a884 Replace build match array with new filter logic
Use MPM and non-MPM lists to build our match array. Both lists are
sorted, and are merged and sorted into the match array.

This disables the old match array building code and thus also bypasses
the mask checking.
10 years ago
Victor Julien 1f57e25c03 detect: Add negated MPM to non-MPM array
Treat negated MPM sigs as if non-MPM, so we consider them always.

As MPM results and non-MPM rules lists are now merged and considered
for further inspection, rules that need to be considerd when a pattern
is absent are caught in the middle.

As a HACK/workaround this patch adds them to the non-MPM list. This
causes them to be inspected each time.
10 years ago
Victor Julien f5df526f9b Detect: create per sgh non-MPM rule array
Array of rule id's that are not using MPM prefiltering. These will be
merged with the MPM results array. Together these should lead to a
list of all the rules that can possibly match.
10 years ago
Victor Julien e49d0a5924 MPM: build sid list from MPM matches
Pmq add rule list: Array of uint32_t's to store (internal) sids from the MPM.

AC: store sids in the pattern list, append to Pmq::rule_id_array on match.

Detect: sort rule_id_array after it was set up by the MPM. Rule id's
(Signature::num) are ordered, and the rule's with the lowest id are to
be inspected first. As the MPM doesn't fill the array in order, but instead
'randomly' we need this sort step to assure proper inspection order.
10 years ago
Ken Steele b96645ded2 Create a wrapper around DetectFlowvarProcessList() to check for empty list
Creates an inline wrapper to check for flowvarlist == NULL before calling
DetectFlowvarProcessList() to remove the overhead of checking since the
list is usually empty.
10 years ago
Ken Steele 5008d0a58b Remove the b2gm and b2gc MPMs
These MPMs have code that looks like it won't work and updating them to
for the new MPM optimization wasn't working.
10 years ago
Victor Julien 227a7de351 Global define of MIN
Some OS' provide it automatically, so make sure we define it
conditionally in one place.
10 years ago
Victor Julien bcfd61416f Fix a fix: defrag OOM condition
** CID 1257764:  Dereference after null check  (FORWARD_NULL)
/src/defrag.c: 291 in Defrag4Reassemble()

** CID 1257763:  Dereference after null check  (FORWARD_NULL)
/src/defrag.c: 409 in Defrag6Reassemble()

In the error case 'rp' can be both NULL or non-NULL.
10 years ago
Victor Julien 43a1007788 detect: add test for memcmp issue 10 years ago
Victor Julien 0d910bed1d Add test for memcmp issue. 10 years ago
Victor Julien 17dfd59bc3 memcmp: compare the first byte as well
MemcmpLowercase would not compare the first byte of both input buffers
leading to two non-identical buffers to be considered the same.

Affects SSE_4_1 and SSE_4_2 implementations of SCMemcmpLowercase, as well
as the non-SIMD implementation. SSE_3 and Tile version are not affected.
10 years ago
Victor Julien c51ce4d2c0 Fix OS X 10.10 unittest failure
Work around OS X 10.10 Yosemite returning EDEADLK on a rwlock wrlocked
then tested by wrtrylock. All other OS' (and versions of OS X that I
tested) seem to return EBUSY instead.
10 years ago
Victor Julien baa55ba239 Fix Tilera compilation
Use proper initializer for a static mutex declaration.

Credits: Ken Steele
10 years ago
Victor Julien 8e946b92b7 Fix compilation on OS X Yosemite
Due to our unconditional declaration of the strlcat and strlcpy
functions, compilation failed on OS X Yosemite.

Bug #1192
10 years ago
Travis Green a1eab4a2e2 Update reference.config
Updated reference.config to match ET Open reference.config found here: 
https://rules.emergingthreats.net/open/suricata/reference.config

Due to startup error shown here:
root@xxxxxxx01:/etc/suricata/rules# /usr/bin/suricata -c /etc/suricata/suricata.yaml --pidfile /var/run/suricata.pid --af-packet
23/12/2014 -- 22:07:56 - <Error> - [ERRCODE: SC_ERR_REFERENCE_UNKNOWN(150)] - unknown reference key "osvdb". Supported keys are defined in reference.config file.  Please have a look at the conf param "reference-config-file"
<...>
Killed
10 years ago
Jason Ish 2b81caf73e Respect DESTDIR in install-conf and install-rules. 10 years ago
Victor Julien 485f34134e unix socket: support profiling 10 years ago
Victor Julien f32d79dfe0 smtp: fix tx handling
Fix issue where SMTPStateGetTxCnt would return the actual active tx'.

The 'GetCnt' API call is not named correctly. It should be 'GetMaxId',
as this is actually the expected behavior.
10 years ago
Victor Julien 105b4340c2 thread local storage: add to build-info 10 years ago
Victor Julien 623c2e78fd packet pool: make pending pool use more robust
Don't leave pointers dangling.
10 years ago
Victor Julien 6e174128c8 packet pool: memory fixes for non-TLS
If the posix TLS implementation is used, the packet pool is memset to
0 before use.

Also use proper 'free' function.
10 years ago
Victor Julien 6fa8922ccd configure: add switch to disable __thread use
Add --disable-threading-tls switch to force the posix thread local
storage code paths even if __thread is available.

Goal is to make it easier to QA the posix code path.
10 years ago
Victor Julien 2745cd2ce9 packet pool: fix wrong free call 10 years ago
Eric Leblond ff8dae3b75 app-layer: fix 'detection-only' keyword
If we follow the description in the yaml file, we should disable
parsing if 'detection-only' keyword is used.
10 years ago
Eric Leblond 969abc2ccd output-json: fix duplicate logging
This patches is fixing a issue in the OutputJSONBuffer function. It
was writing to file the content of the buffer starting from the start
to the final offset. But as the writing is done for each JSON string
we are duplicating the previous events if we are reusing the same
buffer.

Duplication was for example triggered when we have multiple alerts
attached to a packet. In the case of two alerts, the first one was
logged twice more as the second one.
10 years ago
Victor Julien dc5e2a515c stream: improve inline mode GAP handling
Don't conclude a GAP is 'final' until the missing data is ack'd.

Further, cleanup and unify more with the non-inline code.
10 years ago
Victor Julien b69ca16553 stream: move utility functions
This way they can be used by the *Inline* functions as well.
10 years ago
Victor Julien a095694945 host: register unittests
Host unittests were not registered so they wouldn't run.
10 years ago
Victor Julien 60b50e1ca5 packet-pool: free pending packets 10 years ago
Victor Julien 8b2dd81628 stats: stats threads don't need packet pools 10 years ago
Victor Julien ffd2248459 flow manager: destroy packet pool on close 10 years ago
Victor Julien c4e1324690 flow-timeout: use packet pool
Use packet pool for pseudo packets on flow timeout. Wait for a packet
if necessary.

For shutdown, alloc a new pool as the 'main()' thread calls this.
10 years ago
Victor Julien cef609bb73 threading: lock TmThreadKillThreadsFamily 10 years ago
Victor Julien 3499d682c4 flow timeout: cleanups
Rename FlowForceReassemblyForFlowV2 to just FlowForceReassemblyForFlow
as there is no V1.
10 years ago
Victor Julien 6e69b51123 flow timeout: cleanup
Remove now unused old flow timeout code.
10 years ago
Victor Julien de4bda14e6 stream: handle flow timeout stream end packets
Handle flow timeout packets in the stream engine. Previously the flow
timeout code would call reassembly code directly.
10 years ago
Victor Julien 0ffaad66eb flow-time: disable remainder of the old timeout code
Disable registration code that was looking for threadvars
and slots as timeout handling is now done in a live engine.
10 years ago
Victor Julien 8e86f387a6 flow-time: use live threads at shutdown
Update pktacq loop to process flow timeouts in a running engine.

Add a new step to the shutdown phase of packet acquisition loop
threads (pktacqloop).

The shutdown code lets the pktacqloop break out of it's packet
acquisition loop. The thread then enters a flow timeout loop, where
it processes packets from it's tv->stream_pq queue until it's
empty _and_ the KILL flag is set.

Make sure receive threads are done before moving on to flow hash
cleanup (recycle all). Without this the flow recycler could start
it's unconditional hash clean up while detect threads are still
running on the flows.

Update unix socket to match live modes.
10 years ago
Victor Julien c6ec92d9b1 flow-timeout: use live threads
Use live threads. Disable old timeout code.
10 years ago
Victor Julien 48eccf7d91 Assign thread_id to flow on first packet stream engine 10 years ago
Victor Julien 8c51b23e94 Thread registration: id's start at 1
Start thread id's at 1, so that in flow's we can use 0 to indicate
a thread id hasn't been set in it yet.
10 years ago
Victor Julien 7f80516563 Introduce Flow timeout injection api
Add function TmThreadsInjectPacketById that is to be used to inject flow
timeout packets into the threads stream_pq queue.

TmThreadsInjectPacketById will also wake up listening threads if
applicable.

Packets are passed all packets together in an NULL terminated array
to reduce locking overhead.
10 years ago
Victor Julien 51a782fd8c Define FlowThreadId and add it to the flow
16 bits id should be enough for threads for a while.
10 years ago
Victor Julien a260cba32b Give easy access for thread stream packet queue
Access it from ThreadVars. This allows for easy injection of packets
into the stream engine.
10 years ago
Victor Julien 489ee20560 Thread Registration API for ID's
Create thread registration and unregistration API for assigning unique
thread id's.

Threadvars is static even if a thread restarts, so we can do the
registration before the threads start.

A thread is unregistered when the ThreadVars are freed.
10 years ago