Commit Graph

4783 Commits (suricata-2.0.8)

Author SHA1 Message Date
Victor Julien 9952db6d6e Fix crash in AppLayer Proto Detect
The App Proto Detect code would use the wrong pattern count to
index a results array, leading to SEGVs.

Bug #1080.
12 years ago
Victor Julien 2eeddf969d Cygwin: fix compilation
tm-threads.c:1190:5: error: unknown type name ‘DWORD’
12 years ago
Victor Julien 2f14d1e94e Fix compiler warning:
array subscript has type ‘char’ [-Werror=char-subscripts]
12 years ago
Victor Julien 0d280e88d0 pool thread: undo CLS alignment
This breaks clang on 32bit.

Test PoolThreadTestGrow01                                         : process killed by signal 11
12 years ago
Victor Julien d5fdfa4bc1 Fix unittest size_t printing on 32bit 12 years ago
Victor Julien 9b736b6b9e dns: tag each tx we get a reply for as replied
Also, detect and print when server says recursion is desired.
12 years ago
Victor Julien 2047e72cbe DNS: don't store duplicate queries
When an exact duplicate DNS query is received, don't store it in the
tx.
12 years ago
Victor Julien e1e2ebe2da memcmp: convert all pointer arguments to be const pointers, like memcmp itself uses. 12 years ago
Victor Julien a9bf939441 dns log: cleanups 12 years ago
Victor Julien b2d420bed4 app-layer: API calls to check for TX aware proto
Introduce AppLayerParserProtocolIsTxAware which returns 1 if protocol
is Tx aware, 0 if not.
12 years ago
Ken Steele 1f99096b30 Fix PmqSetup() argument removal in ac-tile MPM unit tests.
Needed to remove the second argument from all the calls, which was always 0
and was removed in other tests in a previous checkin.
12 years ago
Victor Julien 399246881d counters: fix 2 scan-build warnings
counters.c:1069:13: warning: Potential leak of memory pointed to by 'temp'
            SCMutexUnlock(&sc_perf_op_ctx->pctmi_lock);
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./threads.h:121:28: note: expanded from macro 'SCMutexUnlock'
                           ^~~~~~~~~~~~~~~~~~~~
counters.c:1156:16: warning: Potential leak of memory pointed to by 'pca'
        return NULL;
               ^~~~
/usr/include/clang/3.3/include/stddef.h:77:24: note: expanded from macro 'NULL'
                       ^
2 warnings generated.
12 years ago
Victor Julien 2c857087fb app-layer: configurable GetActiveTxId function
In preparation of a patchset that will allow for disabling the detect
module, this patch introduces a way to register a function for getting
the lowest active tx id. This is used by the app layer for cleaning up
transactions that already fully inspected, and by the flow timeout code
to determine if a flow is fully inspected and logged at timeout.

The registration function RegisterAppLayerGetActiveTxIdFunc allows for
registration of a custom function of type:
  uint64_t (*GetActiveTxIdFunc)(Flow *f, uint8_t flags);

If no function is called, AppLayerTransactionGetActiveDetectLog is used,
which implements the existing behaviour of considering both the
inspect_id's and the log_id.
12 years ago
Victor Julien c06c595c56 Clean up TX clean up
In AppLayerTransactionsCleanup instead of figuring out 'done' tx id's
itself, now call AppLayerTransactionGetActive for both directions to
figure out the completed TX id's.
12 years ago
Victor Julien 6e389a1fbb stream: don't send empty streammsg at stream end
No longer send an empty StreamMsg through the engine on stream end,
the messages were ignored anyway.
12 years ago
Victor Julien eb1f5ce358 stream: increase max StreamMsg data
Increase from 4024 bytes to 4072 to make the whole structure
4096 again.
12 years ago
Victor Julien c801ef3515 stream: remove flags from StreamMsg 12 years ago
Victor Julien 261881fce2 stream: remove per thread queue for stream msgs
StreamMsgs would be stored in a per thread queue before being
attached to the tcp ssn. This is unnecessary, so this patch
removes this queue and puts the smsgs into the ssn directly.

Large patch as it affects a lot of tests.
12 years ago
Victor Julien b159c1714c stream: remove flow reference from StreamMsg
StreamMsg' flow reference was used mostly to make sure a flow would
not get removed from the hash before inspection. For this it needed
to reference the flow use_cnt reference counter. Nowadays we have
more advanced flow timeout handling. This will make sure that if
there still are pending smsgs' in a flow, these will still be
processed.
12 years ago
Victor Julien 1d08a3ff26 stream: pass TcpSession to StreamTcpReassembleProcessAppLayer
Preparation for removing flow pointer from StreamMsg. Instead of
getting the ssn indirectly through StreamMsg->flow, we pass it
directly as all callers have it already.
12 years ago
Victor Julien 0ec375d95a stream msg: remove structure 12 years ago
Victor Julien 5ca0139cbc stream: remove unused gap structure from StreamMsg. 12 years ago
Victor Julien 3804f3f1b3 stream: no longer process STREAM_GAP smsgs
StreamSmgs are used for raw stream reassembly only. They could also
be used to tell the rest of the engine about sequence gaps. This was
a left over from the older implementation, where the app layer used
the smsgs as well.
12 years ago
Jason Ish 5850607fea Remove the old include support. 12 years ago
Ken Steele 3a9a14711a Correct coding style in decode-ethernet.c
This file is given as the example of correct coding style, so make sure it
follows the coding standard.
12 years ago
Eric Leblond 7561da4b87 debug: default logging level is notice
Update the string in message because default logging level is
now notice and not info.
12 years ago
Eric Leblond d6932f90db doxygen: document some functions 12 years ago
Eric Leblond e5e390a0c6 Add missing UNITTESTS
There is no need for test functions to be build in normal code.
12 years ago
Eric Leblond 98e4a14f6d af-packet: update packet reading loop logic
This patch updates the logic of the packet acquisition loop. When
the reader loop function is called and when the data to read
at offset is a without data (kernel) or still used by suricata. We
try to iter for a loop on the ring to try to find kernel put by
data.
As we are entering the function because the poll said there was some
data. This allow us to jump to the data added to the ring by the
kernel.
When using suricata in autofp mode, with multiple detect threads and
packet acquisition threads attached to a dedicated CPU, the reader
loop function was looping really fast because poll call was returning
immediatly because we did read the data available.
12 years ago
Eric Leblond 4d6b48ea9e htp layer: add memory cap counter
This patch adds a memcap counter for HTP memory usage. Counter
is increased each time an allocation is not done due to the memcap.
12 years ago
Eric Leblond d6d8a08a8f htp layer: add memory usage counter
This patch adds a memory counter for HTP memory usage. As
there is no thread variables available in application layer
the counter has been added to the TCP reassembly thread.
12 years ago
Eric Leblond ced01da822 htp layer: use memcap for HTTP related allocations
This patch introduces wrapper functions around allocation functions
to be able to have a global HTP memcap. A simple subsitution of
function was not enough because allocated size needed to be known
during freeing and reallocation.

The value of the memcap can be set in the YAML and is left by default
to unlimited (0) to avoid any surprise to users.
12 years ago
Ken Steele ba4758d033 Port unittest from bug #970 for util-mpm-ac.c to util-mpm-ac-tile.c
Passes on ac-tile too.
12 years ago
Ken Steele 326d5d3e15 Add 8-bit states to ac-tile
When running with sgh-mpm-context: full, many more MPMs are created
(16K) and many are small. If they have less than 128 states, they only
need 1 byte for the next state instead of 2 bytes, cutting the size of
the next-state table in half. This reduces total memory usage.

Since that makes 3 different state sizes (1, 2 and 4 bytes), rather
than going from 2 copies of the code to create the MPM to 3, I
factored out the code that fills the next-state table into three
functions so that all the other code could be the same.

The search function is now parameterize for 8-bit and 16-bit state
sizes and alphabet sizes 8, 16, 32, 64, 128 and 256.
12 years ago
Eric Leblond c115e63dc2 pfring: fix live device counter usage
Live device counter was in fact the number of packets seen by suricata
and not the total number of packet reported by pfring. This patch fixes
this by using counter provided by kernel instead.

Pfring kernel counter is per socket and is not cleared after read.
So to get the number of packet on the interface we can add the new
value for this thread and add it to the interface counter.
12 years ago
Eric Leblond 1869688fb8 af-packet: fix live device counter usage
Live device counter was in fact the number of packets seen by suricata
and not the total number of packet reported by kernel. This patch fixes
this by using counter provided by kernel instead.
The counter is Clear On Read, so by adding the value fetch at each call
and earch sockets we get the number of packets and drops for the
interface.
12 years ago
Eric Leblond afbb2eb32b capture: display exit stats at default verbosity
This patch updates capture modes not using LiveDecice counters
to display per-thread exit statistics with default verbosity.
12 years ago
Eric Leblond a8c787a265 device list: clean and display stat at exit
This patch adds a cleaning function to device list. This also
permits to display per-interface statistics during the exit.
12 years ago
Duarte Silva aa6b5b406d Fix the segmentation fault while logging the host on the custom HTTP logger.
- Seems to be a regression introduced in the commit
  796bfab231 (fix was already done in commit
  ee0b21652b)
- Doesn't happen with htplib v0.5.6, but it does in the latest, v0.5.9
12 years ago
Eric Leblond 8a5a30ba40 fix size_t printing
This two problem were found by the new version of the size_t cocci
test.
12 years ago
Victor Julien 446e68adca app-layer: only typedef opaque pointers once 12 years ago
Victor Julien 3b8e9ffbe9 app layer: void -> AppLayerProtoDetectThreadCtx
User AppLayerProtoDetectThreadCtx ptr instead of void.
12 years ago
Victor Julien 8dbf7a0d78 Update tests to use AppLayerParserThreadCtx ptr instead of void. Fix a few bugs uncovered by this. 12 years ago
Victor Julien 9634e60e7a app-layer: Use opaque pointers instead of void
For AppLayerThreadCtx, AppLayerParserState, AppLayerParserThreadCtx
and AppLayerProtoDetectThreadCtx, use opaque pointers instead of
void pointers.

AppLayerParserState is declared in flow.h as it's part of the Flow
structure.

AppLayerThreadCtx is declared in decode.h, as it's part of the
DecodeThreadVars structure.
12 years ago
Victor Julien c7ae662d26 Fix HTPBodyReassemblyTest01 Asan error
Fix improper pointer assignment in HTPBodyReassemblyTest01, causing
ASAN to error out.
12 years ago
Victor Julien fdefb65be4 app-layer: rename AppLayerThreadCtx funcs
AppLayerParserGetCtxThread -> AppLayerParserThreadCtxAlloc
AppLayerParserDestroyCtxThread -> AppLayerParserThreadCtxFree
12 years ago
Victor Julien 0bac43a1ca app layer: fix memory leak
Actually free the ctx in AppLayerParserDestroyCtxThread
12 years ago
Victor Julien f5f148805c app layer: uint16_t alproto -> AppProto alproto
This conversion was missing in a couple of places.
12 years ago
Victor Julien 5cdeadb33d Use u8 for ipproto
In a few places in app layer and unittests u16 was used.
12 years ago
Victor Julien 8527b8e08e App Layer: cleanup state func naming
Rename functions related to AppLayerState to be more consistent.
12 years ago
Victor Julien 30f16ee446 Rename AppLayerProtoDetectCtxThread -> AppLayerProtoDetectThreadCtx 12 years ago
Victor Julien cd0627cd39 Rename AppLayerParserParserState -> AppLayerParserState 12 years ago
Victor Julien c23742a0a7 Rename AppLayerParserpCtx -> AppLayerParserProtoCtx 12 years ago
Victor Julien 72a1645979 Rename AppLayerParserCtxThread -> AppLayerParserThreadCtx 12 years ago
Victor Julien ac77cd790f Rename AppLayerCtxThread -> AppLayerThreadCtx 12 years ago
Victor Julien e111401c10 detect unittests: clang build fix and cleanups
A number of unittests would lead to clang build errors because
of unsafe det_ctx ptr usage. This patch fixes these and inits
det_ctx to NULL in the other detect tests.
12 years ago
Victor Julien e2f7226569 App Layer: fix memory leaks
Call FlowCleanupAppLayer before setting f->proto to 0, as the former
bails out without doing anything if proto is 0.
12 years ago
Victor Julien 67053e6ed0 Fix AppLayerProtoDetectPMFreeSignature related valgrind errors 12 years ago
Victor Julien ff16d6fa53 app proto detect: fix valgrind test warnings
Only in unittests when debug is enabled would valgrind warn about
a print statement.
12 years ago
Victor Julien a456bd8181 Cleanup and fix scan-build warning
Add comments and slightly refactor to make function more understandable
and fix a scan-build warning too.
12 years ago
Victor Julien 8801585f10 scan-build fixes 12 years ago
Victor Julien 106e1c7d19 profiling: fix compilation
Stream engine can't access app layer proto detection datatypes
anymore, so moved some of the logic into app-layer.c
12 years ago
Victor Julien 1cbd1cdf36 compile fixes 12 years ago
Victor Julien 59327e0fd4 Various style fixes 12 years ago
Anoop Saldanha 429c6388f6 App layer API rewritten. The main files in question are:
app-layer.[ch], app-layer-detect-proto.[ch] and app-layer-parser.[ch].

Things addressed in this commit:
- Brings out a proper separation between protocol detection phase and the
  parser phase.
- The dns app layer now is registered such that we don't use "dnstcp" and
  "dnsudp" in the rules.  A user who previously wrote a rule like this -

  "alert dnstcp....." or
  "alert dnsudp....."

  would now have to use,

  alert dns (ipproto:tcp;) or
  alert udp (app-layer-protocol:dns;) or
  alert ip (ipproto:udp; app-layer-protocol:dns;)

  The same rules extend to other another such protocol, dcerpc.
- The app layer parser api now takes in the ipproto while registering
  callbacks.
- The app inspection/detection engine also takes an ipproto.
- All app layer parser functions now take direction as STREAM_TOSERVER or
  STREAM_TOCLIENT, as opposed to 0 or 1, which was taken by some of the
  functions.
- FlowInitialize() and FlowRecycle() now resets proto to 0.  This is
  needed by unittests, which would try to clean the flow, and that would
  call the api, AppLayerParserCleanupParserState(), which would try to
  clean the app state, but the app layer now needs an ipproto to figure
  out which api to internally call to clean the state, and if the ipproto
  is 0, it would return without trying to clean the state.
- A lot of unittests are now updated where if they are using a flow and
  they need to use the app layer, we would set a flow ipproto.
- The "app-layer" section in the yaml conf has also been updated as well.
12 years ago
Anoop Saldanha 127ef8f903 Use a typdef AppProto <-> uint16_t for representing app layer protocol.
Some minor refactoring/cleanup, including renaming functions.
12 years ago
Anoop Saldanha abded4200a Disabling the ssh parser temporarily, since we are moving away from some
of the archaic features we use in the app layer. We will reintroduce this
parser shortly. Also do note that keywords that rely on the ssh parser
would now be disabled.
12 years ago
Victor Julien b955ca7b86 conf: fix potential use-after-free on error
Coverity 1139544

If strdup would fail, 'node' was freed but it wasn't set to NULL. The
code then returned node. The caller would not detect there was an error
and use the freed pointer.
12 years ago
Victor Julien 3714925d2b stream: fix potential memory loss on error
Coverity 1139543.

If StreamTcpPseudoPacket would be called with len == 0, the packet
it acquired before checking the len value would be lost.
12 years ago
Victor Julien 1cce207c05 Revert TmqhFlowMode alignment as it breaks on CLANG 12 years ago
Victor Julien 9874c1a83b realloc error handling: remove unnecessary else branch 12 years ago
Eric Leblond 1f07d1521e Fix realloc error handling
This patch is fixing realloc error handling. In case of a realloc
failure, it free the initial memory and continue existing error
handling.

The patch has been obtained via the following semantic patch and
a bit oh hand editing:

@@
expression x, E;
identifier f;
@@

f(...)
{
+ void *ptmp;
<+...
- x = SCRealloc(x, E);
+ ptmp = SCRealloc(x, E);
... when != x
- if (x == NULL)
+ if (ptmp == NULL)
{
+ SCFree(x);
+ x = NULL;
...
- }
+ } else {
+     x = ptmp;
+ }
...+>
}

@@
expression x, E;
identifier f;
statement ES;
@@

f(...) {
+ void *ptmp;

<+...
- x = SCRealloc(x, E);
+ ptmp = SCRealloc(x, E);
... when != x
- if (x == NULL) ES
+ if (ptmp == NULL) {
+ SCFree(x);
+ x = NULL;
+ ES
+ } else {
+     x = ptmp;
+ }
...+>

}

@@
expression x, E;
identifier f;
@@

f(...)
{
+ void *ptmp;
<+...
- x = SCRealloc(x, E);
+ ptmp = SCRealloc(x, E);
... when != x
- if (unlikely(x == NULL))
+ if (unlikely(ptmp == NULL))
{
+ SCFree(x);
+ x = NULL;
...
- }
+ } else {
+     x = ptmp;
+ }
...+>
}

@@
expression x, E;
identifier f;
statement ES;
@@

f(...) {
+ void *ptmp;

<+...
- x = SCRealloc(x, E);
+ ptmp = SCRealloc(x, E);
... when != x
- if (unlikely(x == NULL)) ES
+ if (unlikely(ptmp == NULL)) {
+ SCFree(x);
+ x = NULL;
+ ES
+ } else {
+     x = ptmp;
+ }
...+>

}
12 years ago
Victor Julien 5e1f1ee4ff Fix filemagic unittests on OS_DARWIN 12 years ago
Ken Steele d12834769a Add const for Packet * in flow functions.
By moving FlowReference() out of FlowGetFlowFromHash() and into the one
function that calls it, all the flow functions take const Packet * instead
of Packet *.
12 years ago
Giuseppe Longo 8ba0fa7f92 defrag-config: fix a bug
A ptr to local var is stored in the radix tree currently,
this patch permits to alloc space to store host timeout
and thus also free it when data is removed.
12 years ago
Victor Julien de22d6cf02 defrag: fix compiler warning
defrag-config.c: In function 'DefragParseParameters':
defrag-config.c:105: warning: passing argument 2 of 'DefragPolicyAddHostInfo' from incompatible pointer type
make[3]: *** [defrag-config.o] Error 1
12 years ago
Victor Julien 2913a4a860 debug: fix realloc error checking on flowbit print
detect.c:1074:17: warning: Potential leak of memory pointed to by \
                                field 'debuglog_flowbits_names'
                return;

Bug #1062.
12 years ago
Victor Julien b605ee6fb2 DER decoding: fix potential memory leak
This would only happen in memory failure conditions.

util-decode-der.c:634:27: warning: Potential leak of memory pointed to by 'child'
    return (Asn1Generic *)node;
12 years ago
Victor Julien 2f094ca136 detect-ssl: suppress harmless scan-build warning
detect-ssl-version.c:271:17: warning: Value stored to 'neg' is never read
                neg = 0;
12 years ago
Victor Julien 1252ee3f04 stream: suppress minor scan-build warnings
stream-tcp-reassemble.c:2569:17: warning: Value stored to 'seg' is never read
                seg = seg->next;
                ^     ~~~~~~~~~
stream-tcp-reassemble.c:2587:17: warning: Value stored to 'seg' is never read
                seg = seg->next;
12 years ago
Victor Julien 9d092f35e2 dns: suppress minor scan-build warnings
These were only used if debug is enabled.

app-layer-dns-tcp.c:407:13: warning: Value stored to 'length' is never read
            length = *data;
app-layer-dns-udp.c:236:13: warning: Value stored to 'length' is never read
            length = *data;
12 years ago
Victor Julien 6ac30ae468 dns: suppress harmless cppcheck warning
[src/app-layer-dns-common.c:273]: (warning) Assignment of function \
                        parameter has no effect outside the function.
12 years ago
Victor Julien 66c6c06916 http: clear header pointer on realloc failure
Fixes:

detect-engine-hhd.c:188:5: warning: Use of memory after it is freed
    return headers_buffer;
12 years ago
Victor Julien 7ea13f0f53 dns: fix passing NULL to memcpy
app-layer-dns-common.c:401:5: warning: Null pointer passed as \
                              an argument to a 'nonnull' parameter
    memcpy(ptr, fqdn, fqdn_len);
12 years ago
Victor Julien 6709fdd8cf log-http: fix compiler warning
log-httplog.c:180: warning: 'cvalue' may be used uninitialized in \
this function
12 years ago
Victor Julien 31a94cd4cb defrag: pass u64 to ParseU64
Fixes: defrag-config.c:97: warning: passing argument 2 \
       of 'ParseSizeStringU64' from incompatible pointer type
12 years ago
Ken Steele 12ab6f3ab4 Fix uninitialized variable warning.
These two lines reported warnings with -Werror -O3 on Tile.
12 years ago
Ken Steele 882d98733f Fix pfring so that zero-copy mode can work.
Detect when default_packet_size is zero, which enables zero-copy mode for
pfring and in that case, do what AF Packet does and set pkt_ext pointer to
the data and set PKT_ZERO_COPY flag.
12 years ago
Ken Steele f9705377ae Remove pkt variable from Packet structure.
The uint8_t *pkt in the Packet structure always points to the memory
immediately following the Packet structure. It is better to simply
calculate that value every time than store the 8 byte pointer.
12 years ago
Ken Steele 3870def601 Split AC-Tile MPM context into Search and Initialization structures.
Some of the fields in the SCACTileCtx struct are only used to create the MPM,
but are not needed to search the MPM. Create a new structure to contain just
the data needed by AC Search. After creating the MPM, copy the data into the
new structure and then free the memory only needed during initialization.

This reduces the size of the AC-Tile MPM context from 1360 bytes down to 296
bytes.
12 years ago
Victor Julien b61552482c mpipe code cleanup: indent fixes 12 years ago
Ken Steele 300b739b1f Add more suricata.yaml configuration options for mPIPE.
Add two new mPIPE load-balancing configuration options in suricata.yaml.
1) "sticky" which keep sending flows to one CPU, but if that queue is full,
don't drop the packet, move the flow to the least loaded queue.
2) Round-robin, which always picks the least full input queue for each
packet.

Allow configuring the number of packets in the input queue (iqueue) in
suricata.yaml.

For the mPipe.buckets configuration, which must be a power of 2, round
up to the next power of two, rather than report an error.

Added mpipe.min-buckets, which defaults to 256, so if the requested number
of buckets can't be allocated, Suricata will keep dividing by 2 until either
it succeeds in allocating buckets, or reaches the minimum number of buckets
and fails.
12 years ago
Ken Steele 5a1bc025e5 Mark pflow as a constant pointer.
Address review comment from Victor that the pflow pointer is constant, so
it can be marked as such.
12 years ago
Ken Steele bee24d8909 Use pflow variable in place of p->flow to prevent reloading.
In SigMatchSignatures, the value p->flow doens't change, but GCC can't
figure that out, so it reloads p->flow many times during the function.
When p->flow is loaded into the variable pflow once at the start of the
function, the compile then doesn't need to reload it.
12 years ago
Eric Leblond 58eb6428d1 suricata: ignore SIGHUP signal
This patch ignores the SIGHUP signal instead of having the default
behavior.
12 years ago
Victor Julien 4fdd1a7a71 Fix compilation on systems that use the fallback SC_ATOMIC_ API. 12 years ago
Eric Leblond 28c5c68192 error checking: add missing alloc error treatment
The return of some malloc like functions was not treated in some
places of the code.
12 years ago
Victor Julien f6e37dcc90 Bug 1061: fix multiple vars per sig in ordering
In sigordering rules that had multiple vars doing the same operation,
like setting multiple flowbits, would not be considered correctly.

Bug 1061.
12 years ago
Victor Julien b770fd2981 http header: improve realloc failure checking. Bug #1062. 12 years ago
Victor Julien 90cf8d4c6e port parsing: improve memory handling 12 years ago
Victor Julien b79b2fff25 cppcheck: add special BUG_ON so cppcheck understands we exit 12 years ago
Victor Julien d5db0cc033 port: don't lead memory on port parsing failure
[src/detect-engine-port.c:1354]: (error) Memory leak: gh
12 years ago
Victor Julien 435f99409f Fix small memleak in runmode setup
[src/runmodes.c:338]: (error) Memory leak: custom_mode
12 years ago
Victor Julien 86aad660a2 threading setup: fix small mem leak on failure
[src/tm-threads.c:1058]: (error) Memory leak: slot
12 years ago
Victor Julien b4631794a8 Fix realloc error handling in threshold.config file parsing. Bug #1062. 12 years ago
Victor Julien 35298a0146 Use %u for unsigned int in (console) output 12 years ago
Victor Julien a9d754c23d Use %u for unsigned ints in checksum warning 12 years ago
Victor Julien 76d3cb557b htp: minor cleanup to silence cppcheck warning
[src/app-layer-htp.c:1967] -> [src/app-layer-htp.c:1978]: (warning) \
    Possible null pointer dereference: tx - otherwise it is redundant \
    to check it against null.
12 years ago
Victor Julien 5ba898b738 cppcheck: don't use likely/unlikely when -DCPPCHECK is passed to the checker 12 years ago
Victor Julien b2c4a50e39 Fix small memory leak in classtype parsing 12 years ago
Victor Julien fe46c26e4e cppcheck: improve reporting cppcheck when passing -DCPPCHECK to the checker. 12 years ago
Victor Julien afb48cfcb5 log-http: fix error check leading to null-deref on malloc failure during setup 12 years ago
Victor Julien 4165bf8951 log-http: enforce hostname print limit 12 years ago
Victor Julien 1476db44d9 Convert Flow macros to inline functions
Convert FlowReference and FlowDeReference to inline functions for
better readability and to aid static code analyzers.
12 years ago
Victor Julien b4e6bbe4bc flowvar: initialize new memory to prevent issues on error handling 12 years ago
Victor Julien 0beb7ed781 pcap: fix stats dump logic
pcap has a callback function that is called for each packet. Once a
second, it's meant to 'dump stats'. However, the timing logic was
broken, so it would actually dump stats for each packet.

By moving the stats second timer into the thread vars, next calls of
the callback will be able to use the stored time.
12 years ago
Victor Julien 9e85b8d35e flow timeout: remove now unused code 12 years ago
Victor Julien 85b1a8ff26 flow: fix typo in function name
FlowForceReassemblyNeedReassmbly -> FlowForceReassemblyNeedReassembly
12 years ago
Victor Julien 3b3dce8328 flow timeout cleanup and fix
Flow timeout code worked by luck when checking if a flow still needed
reassembly for app layer inspection or logging. It would check for a
part of raw reassembly (smsg list) to determine if detection was
needed. In this case it would also process app layer cleanup,
including logging.

Introduced AppLayerTransactionGetActive which returns the lowest tx_id
in a direction that still needs some work.

FlowForceReassemblyNeedReassmbly now uses it to determine if the
applayer still needs work.

Converted FlowForceReassemblyForHash to use the checking function
FlowForceReassemblyNeedReassmbly as well, so that checking if a flow
needs work is now unified.
12 years ago
Victor Julien b32abea06b flow/stream: use named values in flow timeout code 12 years ago
Victor Julien 8522da8ea5 stream: add option to disable raw reassembly
Raw reassembly is used only by the detection engine. For users only
caring about logging it's a significant overhead, both in cpu and
memory usage.

The option is called 'raw' and lives under the stream.reassembly
options.

stream:
  memcap: 32mb
  checksum-validation: yes      # reject wrong csums
  inline: auto                  # auto will use inline mode in IPS mode, yes or no set it statically
  reassembly:
    memcap: 64mb
    depth: 1mb                  # reassemble 1mb into a stream
    toserver-chunk-size: 2560
    toclient-chunk-size: 2560
    randomize-chunk-size: yes
    #randomize-chunk-range: 10
    raw: false # <- new option
12 years ago
Eric Leblond 47b5fc0934 erf-dag: fix typo in header guard
Spotted out by clang:
 source-erf-dag.h|25 col 9| warning: '__SOURCE_ERR_DAG_H__'
 is used as a header guard here, followed by #define of a different macro
 [-Wheader-guard]
12 years ago
Jason Ish eaff01a57f Use the stack for temporary memory buffers. 12 years ago
Jason Ish ab7091927e When setting final configuration nodes, set the whole tree as final.
Prevents benign log message of parent nodes of final values being
redefined (which ends up having no affect as the final nodes
are protected from being removed).
12 years ago
Eric Leblond 729540673e htp: display info about randomization
When randomizatin is used display a message about actual values.
12 years ago
Eric Leblond ff784075a2 htp: randomization of htp inspection sizes
This is an implementation of #940. It randomize libhtp request
and response size if the same way this has been done for stream
inspection.
12 years ago
Victor Julien 81ee6f5aad lua: push correct length back through ScFlowvarGet, work around valgrind warning 12 years ago
Victor Julien 86b299d06c lua: clear stack after each script run 12 years ago
Victor Julien ae69a4a024 luajit: pass calling rule's sid,gid,rev to script as SCRuleSid, SCRuleGid, SCRuleRev. 12 years ago
Eric Leblond f76448c1e6 decode: fix failure in layered tunnel
If we have multiple layer of tunnel, the decoding of initial
Packet will recurse in DecodeTunnel function called in
PacketTunnelPktSetup. If we are not setting the pseudo
packet root before calling DecodeTunnel (as done in previous
code), then the tunnel root will no be correct for the lower
layer packets. This result in an counter problem and a suricata
failure after some time.
12 years ago
Jason Ish e9a4871077 Fix alignment in usage. 12 years ago
Giuseppe Longo ae9393987e Adds a defrag configuration example in suricata.yaml 12 years ago
Victor Julien 0a24ac0855 Fix Conf api usage after rebase 12 years ago
Jason Ish 8d29dfca59 Instead of exiting on memory failure, log a warning then return NULL
to signify an error to the caller.
12 years ago
Jason Ish 5f6705c4dc Better document ConfSet and ConfSetFinal. 12 years ago
Jason Ish b033acfb0c Subsequent configuration keys now override previous ones
instead of merging.

The exception is final values, for example, values like
default-log-dir that may be set on the command line.
12 years ago
Jason Ish c981a16579 Function to prune all non-final nodes from a configuration node. 12 years ago
Jason Ish b8e13d4bd6 More concise API for setting config values that
can be overrided or not (final values).
12 years ago
Jason Ish 0820ac9355 Cleanup ConfSet, ConfGet, make more concise.
Removes ifdef's for readability by using strchr instead
of strtok.
12 years ago
Victor Julien 6cd6caf3ea tls: allow matching for @ symbol in tls.subject
Also in tls.issuerdn keyword.

Original patch by Chris Wakelin.

Fixes #1042.
12 years ago
Anoop Saldanha 6ea8ac44ff FTP parser updated to not use the archaic App layer feature of AppLayerParserResultElmt.
The parser otherwise remains pretty much the same.
12 years ago
Anoop Saldanha 80c08f8642 Updated the ftp response handler to return without doing anything.
Currently the processing happening inside the handler is not being used
anywhere else in the engine.
12 years ago
Anoop Saldanha 8523cbadcf Restructured flow_proto mapping enums.
Moved FLOW_PROTO_DEFAULT down the enum list.
12 years ago
Anoop Saldanha a49cbf8a49 Code cleanup.
Use the MpmAddPattern[CS|CI] wrapper to add patterns to the mpm context.

Also use MpmInitCtx() to init the mpm context.
12 years ago
Anoop Saldanha 9c0456ebbe Removed unused function MpmMatcherGetMaxPatternLength. 12 years ago
Victor Julien cc61a190ce Reduce allocs in boyer moore prepare phase 12 years ago
Victor Julien 8344854a1f Don't alloc for hash lookup in SCClassConfGetClasstype 12 years ago
Victor Julien f04618c7ad Don't malloc temp var in SCRuleVarsGetConfVar 12 years ago
Victor Julien 941d5a1081 Don't use strdup in ip-only address parsing 12 years ago
Victor Julien a7a77e32ca Convert classtype keyword to pcre_copy_substring 12 years ago
Victor Julien 4dd605ae3b Convert reference keyword to pcre_copy_substring 12 years ago
Victor Julien 3f8947ff3d app layer: set event if proto detect disabled for a stream, but we see data anyway. 12 years ago
Victor Julien 7074ca373b proto detection: add limit for one sided sessions
If a session only has data in one direction, like ftp data sessions,
protocol detection will only run in one direction. This led to a
situation where reassembly would hold all the segments as proto
detection was never flagged as complete.

This patch introduces a limit for protocol detection in this case.
If the limit is reached, detection will give up.
12 years ago
Victor Julien abccbe13f3 stream: add size debug code 12 years ago
Victor Julien daedb6c557 stream: wait for protocol detection to complete
Wait for protocol detection to complete before removing segments
from the list.
12 years ago
Eric Leblond 0460b194b1 decode: clean DecodeThreadVars counter
Speed counters are not compute anymore and can be removed from the
structure definition.
12 years ago
Eric Leblond 1bdc39fe9b cmdline: add -k to specify checksum validation
This patch adds a '-k' option to suricata to be able to specify
the checksum validation to use. If '-k all' is used, checksum
validation is forced. If '-k none' is used, no checksum validation
is made.

Message output in case of detection of a pcap file with a probable
cheksum issue has been updated to indicate that '-k' is a solution.
12 years ago
Eric Leblond 8b5be26f49 pcap-file: add checksum-checks configuration variable
This patch adds support for checksum-checks in the pcap-file running
mode. This is the same functionnality as the one already existing for
live interface.

It can be setup in the YAML:
  pcap-file:
    checksum-checks: auto

A message is displayed for small pcap to warn that invalid checksum
rate is big on the pcap file and that checksum-check could
be set to no.
12 years ago
Eric Leblond b2c58b8d14 Set packet invalid flag during decoding.
This patch set a new value in pkt->flag to signal that a packet is
invalid during decoding. The patch has been obtained via a coccinelle
transformation.
12 years ago
Eric Leblond 3088b6ac34 Add invalid pkt counter.
This patch adds and increments a invalid packet counter. It
does this by introducing PacketDecodeFinalize function

This function is incrementing the invalid counter and is also
signalling the packet to CUDA.
12 years ago
Victor Julien 92568c3857 Fix parsing of 'custom' detect grouping values
Also, add error checking

Bug 892
12 years ago
Victor Julien ffe4a302a1 vars: optimize layout to reduce size requirements of flowbits and other vars 12 years ago
Victor Julien 3e604b8703 pcre: parsing cleanup
Remove all flags indicating the buffer type. They were only used
at parse time.

Because of this the DetectPcreData_ structure could shrink to 32
bytes.
12 years ago
Victor Julien ab22385083 stream: minor clean up of TcpSession structure 12 years ago
Victor Julien 866b3a1c5d content: reorder DetectContentData member, shrinking the struct from 64 to 48 bytes. 12 years ago
Victor Julien 277fb61c1d defrag: clean up
Rename PacketDefragPktFinishSetup to PacketDefragPktSetupParent to
better refect it's function.
12 years ago
Eric Leblond 3fdf52239d defrag: don't modify packet if defrag fails
If defrag fails dur to an invalid decoding, we are not modifying
the origin packet anymore.
12 years ago
Eric Leblond c611b258a5 decode: PacketTunnelPktSetup replaces PacketPseudoPktSetup
This patch replaces PacketPseudoPktSetup by a better named
PacketTunnelPktSetup function which is also in charge of doing
the decoding of the tunneled packet.
This allow to clean the code. But it also fixes an issue.
Previously, if the DecodeTunnel function was failling (cause of
an invalid packet mainly), the result was that the original packet
to be considered as a tunnel packet (and not inspected by payload
detection).
12 years ago
Eric Leblond d4b7ecfbe3 decode: update API to return error
In some cases, the decoding is not possible and some really invalid
packet can be created. This is in particular the case of tunnel. In
that case, it is more interesting to forget about the tunneled
packet and only consider the original packet.

DecodeTunnel function is maked as warn_unused_result because it is
meaningful for the decoder to know if the underlying data were not
correct. And in this case, only focus detection on the content.
12 years ago
Victor Julien 0b0e9340dc rule setup: cleanup
Remove rule preparation logic that ran, but it's results were not
used.
12 years ago
Victor Julien 2be6829986 Convert dsize keyword parsing to use pcre_copy_substring 12 years ago
Victor Julien dcc75acdec Convert pcre keyword parsing to use pcre_copy_substring 12 years ago
Victor Julien 1f69da80bf rule parser: convert to use pcre_copy_string 12 years ago
Victor Julien d397ed94c5 detect: use macro for max rule size 12 years ago
Victor Julien 9d35855a95 Convert flowbits keyword parsing to use pcre_copy_substring 12 years ago
Victor Julien beab8d401c Convert flow keyword parsing to use pcre_copy_substring 12 years ago
Victor Julien 223fedb8fe Convert ParseSizeString to use pcre_copy_substring 12 years ago
Victor Julien 3f4ce6dadd rule parser: don't use uninitialized value 12 years ago
Giuseppe Longo f03278d132 feature #417: add support for configuration per host timeout value 12 years ago
Victor Julien 54610cb4a4 rule parsing cleanups
Clean up usage of array of pointers to the various parts of a rule.
12 years ago
Victor Julien 67989e7e4e rule parsing: reduce mallocs and clean up
Reduce mallocs during rule parsing. Also, no longer recursively
call the option parse function.
12 years ago
Victor Julien 2ce8895f0a address and port: reduce memory allocs 12 years ago
Jason Ish 06f4fe8e0c Remove the single line if statements. 12 years ago
Jason Ish 8625c9eba8 Support for configuration include files. 12 years ago
Victor Julien e7f6107e79 signature address parsing improvements and tests
Fix sigatures not supporting [10.0.0.0/24, !10.1.1.1] notation when
used directly in a rule instead of through a variable.

Add tests for Bugs #815 and #920.
12 years ago
Victor Julien 3521c37d4a http: use body limit in inspection
When inspecting HTTP bodies there are several limits involved.
In this patch the reaching of the body limit will trigger body
inspection.

Without this, the body would only be inspected when inspection
limits "request-body-minimal-inspect-size" or
"response-body-minimal-inspect-size" were reached. If the body
limit was smaller than this value, the body would only be
inspected at the end of the tx or stream.
12 years ago
Victor Julien 493d531ae8 Fix using uninitialized memory (Bug #994) 12 years ago
Eric Leblond 9bbcc8671e util-ioctl: ioctl error should be a warning 12 years ago
Eric Leblond 286258df86 pcap: add warning about GRO and LRO usage
Use the new GetIfaceOffloading function to display a warning message
if pcap capture is used on Linux with GRO or LRO activated. This is
helpful for kernel after 2.6.31 were pcap will use mmaped capture.
TPACKET_V2 is used and this limit the size of the packet resulting
in truncated packets when merged packets are received.
12 years ago
Eric Leblond 2855ee5aef af-packet: add warning message if LRO or GRO are set
This patch query the network interface to detect if LRO or GRO are
used in mmap TPACKET_V2 mode.
12 years ago
Eric Leblond fcc8759561 util-ioctl: add GRO/LRO detection capabilities
This patch adds a new function GetIfaceOffloading which return 0
if LRO and GRO are not set on a interface and 1 if not the case.
12 years ago
Eric Leblond 008ed41cb4 util-ioctl: minor code cleaning.
Fix author e-mail and simplify an indentation.
12 years ago
Eric Leblond 853732210e pfring: improve error reporting at device opening
This patch improves the error message displayed if pfring_open fails.
12 years ago
Victor Julien 5330b1cae1 detect: don't consider smsgs for no inspect flag
When the PKT_NOPAYLOAD_INSPECTION flag is set, don't apply it to smsgs.
This way we can still inspect the outstanding smsgs.

The PKT_NOPAYLOAD_INSPECTION is set for encrypted traffic, and is combined
with disabling stream reassembly. So we only inspect the smsgs up to the
point of the disable detection point.
12 years ago
Victor Julien ab7677638e stream: improve raw reassembly
When checking the reassembly limit for raw reassembly, consider the
STREAMTCP_STREAM_FLAG_NOREASSEMBLY a trigger immediately. We won't
process any more segments in the reassembly engine anyway.
12 years ago
Victor Julien e392c0a4ce Fix autofp flow queue handler optimization 12 years ago
Victor Julien 480fddd189 build-info: add a nicer way of printing atomics support 12 years ago
Victor Julien ce120d4927 flow: aligned flow balance structures (used by autofp) to CLS to reduce false sharing 12 years ago
Victor Julien fb4967912c http: add meta-field-limit option
The meta-field-option allows for setting the hard limit of request
and response fields in HTTP. In requests this applies to the request
line and headers, not the body. In responses, this applies to the
response line and headers, not the body.

Libhtp uses a default limit of 18k. If this is reached an event is
raised.

Ticket 986.
12 years ago
Victor Julien 2ec57c36b4 SSE 4.2 memcmp: don't read beyond var boundary
In the SSE 4.2 SCMemcmpLowercase implementation, there would be a
_mm_load_si128 of a 2 byte array. However, _mm_load_si128 loads
16 bytes, causing it to read beyond the var. I don't think this lead
to crashes, as it was a static var, but clangs ASAN complained about
it.
12 years ago
Ken Steele d3c6913e28 Reduce the size of Packet structure
Share memory space for IPV4Vars and (IPV6Vars, IPV6ExtHdrs), since a
packet can only be either IPv4 or IPv6, but not both.

Share memory for TCPVars, UDPVars, ICMPV4Vars and ICMPV6Vars, since a
packet can only be only of these.

Then move other structure members around to remove holes reported by pahole.

This reduces the size of the Packet structure from 2944 bytes (46 cachelines)
down to 1976 (31 cachelines), a 33% reduction.
12 years ago
Victor Julien a8b971c710 http: strip 'proxy' part of http_uri
Strip the 'proxy' parts from the normalized uri as inspected by http_uri,
urilen, pcre /U and others.

  In a request line like:
    GET http://suricata-ids.org/blah/ HTTP/1.1
  the normalized URI will now be:
    /blah/

This doesn't affect http_raw_uri. So matching the hostname, etc is still
possible through this keyword.

Additionally, a new per HTTP 'personality' option was added to change
this behavior: "uri-include-all":

  uri-include-all: <true|false>
    Include all parts of the URI. By default the
    'scheme', username/password, hostname and port
    are excluded. Setting this option to true adds
    all of them to the normalized uri as inspected
    by http_uri, urilen, pcre with /U and the other
    keywords that inspect the normalized uri.
    Note that this does not affect http_raw_uri.

So adding uri-include-all:true to all personalities in the yaml will
restore the old default behavior.

Ticket 1008.
12 years ago
Ken Steele de6cbb01c8 Allocate mPIPE packet ingress queue in each worker thread.
Move the allocation of the mPipe ingress queue from a loop over
the number of workers in the main init function to being done inside
each worker thread. This allows allocating the memory locally on the
worker's CPU without needing to figure out ahead of time where that thread
will be running. This fixes one case of static mapping of workers to CPUs.

Use __thread to hold the queue rather than a global tables of queues.
12 years ago
Ken Steele 601c7c8e3c Cleanup Tile build for -Werror
Just the changes needed for the Tile architecture to compile cleanly with
-Werror.
12 years ago
Ken Steele f16b339fc4 Rename checksums to level3_comp_csum and level4_comp_csum.
This will also sharing even more memory in the Packet_ structure.
12 years ago
Eric Leblond 3dceca70ee suricata: move some code into PostConfLoadedSetup
All functions before daemonization are initialisation functions and thus the
call can be moved in PostConfLoadedSetup.
12 years ago
Victor Julien a84c502e50 Add SSE support to --build-info 12 years ago
Victor Julien 49a54713da memcmp: don't use SSE intrinsics if less that 16 bytes are available in SSE_4_2 version. 12 years ago
Victor Julien 8ffa30dd88 profiling: don't init rule profiling ctx if rule profiling is disabled 12 years ago
Victor Julien 660636c5bc profiling: when config is missing, keyword profiling is disabled 12 years ago
Victor Julien 2982408155 pcap: register counters for old pcap versions as well 12 years ago
Victor Julien 9a42f621f5 Fix pcre_study error check
pcre_study returning NULL is not necessarily an error, from the man page
pcre_study(3):

  "If the function returns NULL, either it could not find any additional
   information, or there was an error. You can tell the difference by
   looking at the error value. It is NULL in first case."

Older libpcre versions would return NULL, causing errors.
12 years ago
Ken Steele c6a8d0ab6b Share Packet checksum values for TCP, UDP, IPv6. ICMPv4 and ICMPv6
Keep a separate checksum for IPV4, since a packet can have both an IPV4
checksum and a TCPV4 checksum, or IPV4 and UDPV4 checksum.

This will allow future sharing of more values.

Use PACKET_RESET_CHECKSUMS() in Unit Tests in place of setting the
individual checksum values.
12 years ago
Ken Steele 27caa8aea7 Add missing case for DNS_CONFIG
Found compiling with -Werror
12 years ago
Victor Julien 36bc8d5cd0 http & tls: fix transaction handling
When http and/or tls logging is disabled, the app layer would still
be flagged as logging. This caused transactions not to be freed until
the end of the flow as the logged tx id would never increment.

This fix postpones the setting of the app layer parser "logger"
flag to the point where we know the logger is enabled.
12 years ago
Victor Julien bee5ff172b dns: fix transaction handling
When logging is disabled, the app layer would still be flagged
as logging. This caused transactions not to be freed until the
end of the flow as the logged tx id would never increment.

This fix postpones the setting of the app layer parser "logger"
flag to the point where we know the logger is enabled.
12 years ago
Victor Julien 6730f3d5cc DNS: trigger logging for toserver dir when previous reply is lost. 12 years ago
Victor Julien 61cdd9be6b dns: detect case of request flooding
In the case where DNS requests are sent over the same flow w/o a
reply being received, we now set an event in the flow and refuse
to add more transactions to the state. This protects the DNS
handling from getting overloaded slowing down everything.

A new option to configure this behaviour was added:

app-layer:
  protocols:
    dnsudp:
       enabled: yes
       detection-ports:
         udp:
           toserver: 53
       request-flood: 750

The request-flood parameter can be 0 (disabling this feature) or a
positive integer. It defaults to 500.

This means that if 500 unreplied requests are seen in a row an event
is set. Rule 2240007 was added to dns-events.rules to match on this.
12 years ago
Ken Steele c1b9f0e1f4 Formatting and comment updates in flow files
Some reformatting to meet coding standards.

Added a few comments to make it more clear where p->flow gets set.
12 years ago
Victor Julien 72a147b6f1 detect: only inspect smsg for valid tcp packets
Packets that are rejected by the stream engine are not considered
part of an established tcp session. By allowing them to inspect
an smsg, some smsgs would not be properly inspected.
12 years ago
Ken Steele dfc2117e80 Add Unit test to check TCPv4 and IPV4 checksums together.
Copied SigTest26TCPV4Keyword and added check for invalid IPV4 checksums.
Created new SigTest26TCPV4AndIPV4Keyword test with a new packet with valid
IPV4 checksums.
12 years ago
Victor Julien 0c12ad6bd0 stream: fix sequence number on smsg
When multiple segments were put into a smsg, the seq would be updated
each time a segment was added. Because of this, the seq wasn't pointing
to the start of the data.

This caused some false negatives when the fast_pattern was in the raw
stream, but another part of the inspection was in the state. Because of
the wrong seq, the inspection of the smsg could be delayed. This in turn,
could make the inspection engine consider a TX inspected, even if it wasn't
fully yet.
12 years ago
Ken Steele 86c6861b40 Give Suricata priority to receive packets over Linux with mPIPE.
When installing the rules to tell mPIPE to send packet to Suricata,
give it a higher priority than the default used by Linux. This way if
Linux also tells mPIPE to send it packets, Suricata will get them
instead, as long as Suricata is running.
12 years ago
Victor Julien 9a7353e148 http: don't decode + to space by default
Libhtp decodes the + character in the query string to a space by default.
Suricata rules (e.g. etpro sid 2806767) are expecting to see the space in
the http_uri buffer.

Added an option per htp config to reenable this default behavior:

    query-plusspace-decode: yes

Bug #1035.
12 years ago
Victor Julien 25636597af Fix live rule reload confusing delayed detect
Fixes bug 1023 and the previous attempt to fix it.
12 years ago
Victor Julien 5906eeb8c8 detect: don't do rule reload during delayed detect
When both rule reloads and delayed detect are enabled, make sure we don't
trigger a reload during delayed detect initialization.

Bug #1023.
12 years ago
Victor Julien 7b687da726 profiling: add tracking of missing keywords 12 years ago
Victor Julien 5686c673ec profiling: per buffer profiling 12 years ago
Victor Julien 9419b9cbb6 detect: add tostring function for DETECT_SM_LIST_ enum. 12 years ago
Victor Julien 97bfcac444 profiling: introduce per keyword profiling
Initial version of per keyword profiling. Prints stats about
how ofter a keyword was checked and what the costs were.
12 years ago
Victor Julien 210eede033 content inspection: introduce no_match label 12 years ago
Victor Julien e416b2cdfb stream: fix IPv6 pseudo packet setup
Bug #1022: IPv6 pseudo packet setup using reverse logic of IPv4.
12 years ago
Victor Julien ef17b7b9f4 stream: reduce scope of StreamTcpPseudoPacketSetupHeader 12 years ago
Victor Julien ce4d262c7d IPv4 decoder compile warning fix 12 years ago
Victor Julien 07c97412f3 DNS: fix response name length logic
In some cases where the length would be calculated as 0 we'd loop until
we'd hit our loop limit.

Update name logic everywhere.
12 years ago
Anoop Saldanha 95ed53c590 Fix for #1003.
Now that we call stream reassembly directly from proto detection, we will
need to check if reassembly has been disabled inside the stream reassembly
callback.

This prevents any calls to bypass and re-enter proto detection, despite
having reassembly disabled.
12 years ago
Victor Julien 7ebd1e6433 Counters: fix delayed-detect counter registration
Make sure we register the detect.alerts counter before packet runtime starts
even in delayed detect mode. The registration of new counters at packet
runtime is not supported by the counters api and might lead to crashes as there
is no proper locking to allow for this operation.

This changes how delayed detect works a bit. Now we call the ThreadInit
callback twice. The first call will only register the counter. The 2nd call
will do all the other setup. This way the counter is registered before the
counters api starts operating in the packet runtime.

Fixes the segv reported in ticket #1018.
12 years ago
Victor Julien 9e88c51e24 Counters: move perf critical var to the top of the SCPerfContext struct 12 years ago
Victor Julien ed03196a20 Counter: fix accidental logic change 12 years ago
Victor Julien 45dfecafd4 Counters: remove unused updated field 12 years ago
Victor Julien 49087f21e4 Optimizations to reduce branch misses 12 years ago
Victor Julien 64f5129f12 Counters: remove unused tm_name comparison loops 12 years ago
Victor Julien 76c305c128 Counters: fix unix socket 12 years ago
Victor Julien 25aeeebdf7 Counters: merge SCPerfCounterName into SCPerfCounter as there was a 1 on 1 mapping 12 years ago
Victor Julien 3445d17ae5 Counters: remove SCPerfCounterValue struct as we no longer support multiple data types 12 years ago
Victor Julien 677cd03e52 Counters: more unused code removal 12 years ago
Victor Julien 8d4a61a789 Counters: remove unused code 12 years ago
Victor Julien 698ff4e4aa Counters: remove all unused parts of the API 12 years ago
Eric Leblond 79fcf1378a Use unlikely in malloc failure test.
This patch is a result of applying the following coccinelle
transformation to suricata sources:

  @istested@
  identifier x;
  statement S1;
  identifier func =~ "(SCMalloc|SCStrdup|SCCalloc|SCMallocAligned|SCRealloc)";
  @@

  x = func(...)
  ... when != x
  - if (x == NULL) S1
  + if (unlikely(x == NULL)) S1
12 years ago
Eric Leblond c8b3f4418a af-packet: init correctly the config structure
This fix a crash when interface is not defined in YAML.
12 years ago
Eric Leblond eea760de3c decode: fix typo in comment 12 years ago
Anoop Saldanha 167597cfb0 Update ftp parser protocol detection to use lowercase patterns. 12 years ago
Anoop Saldanha 36bd444406 Introduce new API to allow case insensitive protocol detection patterns. 12 years ago
Anoop Saldanha 90827ea990 Remove the obsolete DetectFtpBounceMatch() function. 12 years ago
Ken Steele 9fce4da84d Spell fixes in threads-arch-tile.h 12 years ago
Anoop Saldanha e8cd15c823 Support for feature #983.
Provide support for icmvp4 and icmpv6 as well.  You can now use

alert icmpv4 and
alert icmpv6 as well, apart from the existing

alert icmp, which created a rule that applied to both icmpv4 and icmpv6.
12 years ago
Nelson Escobar cf9f1e3191 Build cuda kernel for capability 3.5 devices. 12 years ago
Victor Julien 3f8b9dde04 Dead code removal 12 years ago
Victor Julien 84af1ee277 storage: fix and small optimization 12 years ago
Victor Julien 77ae8b8878 flow: set correct family in FLOW_COPY_IPV6_ADDR_TO_PACKET 12 years ago
Victor Julien 2a4f821284 Fix 2 unittests 12 years ago
Victor Julien 8516000208 Minor code cleanup/fixes to fast pattern unittests
cppcheck:
[detect-fast-pattern.c:1183] -> [detect-fast-pattern.c:1183]: (style) Same expression on both sides of '&'.
[detect-fast-pattern.c:1217] -> [detect-fast-pattern.c:1217]: (style) Same expression on both sides of '&'.
[detect-fast-pattern.c:1449] -> [detect-fast-pattern.c:1449]: (style) Same expression on both sides of '&'.
[detect-fast-pattern.c:1479] -> [detect-fast-pattern.c:1479]: (style) Same expression on both sides of '&'.
[detect-fast-pattern.c:1509] -> [detect-fast-pattern.c:1509]: (style) Same expression on both sides of '&'.
[detect-fast-pattern.c:1539] -> [detect-fast-pattern.c:1539]: (style) Same expression on both sides of '&'.
[detect-fast-pattern.c:1570] -> [detect-fast-pattern.c:1570]: (style) Same expression on both sides of '&'.
[detect-fast-pattern.c:1686] -> [detect-fast-pattern.c:1686]: (style) Same expression on both sides of '&'.
[detect-fast-pattern.c:1716] -> [detect-fast-pattern.c:1716]: (style) Same expression on both sides of '&'.
[detect-fast-pattern.c:1746] -> [detect-fast-pattern.c:1746]: (style) Same expression on both sides of '&'.
[detect-fast-pattern.c:1776] -> [detect-fast-pattern.c:1776]: (style) Same expression on both sides of '&'.
[detect-fast-pattern.c:1806] -> [detect-fast-pattern.c:1806]: (style) Same expression on both sides of '&'.
[detect-fast-pattern.c:1836] -> [detect-fast-pattern.c:1836]: (style) Same expression on both sides of '&'.
[detect-fast-pattern.c:1866] -> [detect-fast-pattern.c:1866]: (style) Same expression on both sides of '&'.
[detect-fast-pattern.c:1896] -> [detect-fast-pattern.c:1896]: (style) Same expression on both sides of '&'.
[detect-fast-pattern.c:1926] -> [detect-fast-pattern.c:1926]: (style) Same expression on both sides of '&'.
[detect-fast-pattern.c:2022] -> [detect-fast-pattern.c:2022]: (style) Same expression on both sides of '&'.
12 years ago
Victor Julien af311aee4e Minor fix for detection engine setup error check
cppcheck said:
[detect-engine-mpm.c:2075] -> [detect-engine-mpm.c:2075]: (style) Same expression on both sides of '||'.
12 years ago
Victor Julien 974e86e450 Minor pppoe cleanup
cppcheck said:
[decode-pppoe.c:58] -> [decode-pppoe.c:60]: (performance, inconclusive) Variable 'pppoedh' is reassigned a value before the old one has been used if variable is no semaphore variable.
12 years ago
Victor Julien 209946b07c Fix broken check in stream.max-synack-queued parsing (coverity 1038103) 12 years ago
Victor Julien bec59f426e Fix sanity check in AppInspectionEngine registration code 12 years ago
Jason Ish 2953b3f640 Feature #901 - VLAN defrag support.
Take VLAN IDs into account when re-assembling fragments.

Prevents fragments that would otherwise match, but on different
VLANs from being reassembled with each other.
12 years ago
Ken Steele 2d3dc23026 Correct indentation and wording of comments. 12 years ago
Ken Steele a63b87df9e Clean up function syntax
Remove space before ( in function names. Put { on new line.
Make tests static.
12 years ago
Anoop Saldanha 619414c59e Add a /* fall through */ comment for all switch case fall throughs.
This should server as a message to coverity that the fall through is
intentional.
12 years ago
Victor Julien b6efaeb0c0 storage: fix freeing storage
Fix freeing storage. Also add workaround for unittests that don't
(fully) setup storage.

Bug #991.
12 years ago
Victor Julien 37669bfdd2 threshold: register threshold host storage. Related to bug #991 12 years ago
Victor Julien 1b11165864 Reset both sides of the de_state on rule reload. Bug #998. 12 years ago
Victor Julien 74d8d95f83 Don't initialize threshold before rules on delayed detect. Bug #999. 12 years ago
Victor Julien 64203be3ba iprep: fix reputation loading and reloading
When an IP is listed in multiple categories, each new "load" would clear the
previous loads for that IP.

Bug #976
12 years ago
Victor Julien c583c9e205 tag: fix session seconds tracking
Fix bug #995. Tag time setting was initialized using "usec" field
instead of "sec" field. This led to immediate timing out of tag.

Added proper matching unittests for all tagging types.

Bug #995.
12 years ago
Victor Julien 1822a897ff tag: add some debug statements 12 years ago
Victor Julien a26243a23c Clean up rule reload logging 12 years ago
Anoop Saldanha b24fb72247 fix for bug #987.
We don't support jabber protocol detection atm.  Disable the code check
inside suricata to check if jabber protocol detection is enabled in the
yaml file.

Also updated an error log message for app layer.
12 years ago
Anoop Saldanha 83a72d50dd API renaming/beautification. 12 years ago
Anoop Saldanha 1ea5d27508 Fix for bug #989.
In case of recursive call to protocol detection from within protocol
detection, and the recursively invoked stream still hasn't been ack'ed
yet, protocol detection doesn't take place.  In such cases we will end up
still calling the app layer with the wrong direction data.  Introduce a
check to not call app layer with wrong direction data.

When sockets are re-used reset all relevant vars correctly.

This commit fixes a bug where we were not reseting app proto detection
vars.

While fixing #989, we discovered some other bugs which have also been
fixed, or rather some features which are now updated.  One of the feature
update being if we recieve wrong direction data first, we don't reset the
protocol values for the flow.  We let the flow retain the detected
values.

Unittests have been modified to accomodate the above change.
12 years ago
Anoop Saldanha 836bad85a4 Reset app layer processed flag for segments that have been sent for proto
detection, but we failed to figure out the proto.

Updated a unittest to reflect the above change.
12 years ago
Anoop Saldanha 87edd2ade9 Inside PP parser, we were using the return value from DetectPortParse as
the ip_proto value,  which is wrong.  We have fixed this now.
12 years ago
Anoop Saldanha 73be9d3ef7 Update ssl parser protocol detection pattern strings. 12 years ago
Victor Julien 1d18155a16 XFF: use per alert tx id
Use the tx id stored for each alert to find the correct XFF address
to add to the extra-data field.

In overwrite mode we still only grab the first available XFF addr,
as this address is set in the header preceeding the individual alerts.

Issue #904.
12 years ago
Victor Julien e7df53b136 Display TX id in alert debuglog. 12 years ago
Victor Julien edeeb7ed44 Store TX id with alerts
When generating an alert and storing it in the packet, store the tx_id
as well. This way the output modules can log the tx_id and access the
proper tx for logging.

Issue #904.
12 years ago
Victor Julien 51c2e1eaf6 htp: for apache and apache_2_2 personalities, that are no longer supported by libhtp, fall back to apache_2 with a warning. 12 years ago
Victor Julien 958938bf01 Bug 640: add more tests to validate that issue is fixed 12 years ago
Eric Leblond 2be194d03f suricata: add -v[v] option to increase verbosity
This patch adds a -v option to suricata. It increases the log level
defined in the YAML.
12 years ago
Eric Leblond 4a4600539d suricata: info message after log init
This patch moves version display after log init so we can have an
homogeneous display.
12 years ago
Eric Leblond fdc1757e34 suricata: reorder start
Initalizing output just after configuration file parsing allow to
log almost all messages accordingly to configuration.
12 years ago
Eric Leblond 7bcacc712a log: change default log level to notice
This patch updates the log level of meaningful start messages to
notice. It also sets the default log level to notice.
12 years ago
Victor Julien c1190545cf Revert change in queue handler wait logic. Bug #988. 12 years ago
Victor Julien 8d6bca72f7 Improve 'host-mode' info message 12 years ago
Victor Julien 57abba2e64 Coverity 1100842: add missing return statement 12 years ago
Victor Julien afaa10b37d Coverity 1100843: remove unnecessary check 12 years ago
Victor Julien cb15000387 http: add new events for invalid host header and host part of uri 12 years ago
Victor Julien 43b39d333f http: fix some decoder events
Some events we retrieved from error messages are flag now, so check
those. Not all can be converted though. These are no longer set:

HTTP_DECODER_EVENT_INVALID_TRANSFER_ENCODING_VALUE_IN_RESPONSE
HTTP_DECODER_EVENT_INVALID_AUTHORITY_PORT

Part of Bug #982.
12 years ago
Victor Julien 636791751e http: fix field too long events 12 years ago
Victor Julien 5d10bafdba http: don't call HTPHandleWarning before HTPHandleError as the latter handles warnings and errors. 12 years ago
Victor Julien 129b6a65ca http: add test for HTTP_DECODER_EVENT_UNKNOWN_ERROR event as a result of a too long request 12 years ago
Eric Leblond 2c50e41153 reject: try to fail more gracefully
In the case of reject both, a failure in sending one way do not lead to
abort the reset procedure.
12 years ago
Eric Leblond 10b05a6361 reject: clean respond-reject code. 12 years ago
Eric Leblond 6f1cf9728e reject: delete debug line 12 years ago
Eric Leblond f05efeb46f Add reject for IPv6
With this patch reject is now available in IPv6.
12 years ago
Eric Leblond 5f224f87d1 reject: update computation of seq and ack
We have follow TCP RFC (http://tools.ietf.org/html/rfc793#section-3.4).
There is two cases depending on wether the original packet contains a
ACK.
If packet has no ACK, the RST seq number is 0 and the ACK is built the
standard way.
If packet has a ACK, the seq of the RST packet is equal to the ACK of
incoming packet and the ACK is build using packet sequence number and
size of the data.

Regarding standard Ack number, it is computed using seq number of captured
packet added to packet length. Finally 1 is added so we respect the
RFC:
    If the ACK control bit is set this field contains the value of the
    next sequence number the sender of the segment is expecting to
    receive.  Once a connection is established this is always sent.

With this patch we have some correct results. With the following rule:
    reject ssh any any -> 192.168.56.3 any (msg:"no SSH  way"; sid:3; rev:1;)
ssh connection to 192.168.56.3 is correctly resetted on client side.

But this is not perfect. If we have the following rule:
    reject tcp any any -> 192.168.56.3 22 (msg:"no way"; sid:2; rev:1;)
then the connection is not resetted on a standard ethernet network. But
if we introduce 20ms delay on packets, then it is correctly resetted.
This is explained when looking at the network trace. The reset is sent
as answer to the SYN packet and it is emitted after the SYN ACK from
server because the exchange is really fast. So this is discarded by the
client OS which has already seen a ACK for the same sequence number.

This should fix #895.
12 years ago
Eric Leblond 4e15cf2245 reject: fix typo 12 years ago
Eric Leblond efc12b24ae reject: use host-mode to set interface
This patch update reject code to send the packet on the interface
it comes from when 'host-mode' is set to 'sniffer-only'. When
'host-mode' is set to 'router', the reject packet is sent via
the routing interface.

This should fix #957.
12 years ago
Eric Leblond 9bbd2a103d reject: reindent and code cleaning
Reindent file and use some switch instead of if else if.
12 years ago
Eric Leblond 6cf7da30e2 Introduce host-mode.
This variable can be used to indicate to suricata that the host
running is running as a router or is in sniffing only mode.
This will used at least to determine which interfaces are used to
send reject message.
12 years ago
Victor Julien d8cb821875 locks: clean up locks declarations
Split threads.h into several files, where each of these files defines
all lock types and macro's.

threads.h defines the normal case
threads-debug.h defines the debug variants
threads-profile.h defines the lock profiling variants

Finally, threads-arch-tile.h moves the Tilera specifics out
12 years ago
Anoop Saldanha c5cd3562d0 Stateful detection inspection continuation API call should update per
signature's Sigmatch entry as well.
12 years ago
Victor Julien 7f0cc97f5b Thresholding: move parsing code into separate func 12 years ago
Victor Julien 8ce38ac8fe Split Thresholds and Suppression
Thresholds and suppression can be handled independently. Suppression
only suppresses output, and is not related to Threshold state tracking.

This simplifies mixing suppression and thresholding rules.

Part of the Bug #425 effort.
12 years ago
Ken Steele 592d48aab7 Use Spin locks on Tile
On Tile, replace pthread_mutex_locks with queued spin locks (ticket
locks) for dataplane processing code. This is safe when running on
dataplane cores with one thread per core. The condition variables are
no-ops when the thread is spinning anyway.

For control plane threads, unix-manager, stats-logs, thread startup,
use pthread_mutex_locks. For these locks replaced SCMutex with SCCtrlMutex
and SCCond with SCCtrlCond.
12 years ago
Victor Julien 2f4e11b1ca Fix compiler warning
app-layer-parser.c: In function ‘AppLayerPPTestData’:
app-layer-parser.c:2525:9: error: variable ‘dir’ set but not used [-Werror=unused-but-set-variable]
     int dir = 0;
         ^
12 years ago
Ken Steele 85a51638c9 Improve Signature sorting speed
Changed the signature sorting code to use a a single merge sort instead
of the multiple pass sorting that was being used. This reduces startup
time on Tile by a factor of 3.

Also replace the user array of pointers to ints with a simpler array of
ints.
12 years ago
Victor Julien 5c08b2296f DNS: copy only the length of the hardcoded string, not the length of the destination buffer. 12 years ago
Anoop Saldanha 57ed5dfd32 Fix return value from DetectProtoParse() which is used by probing
parser.
12 years ago
Anoop Saldanha ac65784cbc Fix coverity scan defect #1099714.
Sending back uninitialized variable in DetectParseProto().
12 years ago
Anoop Saldanha e383cc27cd Fix a leak in probing parsers. We were freeing just the head of the list,
instead of all the members.
12 years ago
Anoop Saldanha 980934d670 Fix a leak in app layer parser proto code. Free the proto signatures
allocated internally for PM parser.
12 years ago
Anoop Saldanha fc82614025 Fix mem leak in b2g. 12 years ago
Anoop Saldanha 06db1e4cb8 Remove unused vars alp_content_module_handle and proto_map from
struct AlpProtoDetectCtx.
12 years ago
Anoop Saldanha 558f5705eb Remove the unused flow flags - FLOW_TS_PM_PP_ALPROTO_DETECT_DONE and
FLOW_TC_PM_PP_ALPROTO_DETECT_DONE.
12 years ago
Anoop Saldanha 36220b689b Reset some flow flags when port numbers are re-used and we re-use the
flow as a part of a new session.
12 years ago
Anoop Saldanha af1df7a89d Remove the smtp parser restriction that it accepts data only in to client
direction first.
12 years ago
Anoop Saldanha 3ec411486e Fix compilation failure when we don't enable unittests. Got to #ifdef
ALPROTO_TEST.
12 years ago
Anoop Saldanha d76a5bedbc Update stream inline to use the improved app proto detection. 12 years ago
Anoop Saldanha 96d1ba9106 Cosmetic changes to app parser struct.
Removed a flag parameter introuced earlier to indicate the data
that is first acceptable by the parser.  We now use a differently
named parameter to carry out the same activity.
12 years ago
Anoop Saldanha 2cb5bdd3fa Cosmetic changes to code. Introduce human readabel flag values for some constants. Here the parameter in question is "data_first_seen_dir" for session context. 12 years ago
Anoop Saldanha e42905f3b9 indentation fix. 12 years ago
Anoop Saldanha 6bef5fda06 If we have proto mismatch from 2 directions, use one of the protos, instead of erroring out and not sending the data further to the parser.
The logic we use currently is if we have already sent some data to
a parser before we figure out we have a proto mismatch, we use the
proto from the first direction from which we have already sent the
data to the parser, else we stick to the the to client direction.
12 years ago
Anoop Saldanha 976a86def4 Introduce convenience macro to set Stream app proto completion flag. 12 years ago
Anoop Saldanha 16144fe38a Rename function pointer var to use the FuncPtr typing convention. Resupply "dns" as the alproto name for ALPROTO_DNS. 12 years ago
Anoop Saldanha 8ae92c7a5e Add unittest to test for http ambiguous host header.
Previously we would not check the port part of the host from the uri
hostname, while we did use the port part from the host header, leading
to FPs.
12 years ago
Anoop Saldanha d0c5f51293 Update rule engine relationship with regard to setting ip protocol between specifying protocol after action, ip_proto and app-layer-protocol.
Now we can specify alproto, ip_proto combinations this way

alert dns (ip_proto:[tcp/udp];)
alert ip (app-layer-protocol:dns;)
alert ip (app-layer-protocol:dns; ip_proto:tcp;)
alert tcp (app-layer-protocol:dns:)

so on.  Neater than using dnstcp/dnsudp.

This is related to feature #424.
12 years ago
Anoop Saldanha 6eb8f66f0a alert ipv4 and alert ipv6 specified proto rules should be treated and PROTO_ANY just like how we treat alert ip rules. 12 years ago
Anoop Saldanha f592c481dc Introduce a separate inspection engine for app events. 12 years ago
Anoop Saldanha 9e4eec200f Update htp event handler to both warning and error events regardless of any conditions. 12 years ago
Anoop Saldanha b1dffdfbe0 Add app layer protocol packet event detection support. 12 years ago
Anoop Saldanha 5e2d9dbdc3 Add and use EventGetInfo for getting info on an event.
Also update existing parsers and app-layer-event Setup to use this.
12 years ago
Anoop Saldanha 60a2b157b2 Fix duplicate packet decoder events. Add event entries that were missing as well. 12 years ago
Anoop Saldanha 1077acecd7 validate dns sigs that are reported as plain dns and not dnsudp or dnstcp. 12 years ago
Anoop Saldanha 6cb0014287 Move app event module registration as a part of app layer proto table. 12 years ago
Anoop Saldanha 64b0939b4a code cleanup. 12 years ago
Anoop Saldanha 0d7159b525 App layer protocol detection updated and improved. We now use
confirmation from both directions and set events if there's a mismatch
between the 2 directions.

FPs from corrupt flows have disappeared with this.
12 years ago
Anoop Saldanha 22c05da3cd Replace ssn appproto_detection_completed flag with individual stream ones. 12 years ago
Anoop Saldanha c044541b1c Provide convenience macros for setting flow flags on protocol matching by
PM and PP phase.

Replace the areas of the code that would otherwise rely on setting/reading
these flags with these macros.

Other minor tweaks to some api calls.
12 years ago
Anoop Saldanha 00f546e739 update pmp to return whole set of matches, rather than a single match. 12 years ago
Anoop Saldanha 4f7339c423 code cleanup. 12 years ago
Anoop Saldanha 8e8bc49063 Introduce detection parser function pointer. 12 years ago
Anoop Saldanha 94e40907e2 feature #727 - Add support for app-layer-protocol:<protocol> keyword 12 years ago
Anoop Saldanha 6f8cfd999f Allow detection ports for alproto to be specified via the conf file.
To understand the option have a look at the option

app-layer.protocols.tls.detection-ports
12 years ago
Anoop Saldanha ddde572fba Introduce new options into the conf file to enable/disable -
1. Proto detection
2. Parsers

For app layer protocols.

libhtp has now been moved to the section under app-layer.protocols.http,
but we still provide backward compatibility with older conf files.
12 years ago
Anoop Saldanha d9686fae57 Now supports accepting port addresses as strings, like the ones accepted in our rules. As a consequence we now accept port range, and other such combination. Support PP for ports based on ipproto as well. 12 years ago
Victor Julien 48b5513ed9 Properly clean up decoder event rules
Addresses:
~~Dr.M~~ Error #3: LEAK 120 direct bytes 0x08a26ac8-0x08a26b40 + 1871 indirect bytes
~~Dr.M~~ # 0 replace_malloc                               [/work/drmemory_package/common/alloc_replace.c:2292]
~~Dr.M~~ # 1 SigGroupHeadAlloc                            [/home/victor/dev/oisf/src/detect-engine-siggroup.c:144]
~~Dr.M~~ # 2 SigGroupHeadAppendSig                        [/home/victor/dev/oisf/src/detect-engine-siggroup.c:1014]
~~Dr.M~~ # 3 DetectEngineAddDecoderEventSig               [/home/victor/dev/oisf/src/detect.c:3026]
~~Dr.M~~ # 4 SigAddressPrepareStage2                      [/home/victor/dev/oisf/src/detect.c:3075]
~~Dr.M~~ # 5 SigGroupBuild                                [/home/victor/dev/oisf/src/detect.c:4311]
~~Dr.M~~ # 6 SigLoadSignatures                            [/home/victor/dev/oisf/src/detect.c:464]
~~Dr.M~~ # 7 LoadSignatures                               [/home/victor/dev/oisf/src/suricata.c:1706]
~~Dr.M~~ # 8 main                                         [/home/victor/dev/oisf/src/suricata.c:1994]
12 years ago
Victor Julien c43e078db8 ipproto: improve cleanup
To address:
~~Dr.M~~ Error #2: LEAK 16 direct bytes 0x08399688-0x08399698 + 2 indirect bytes
~~Dr.M~~ # 0 replace_malloc                      [/work/drmemory_package/common/alloc_replace.c:2292]
~~Dr.M~~ # 1 SigMatchAlloc                       [/home/victor/dev/oisf/src/detect-parse.c:201]
~~Dr.M~~ # 2 DetectIPProtoSetup                  [/home/victor/dev/oisf/src/detect-ipproto.c:523]
~~Dr.M~~ # 3 SigParseOptions                     [/home/victor/dev/oisf/src/detect-parse.c:510]
~~Dr.M~~ # 4 SigParseOptions                     [/home/victor/dev/oisf/src/detect-parse.c:523]
~~Dr.M~~ # 5 SigParse                            [/home/victor/dev/oisf/src/detect-parse.c:881]
~~Dr.M~~ # 6 SigInitHelper                       [/home/victor/dev/oisf/src/detect-parse.c:1309]
~~Dr.M~~ # 7 SigInit                             [/home/victor/dev/oisf/src/detect-parse.c:1456]
~~Dr.M~~ # 8 DetectEngineAppendSig               [/home/victor/dev/oisf/src/detect-parse.c:1728]
~~Dr.M~~ # 9 DetectLoadSigFile                   [/home/victor/dev/oisf/src/detect.c:334]
~~Dr.M~~ #10 SigLoadSignatures                   [/home/victor/dev/oisf/src/detect.c:422]
~~Dr.M~~ #11 LoadSignatures                      [/home/victor/dev/oisf/src/suricata.c:1706]
12 years ago
Victor Julien 1006d905d0 Improve memory cleanup for decoder-events
To address:

~~Dr.M~~ Error #1: LEAK 1 direct bytes 0x0892c108-0x0892c109 + 0 indirect bytes
~~Dr.M~~ # 0 replace_malloc                        [/work/drmemory_package/common/alloc_replace.c:2292]
~~Dr.M~~ # 1 DetectEngineEventParse                [/home/victor/dev/oisf/src/detect-engine-event.c:173]
~~Dr.M~~ # 2 _DetectEngineEventSetup               [/home/victor/dev/oisf/src/detect-engine-event.c:204]
~~Dr.M~~ # 3 DetectDecodeEventSetup                [/home/victor/dev/oisf/src/detect-engine-event.c:248]
~~Dr.M~~ # 4 SigParseOptions                       [/home/victor/dev/oisf/src/detect-parse.c:510]
~~Dr.M~~ # 5 SigParseOptions                       [/home/victor/dev/oisf/src/detect-parse.c:523]
~~Dr.M~~ # 6 SigParse                              [/home/victor/dev/oisf/src/detect-parse.c:881]
~~Dr.M~~ # 7 SigInitHelper                         [/home/victor/dev/oisf/src/detect-parse.c:1309]
~~Dr.M~~ # 8 SigInit                               [/home/victor/dev/oisf/src/detect-parse.c:1456]
~~Dr.M~~ # 9 DetectEngineAppendSig                 [/home/victor/dev/oisf/src/detect-parse.c:1728]
~~Dr.M~~ #10 DetectLoadSigFile                     [/home/victor/dev/oisf/src/detect.c:334]
~~Dr.M~~ #11 SigLoadSignatures                     [/home/victor/dev/oisf/src/detect.c:422]
12 years ago
Victor Julien 1be6a8a48b Fix small leak in ports validation at startup 12 years ago
Victor Julien 3601091952 flowint: further setup fixes and cleanups 12 years ago
Victor Julien 8080494e9a counters: consolidate counters after all ThreadInit functions of a thread have run. This prevents duplicate and overwriting memory allocations. 12 years ago
Victor Julien 7f8d256e7c Fix tests that didn't expect radix to be freed 12 years ago
Victor Julien d2d784e31a radix: actually free a tree in SCRadixReleaseRadixTree 12 years ago
Victor Julien c94b920874 flowint: fix compile warning 12 years ago
Victor Julien a8c416fc8b flowint: fix setup memory leaks 12 years ago
Victor Julien 16130cc974 ssh: fix memleaks during ssh.softwareversion init and cleanup 12 years ago
Victor Julien ec724a1e56 urilen: fix memory leak when freeing the rule 12 years ago
Anoop Saldanha cfa2cda42b fix for bug #973.
An alternative solution for bug #970.

For chopped patterns, which in it's whole is a duplicate of another
pattern we assign an unique content id.
12 years ago
Anoop Saldanha 4da2f29054 Unittest for bug #973. 12 years ago
Victor Julien 0bfba8352d pcre: check for pcre_free_study, fall back to pcre_free if it unavailable 12 years ago
Victor Julien dd76e679fe mpm: clean up stream thread ctx 12 years ago
Victor Julien 6f450785fc profiling: properly clean up thread local memory. 12 years ago
Victor Julien eca1a8d73a profiling: don't alloc 0 bytes block if no rules are used 12 years ago
Victor Julien 468a8e1ca3 Properly cleanup NSS ctx 12 years ago
Victor Julien eedd4329da Change ParseSize api to not leak memory and only setup pcre once. 12 years ago
Victor Julien 3d78cc8ca6 DNS: free TX events using proper function 12 years ago
Victor Julien 6f2cb141cf Http: improve tx data cleanup 12 years ago
Victor Julien 239ab202c9 stream: clean up queue list in all cases 12 years ago
Victor Julien 67c12c61d3 Http: fix memory leaks when cleaning up our per-tx storage 12 years ago
Victor Julien 6aed56d093 Dns: fix memory leak when events are set 12 years ago
Anoop Saldanha cd80dcbfd4 bug #955 - Fix SSL parsing issue.
The parser wasn't carrying out a bounds check on record length while
in the middle of parsing a handshake.  As a result we would step onto the
next record header and consider it a part of the current handshake.

- Contains an unittest to test the issue.
- Disable the duplicate parser unittest registration.

The issue came to light through an irregular ssl record, which was
reported by Sebastian Roschke, via CVE-2013-5919.

Thanks to Sebastian Roschke for reporting this issue.
12 years ago
Anoop Saldanha 8c1e855632 fix for bug #970(ac-gfbs).
Content strings that are a duplicate of a pattern from another sig, but
have a fast_pattern chop being applied, would end up being assigned the
same pattern id as the duplicate string.  But the string supplied to the
mpm would be the chopped string, which might result in the state_table
output_state content entry being over-riden by the the fuller string at
the final state of the smaller content length, because of which during a
match we might end up inspecting the search buffer against the fuller
content pattern, instead of the chopped pattern, which would end up being
an inspection beyond the buffer bounds.
12 years ago
Anoop Saldanha 92a8b2b738 Unittest to display bug #970(ac-gfbs). 12 years ago
Anoop Saldanha 496f30a5e4 fix for bug #970(ac-bs).
Content strings that are a duplicate of a pattern from another sig, but
have a fast_pattern chop being applied, would end up being assigned the
same pattern id as the duplicate string.  But the string supplied to the
mpm would be the chopped string, which might result in the state_table
output_state content entry being over-riden by the the fuller string at
the final state of the smaller content length, because of which during a
match we might end up inspecting the search buffer against the fuller
content pattern, instead of the chopped pattern, which would end up being
an inspection beyond the buffer bounds.
12 years ago
Anoop Saldanha af95df67a5 Unittest to display bug #970(ac-bs). 12 years ago
Victor Julien 68ba9df8a0 Fix valgrind warning on memrchr unittest. 12 years ago
Anoop Saldanha d2ea799d38 fix for bug #970.
Content strings that are a duplicate of a pattern from another sig, but
have a fast_pattern chop being applied, would end up being assigned the
same pattern id as the duplicate string.  But the string supplied to the
mpm would be the chopped string, which might result in the state_table
output_state content entry being over-riden by the the fuller string at
the final state of the smaller content length, because of which during a
match we might end up inspecting the search buffer against the fuller
content pattern, instead of the chopped pattern, which would end up being
an inspection beyond the buffer bounds.
12 years ago
Anoop Saldanha da75db9330 Unittest to display bug #970. 12 years ago
Victor Julien 397a55457d Add sanity checks for command line argument handling
Coverity 1075221.

Normally getopt_long should cover this case, but can't hurt to
add in some extra checks.
12 years ago
Victor Julien c8b71938ff Add a fallback memrchr implementation for those platforms that dont support it. Bug #963. 12 years ago
Victor Julien e77b21a7f7 Suppress compiler warning about comparing signed and unsigned vars 12 years ago
Victor Julien bb8298ffa2 Move header thread_affinity declaration to extern to avoid duplicate declarations. 12 years ago
Victor Julien 3470b07ea5 Fix several compile and runtime warnings found by clang 3.2 with the -fsanitize=address option. 12 years ago
Victor Julien c82ecf553a Tag: document in the code that 'tag' is compatible with ip only 12 years ago
Victor Julien d12761233c Don't set tag on pseudo packets 12 years ago
Victor Julien 02cbbd0b89 unified2: fix tags not being logged. Bug #968 12 years ago
Anoop Saldanha 3749fc98fd Modify handling of negated content.
The old behaviour of returning a failure if we found a pattern while
matching on negated content is now changed to continuing searching
for other combinations where we don't find the pattern for the
negated content.

Thanks to Will Metcalf for reporting this.
12 years ago
Victor Julien 8539791c7e Coverity 1038102: remove dead code from host hash 12 years ago
Victor Julien 8237bbf18a Coverity 1038101: remove dead code from host hash timeout code 12 years ago
Victor Julien 440124a4b9 Coverity 1038100: remove dead code from flow hash timeout code(2) 12 years ago
Victor Julien 243060a6b7 Coverity 1038099: remove dead code from flow hash timeout code 12 years ago
Victor Julien 2e82772a0a Coverity 1038098: remove dead code from flow hash 12 years ago
Victor Julien aecefd00bd Coverity 1038095: remove dead code from defrag hash timeout code 12 years ago
Victor Julien 16056d51f2 Coverity 1038094: remove dead code from defrag hash 12 years ago
Victor Julien 32503bafaa Coverity 1038089: error check fseek call 12 years ago
Victor Julien 4827a4dcef Coverity 400477: pcre_get_substring retval
Add missing return code check to pcre_get_substring call.
12 years ago
Victor Julien 790866656b Coverity 1038129 fix
Don't leak memory on malloc error in b2gm mpm implementation.
12 years ago
Victor Julien 33919559d0 Fix memory leak on invalid luajit signature. Coverity 1038520. 12 years ago
Victor Julien 51c6a333d9 geoip: never try to store more locations than possible (Coverity 1038517) 12 years ago
Victor Julien 3cf3b485f2 Coverity 1038138 fix
Clean up parsing code to suppress Coverity:
Dereference before null check (REVERSE_INULL)

Proper checking was already done.
12 years ago
Victor Julien 27ea4232fe Coverity 1038134 fix
Cleaned up error check. "ipdup" can only be non-NULL there, so remove check
that confused coverity.
12 years ago
Victor Julien ecd5c7573b Coverity 1038135 fix
Small cleanup in the error handling. The extra null check confused
Coverity.
12 years ago
Victor Julien 38b6103ff5 Coverity 1038133 fix
Clean up parsing code to suppress Coverity:
Dereference before null check (REVERSE_INULL)

Proper checking was already done.
12 years ago
Ken Steele 50f859e9f2 Move SIMD implementations out of detect.c
Move SIMD the implementations of SigMatchSignaturesBuildMatchArray()
for SSE3 and Tile out of detect.c to reduce the size of the file.

Also moved SIMD unit tests to detect-simd.c
12 years ago
Victor Julien 7f140f6726 Coverity 1038111: fix local overrun of a string in app layer proto detect setup code. 12 years ago
Ken Steele eb4f0da97f Change one more atomic size in detect.h
Change uint16_t to int for better tile atomic performance. Checked with
pahole that it doesn't increase the size of the structure.
12 years ago
Ken Steele b08ddfa7f1 Support for Tile Gx atomic instructions
Tilera's GCC supports the GCC __sync_ intrinsics.

Increase the size of some atomic variables for better performance on
Tile.  The Tile-Gx architecture has native support for 32-bit and
64-bit atomic operations, but not 8-bit and 16-bit, which are emulated
using 32-bit atomics, so changing some 16-bit and 8-bit atomic into
ints improves performance.

Increasing the size of the atomic variables modified in this change
does not increase the total size of the structures in which they
reside because of existing padding requirements. The one case that
would increase the size of the structure (Flow_) was confitionalized
to only change the size on Tile.
12 years ago
Anoop Saldanha 54847e396f unittests for gzip, deflate http compression, multiple stacked
compressions, cunning compression that's not what it says it is, etc.

These unittests are tweaked to pass.  When libhtp fixes these issues
we will have to reenable them.
12 years ago
Anoop Saldanha 94e2527606 Introduce a saner way to validate the completion of request and
response bodies.

Also don't change app state for http from inside inspection.
12 years ago
Anoop Saldanha dcdcbd9721 Fix creating a backup of htp config. This is used by unittests that
changed htp config.
12 years ago
Ken Steele 62540eff3e Align some structures to cacheline
Align strucutres with pthread mutex locks to start on cachelines to keep
the lock within one cacheline.
12 years ago
Ken Steele d84079ba7d Move FlowIncrUsecnt to header file to allow for inlining.
Move FlowIncrUsecnt() and FlowDecrUsecnt() from flow.c to flow.h to
allow for inlining.
12 years ago
Ken Steele e05034f5dd New Multi-pattern matcher, ac-tile, optimized for Tile architecture.
Aho-Corasick mpm optimized for Tilera Tile-Gx architecture. Based on the
util-mpm-ac.c code base. The primary optimizations are:
1) Matching function used Tilera specific instructions.
2) Alphabet compression to reduce delta table size to increase cache
   utilization  and performance.

The basic observation is that not all 256 ASCII characters are used by
the set of multiple patterns in a group for which a DFA is
created. The first reason is that Suricata's pattern matching is
case-insensitive, so all uppercase characters are converted to
lowercase, leaving a hole of 26 characters in the
alphabet. Previously, this hole was simply left in the middle of the
alphabet and thus in the generated Next State (delta) tables.

A new, smaller, alphabet is created using a translation table of 256
bytes per mpm group. Previously, there was one global translation
table for converting upper case to lowercase.

Additional, unused characters are found by creating a histogram of all
the characters in all the patterns. Then all the characters with zero
counts are mapped to one character (0) in the new alphabet. Since
These characters appear in no pattern, they can all be mapped to a
single character and still result in the same matches being
found. Zero was chosen for the value in the new alphabet since this
"character" is more likely to appear in the input. The unused
character always results in the next state being state zero, but that
fact is not currently used by the code, since special casing takes
additional instructions.

The characters that do appear in some pattern are mapped to
consecutive characters in the new alphabet, starting at 1. This
results in a dense packing of next state values in the delta tables
and additionally can allow for a smaller number of columns in that
table, thus using less memory and better packing into the cache. The
size of the new alphabet is the number of used characters plus 1 for
the unused catch-all character.

The alphabet size is rounded up to the next larger power-of-2 so that
multiplication by the alphabet size can be done with a shift.  It
might be possible to use a multiply instruction, so that the exact
alphabet size could be used, which would further reduce the size of
the delta tables, increase cache density and not require the
specialized search functions. The multiply would likely add 1 cycle to
the inner search loop.

Since the multiply by alphabet-size is cleverly merged with a mask
instruction (in the SINDEX macro), specialized versions of the
SCACSearch function are generated for alphabet sizes 256, 128, 64, 32
and 16.  This is done by including the file util-mpm-ac-small.c
multiple times with a redefined SINDEX macro. A function pointer is
then stored in the mpm context for the search function. For alpha bit
sizes of 8 or smaller, the number of states usually small, so the DFA
is already very small, so there is little difference using the 16
state search function.

The SCACSearch function is also specialized by the size of the value
stored in the next state (delta) tables, either 16-bits or 32-bits.
This removes a conditional inside the Search function. That
conditional is only called once, but doesn't hurt to remove
it. 16-bits are used for up to 32K states, with the sign bit set for
states with matches.

Future optimization:

The state-has-match values is only needed per state, not per next
state, so checking the next-state sign bit could be replaced with
reading a different value, at the cost of an additional load, but
increasing the 16-bit next state span to 64K.

Since the order of the characters in the new alphabet doesn't matter,
the new alphabet could be sorted by the frequency of the characters in
the expected input stream for that multi-pattern matcher. This would
group more frequent characters into the same cache lines, thus
increasing the probability of reusing a cache-line.

All the next state values for each state live in their own set of
cache-lines. With power-of-two sizes alphabets, these don't overlap.
So either 32 or 16 character's next states are loaded in each cache
line load. If the alphabet size is not an exact power-of-2, then the
last cache-line is not completely full and up to 31*2 bytes of that
line could be wasted per state.

The next state table could be transposed, so that all the next states
for a specific character are stored sequentially, this could be better
if some characters, for example the unused character, are much more
frequent.
12 years ago
Victor Julien 77b429c402 xff: fix unittest crashes 12 years ago
Victor Julien 05d68ce394 xff: don't do xff check if there are no alerts anyway. 12 years ago
Duarte Silva 7dbb305255 Adds X-Forwarded-For support to the Unified2 output format
- Added the Unified2 file format related constants
 - Added IPv6 support
 - Two modes of operation with a fall-back to "extra-data" mode if
   "overwrite" mode is not applicable
 - Changed the configuration loading code to handle the new
   configuration structure
 - When creating the packet that fakes the one that generated the alert
   the flow direction wasn't taken into account in overwrite mode
 - Fixed BUG_ON condition
12 years ago
Victor Julien 900918a5d1 Bug #948: detect thread local storage support 12 years ago
Ken Steele 0861d3a2a3 Minor optimization in time caching code.
Reduced the size of the cached string buffer from 128 to 32, which is
still larger than the largest possible time string, which is 26
characters.

Added a check for the user passing in an output buffer that is smaller
than the cached string. Previously, the code would have copied past
the end of the users buffer.
12 years ago
Anoop Saldanha 49dcb0ca84 fix for #925.
Log sensible error message when the user doesn't supply a value for
stream.prealloc-sessions or when the values supplied in invalid and
the engine resorts to using a default.
12 years ago
Anoop Saldanha db6ef81fb0 fix for #926.
Supply meaningful error message when user supplies invalid value for
host.prealloc.
12 years ago
Anoop Saldanha b90a56b626 fix for #927.
Print an error message when the user supplies an invalid value for
detect-thread-ratio in the conf file.
12 years ago
Anoop Saldanha bed3f605fa Fix for #922.
Add more relevant error message when we supply invalid value for
defrag.trackers and defrag.hash-size
12 years ago
Anoop Saldanha 6608e7f523 Introduce generic utility API to log message on invalid config entry. 12 years ago
Victor Julien 6d34834623 Runmode fixes and cleanups
Bug #939: thread name buffers are sized inconsistently
These buffers are now all fixed at 16 bytes.

Bug #914: Having a high number of pickup queues (216+) makes suricata crash
Fixed so that we can now have 256 pickup queues, which is the current built-in
maximum. Improved the error reporting.

Bug #928: Max number of threads
Error reporting improved. Issue was the same as #914.
12 years ago
Anoop Saldanha 56143131da Fix unittests that use chunked encoding. 12 years ago
Nelson Escobar ef4d11aeb5 Use the Async versions of SCCudaMemcpy* to improve gpu performance. 12 years ago
Eric Leblond 77f2b9968e autotools: use builddir instead of srcdir
srcdir is supposed to be read-only when running distcheck so it is better to
create the log directory in builddir.
12 years ago
Ignacio Sanchez 1b2f251866 Various custom http logging improvements
Cookie is parsed now using uint8_t pointers (inliniac PR comments)
Changed buffer size to a power of 2 (8192) and cookie value extraction function to static (inliniac PR comments)
Added %b for request size (vinfang patch)
Writing "-" if an unknown % directive is used (vinfang patch)
Fixed bug in cookie parser
Fixed format string issue logging literal values
Improve error handling (Victor Julien comments)

(patchset rebased and reworded by Victor Julien)
12 years ago
Ignacio Sanchez 8051dc8a6a Added modifications suggested by Charles Smutz (https://redmine.openinfosecfoundation.org/issues/602) 12 years ago
Ignacio Sanchez 796bfab231 Added support for %{cookiename}C
Added support for the definition of maximun length. ie: %[50]{user-agent}i
Some small bugfixes
12 years ago
Eric Leblond 3dbf6c6fee solaris: fix compilation failure
This patch fixes a compilation failure on Solaris. Compiler does
not support when a function returning void is used in return of
an other function returning void.
12 years ago
Ken Steele a2b502a30c Formatting change for function call.
Put open brace { for function on a new line to match coding standard.

Changed:

int foo(int x) {
}

to:

int foo(int x)
{
}
12 years ago
Ken Steele d4dd18eb85 Clean up SCLocalTime() usage
Remove cast of return type from SCLocalTime() as it is not needed.
Replace last use of localtime_r() with SCLocalTime().
12 years ago
Ken Steele 77fae5313d On Open BSD systems don't cache time.
Open BSD doesn't support __thread, which is used for time caching, so
don't do time chaching for BSD systems.
12 years ago
Ken Steele 2feb37c155 Cache time conversions for localtime() and CreateTimeString()
When converting a time in seconds (64-bit seconds since 1970) to
Month/Day/Year hours minutes, Suricata calls localtime_r(), which
always aquires a lock and then does complex comutation based on the
current time zone. The time zone can be specified in the TZ
environment variable, which is only parsed the first time it is used,
or from a file. The default file is /etc/localtime. The file is
checked each time to see if it might have changed and is reparsed if
it has changed.

The GLIBC library has a lock inside localtime_r(), which limits
parallelism, which is a problem when the rate of generating alerts is
high, since Suricata generates a new ascii time string for each alert
into fast.log.

This change caches the value returned by localtime_t() and then sets
the seconds within the minute based on the cached start-of-minute
time. All of the values return, expect for the seconds, is constant
within the same minute. Switching to a new seconds could change all
the other values, year, month, day, hour. The cache stores the current
and previous minute values.

The same trick is used in CreateTimeString() for generated time
string. The string, up to the minutes, is cached and then copied into
the result string, followed by printing the new seconds into the
result string.

The seconds within a minute are calculated as the difference in
seconds from the start of the current minute.
12 years ago
Ken Steele 68d26dcec7 Merge multiple copies of CreateTimeString() to one copy.
There were 8 identical copies of CreateTimeString() in 8 files.
Most used SCLocalTime, to replace localtime_r(), but some did not.
Created one copy in util-time.c.
12 years ago
Ken Steele 5532af4621 Create SCMUTEX_INITIALIZER to abstract out PTHREAD_MUTEX_INITIALIZER
This allows replacing pthread mutexes with other types of mutex.
12 years ago
Ken Steele 784843b146 Use Tilera SIMD for Signature matching ala SSE3
Makes use of 8-wide byte compare instructions in signature matching.

For allocating aligned memory, _mm_malloc() is SSE only, so added
check for __tile__ to use memalign() instead.

Shows a 13% speed up.
12 years ago
Ken Steele 22225a7e99 Tile SIMD implementation of SCMemcmp and SCMemcmpLowercase
Based on the SSE3 implementation, it checks 8 bytes at a time.
12 years ago
Anoop Saldanha e68d44b051 fix for #932.
ipv6 tunnel decoder wrongly treats the tunneled ipv6 packets as an ipv4
packet.
12 years ago
Anoop Saldanha e2f4144d99 fix for #920.
Cull the space before the address specified in address var variables.
12 years ago
Duarte Silva ab215c72f6 Now using the common functions 12 years ago
Duarte Silva 0a5c798729 Now using the common functions
- Removed some non printable ANSI characters
- Removed unecessary include
12 years ago
Duarte Silva 8ce95af09c Added the new files containing the repeated functions
- Renamed the functions to something more generic
- Added the source and include files to the Makefile
12 years ago
Anoop Saldanha a44d42b124 Fixes segv inside rule swap under low mem conditions.
We now gracefully exit rule swap on any allocation or other failures.
12 years ago
Anoop Saldanha 8516ba24c9 Rearrange ac state.
Notice a minor speed bump of around 2% on runs.  More updates to follow.
12 years ago
Ken Steele 4b8bb11454 Enable using Tile cycle counter.
The Tile processors all have a cycle counter with a simple interface. Use
that for UtilCpuGetTicks.
12 years ago
Victor Julien 38aaae1fd7 IsRuleReloadSet() shouldn't return an uninitialized value 12 years ago
Eric Leblond 189327981a unittests: fix stream-tcp.c
Lock and recycle fixes for stream-tcp.c
12 years ago
Eric Leblond cd3e32ce19 unittests: some functions needs a flow lock.
In debug validation mode, it is required to call application layer
parsing and other functions with a lock on flow. This patch updates
the code to do so.
12 years ago
Eric Leblond c5bd04f102 unittest: recycle packet before exit
To avoid an issue with flow validation, we need to recycle the packet
before cleaning the flow.
12 years ago
Anoop Saldanha d292f1a529 fix for #915. Fix segv when we send NULL to snprintf. 12 years ago
Eric Leblond c6e8c5bf1f pf_ring: avoid to ask for extended header.
This patch update pf_ring capture to avoid to ask for extended
header. They are only needed when rxonly checksum checks is used
and this is only possible when interface is not a DNA interface.
12 years ago
Victor Julien ff668c2030 Fix Tile compile 12 years ago
Eric Leblond 20ca270dc3 fix pf_ring build 12 years ago
Eric Leblond 2a46f0dae4 suricata: rename SuriInstance to SCInstance. 12 years ago
Eric Leblond 9b422f3a8c suricata: suppress Suri prefix
Suppress Suri prefix in internal function name.
12 years ago
Eric Leblond 18ced653c3 Use a typedef for SuriInstance. 12 years ago
Eric Leblond 2d77e53f2c Add offline flag to SuriInstance and some refactoring 12 years ago
Eric Leblond 34abd818dd Prefix util-conf function with Config 12 years ago
Eric Leblond 7242cb30e7 Move CreateLowercaseTable to GLobalInits 12 years ago
Eric Leblond 02e9851315 Generic code don't need ifdef 12 years ago
Eric Leblond 8c00a963aa Use function for delayed detect setup. 12 years ago
Eric Leblond 4296e5f29e Add functions for elapsed time computation. 12 years ago
Eric Leblond 9d1d08c7a4 Factorize Signature loading 12 years ago
Eric Leblond 20c5683b60 Use function for daemonification and signal handler 12 years ago
Eric Leblond 90aaf55201 set rule_reload as part of SuriInstance 12 years ago
Eric Leblond bb19ce1847 SetBPfString is part of command line parsing 12 years ago
Eric Leblond 1a6983ee19 suricata: use function to print version 12 years ago
Eric Leblond 4f789dbe84 Add function for internal running mode 12 years ago
Eric Leblond d3cb043001 suricata: windows specific in one function 12 years ago
Eric Leblond 4401c048ba Running mode is set earlier so out earlier 12 years ago
Eric Leblond 40a25112a0 kill remaining run_mode usage 12 years ago
Eric Leblond 75fa1e20d7 engine analysis is a running mode 12 years ago
Eric Leblond c0d5ee77f9 get (almost) rid of run_mode variable. 12 years ago
Eric Leblond 80542816cd add internal running mode 12 years ago
Eric Leblond e07fdb20a8 Add SuriInstance structure
To be able to split code in functions in main, we need to pass
information about the current running Suricata to functions.
For that we create a structure to store suricata run parameters.

In this patch it allows to separate command line parsing and to
treat internal running mode in a switch just after command line
parsing.
12 years ago
Eric Leblond 325462d396 Export IsRuleReloadSet and use it. 12 years ago
Eric Leblond 6d9a66d522 unittest: make check use a qa/log dir for logging
This patch is using the qa/log directory to store the output
of the check. In case of success, the directory is deleted.
In case of failure, the directory remains in place.

This should fixes #910.
12 years ago
Eric Leblond 4424f5a231 af-packet: add sanity check in free function 12 years ago
Eric Leblond 8e68b357c7 Suppress Suri prefix. 12 years ago
Eric Leblond 42011e2d32 suricata: function for lowercase table creation 12 years ago
Eric Leblond 132bebb2b2 Simplify code by removing comment 12 years ago
Eric Leblond 07ef1f9837 suricata: add wrapper for interface listing 12 years ago
Eric Leblond 54006de40c Use new function GetLogDirectory() 12 years ago
Eric Leblond 2be7c8aea8 Add util-conf for config util 12 years ago
Eric Leblond 27752818c2 suricata: add some wrapper for config file handling 12 years ago
Eric Leblond b2fa4edd36 move unittest out of suricata.c 12 years ago
Eric Leblond 9a0bf0956b suricata: list cuda cards in separate function 12 years ago
Eric Leblond bed48e3a54 suricata: separate keyword and app layer listing code
The list-keyword and app-layer listing code was spread over all the
init code. This patch introduces a separate file to store non standard
running mode like these ones.
12 years ago
Eric Leblond 135ef0186b runmodes: fix comment 12 years ago
Victor Julien 5a7bf53a6b Storage: rename Init to Alloc to reflect actual functioning. Comment updates. 12 years ago
Victor Julien f06694d0c1 Storage API: add safety check for cases when there is no storage used. 12 years ago
Eric Leblond caf730d988 engine-tag: rename var and add sanity check 12 years ago
Eric Leblond fb55931c30 flow tag: conversion to flow storage API
This patch is updating the flow tag system to use the flow
storage API. The tag_list member of Flow structure is suppressed
and its cleaning operation are suppressed too as this is handled
transparently by the flow storage API.
12 years ago
Eric Leblond 4db2fc2cbb Add per-flow generic storage
This patch adds a per-flow storage that can be created via the functions
available in flow-storage.c.
12 years ago
Eric Leblond 6d08807b2d Host: use global free storage function
This patch is here to avoid that all modules using a local storage
have to update host code to add their free function. It modifies
previous behavior by calling HostFreeStorage in any case.
12 years ago
Victor Julien 27023872de Use Host Storage API for per host thresholding 12 years ago
Victor Julien c08b395c2c Init storage api at start up 12 years ago
Victor Julien 5919901675 Storage API: add registration check closed test in debug mode. 12 years ago
Victor Julien 3447324c36 Move Host Tag storage to Host Storage API. 12 years ago
Victor Julien 0d2a6e515e Add Host specific wrapper to StorageRegister() 12 years ago
Victor Julien b5ccf0b9c7 storage: allow preallocated storage 12 years ago
Victor Julien e2b006f523 host: use storage api 12 years ago
Victor Julien 022c0e466e Initial storage api work 12 years ago
Victor Julien 1c06d52208 Misc fixes after make check feedback 12 years ago
Ken Steele 316190c6b9 Add TILE-Gx mPIPE packet processing support.
The TILE-Gx processor includes a packet processing engine, called
mPIPE, that can deliver packets directly into user space memory. It
handles buffer allocation and load balancing (either static 5-tuple
hashing, or dynamic flow affinity hashing are used here). The new
packet source code is in source-mpipe.c and source-mpipe.h

A new Tile runmode is added that configures the Suricata pipelines in
worker mode, where each thread does the entire packet processing
pipeline.  It scales across all the Gx chips sizes of 9, 16, 36 or 72
cores. The new runmode is in runmode-tile.c and runmode-tile.h

The configure script detects the TILE-Gx architecture and defines
HAVE_MPIPE, which is then used to conditionally enable the code to
support mPIPE packet processing. Suricata runs on TILE-Gx even without
mPIPE support enabled.

The Suricata Packet structures are allocated by the mPIPE hardware by
allocating the Suricata Packet structure immediatley before the mPIPE
packet buffer and then pushing the mPIPE packet buffer pointer onto
the mPIPE buffer stack.  This way, mPIPE writes the packet data into
the buffer, returns the mPIPE packet buffer pointer, which is then
converted into a Suricata Packet pointer for processing inside
Suricata. When the Packet is freed, the buffer is returned to mPIPE's
buffer stack, by setting ReleasePacket to an mPIPE release specific
function.

The code checks for the largest Huge page available in Linux when
Suricata is started. TILE-Gx supports Huge pages sizes of 16MB, 64MB,
256MB, 1GB and 4GB. Suricata then divides one of those page into
packet buffers for mPIPE.

The code is not yet optimized for high performance. Performance
improvements will follow shortly.

The code was originally written by Tom Decanio and then further
modified by Tilera.

This code has been tested with Tilera's Multicore Developement
Environment (MDE) version 4.1.5. The TILEncore-Gx36 (PCIe card) and
TILEmpower-Gx (1U Rack mount).
12 years ago
Victor Julien 04f3f14541 ipv6: fix parsing of malformed ext hdr. Bug #908. 12 years ago
Victor Julien 4b4111e9e2 icmpv6: fix icmp_id and icmp_seq keywords
Bug #907
12 years ago
Victor Julien d82ce3f50c Fix compiler warning due to missing include
decode.c: In function 'DecodeThreadVarsAlloc':
decode.c:437: error: implicit declaration of function 'ConfGetBool'
12 years ago
Victor Julien 16c3487444 Add yaml option to disable vlan ids hashing
In some cases using the vlan id(s) in flow hashing is problematic. Cases
of broken routers have been reported. So this option allows for disabling
the use of vlan id(s) while calculating the flow hash, and in the future
other hashes.

Vlan tracking for flow is enabled by default.
12 years ago
Victor Julien 58ed1f2411 flow: take vlan_id's into account in the flow hash
In VLAN we can have 2 layers of encapsulation. In this patch both
layers are used in the flow hash to distinguish between encapsulated
traffic.
12 years ago
Victor Julien 055b422c28 Remove obsolete code: flow alert sid storage 12 years ago
Victor Julien 9faa4b740d Add --unittests-coverage option to list how many code modules have tests 12 years ago
Victor Julien fc7879322e Rename GetIfaceMaxPayloadSize to GetIfaceMaxPacketSize to reflect the actual function. 12 years ago
Victor Julien bd21b5ed9c Pcap: fix snaplen autodetection, GetIfaceMTU doesn't include link layer length 12 years ago
Anoop Saldanha ee0b21652b fix bug where we were not printing http hostname(printing <unknown>
previously) in httplog, filestore meta and file log.
12 years ago
Victor Julien 7edcc13514 NFQ: fix packets not getting freed 12 years ago
Anoop Saldanha cdaa13012a fix for #882.
Refactor the code that initializes the cuda mpm environment.
12 years ago
Victor Julien 9f3e2f7a92 NFQ: adapt to ReleasePacket API 12 years ago
Ken Steele b076a26cdc Replace ReleaseData function on Packet Structure with ReleasePacket.
This commit allows handling Packets allocated by different methods.
The ReleaseData function pointer in the Packet structure is replaced
with ReleasePacket function pointer, which is then always called to
release the memory associated with a Packet.

Currently, the only usage of ReleaseData is in AF Packet. Previously
ReleaseData was only called when it was not NULL. To implement the
same functionality as before in AF Packet, a new function is defined
in AF Packet to first call the AFP specific ReleaseData function and
then releases the Packet structure.

Three new general functions are defined for releasing packets in the
default case:
    1) PacketFree() - To release a packet alloced with SCMalloc()
    2) PacketPoolReturnPacket() - For packets allocated from the Packet Pool.
                                  Calls RECYCLE_PACKET(p)
    3) PacketFreeOrRelease() - Calls PacketFree() or PacketPoolReturnPacket()
                                 based on the PKT_ALLOC flag.

Having these functions removes the need to check the PKT_ALLOC flag
when releasing a packet in most cases, since the ReleasePacket
function encodes how the Packet was allocated. The PKT_ALLOC flag is
still set and is needed when AF Packet releases a packet, since it
replaces the ReleasePacket function pointer with its own function and
then calls PacketFreeOfRelease(), which uses the PKT_ALLOC flag.
12 years ago
Anoop Saldanha f85a2dc84b fix for #875.
Update configure.ac to check for either 0.5.5 and 0.5.x version of libhtp.
12 years ago
Anoop Saldanha 9698a5d78c Code to enable cuda support for pfring live mode. 12 years ago
Victor Julien 91fb47475b DNS: break out of DNSResponseGetNameByOffset if we're in there too long. Can happen on bad data. 12 years ago
Victor Julien aa26dae5a1 Stream: don't inject stream end pseudo pkt on FinWait2 state. Bug #883. 12 years ago
Victor Julien 2f3f577fb6 DNS: convert info logs to debugs 12 years ago
Victor Julien 97f51c1011 Fix ac-bs and ac-gfbs mpm-algo settings leading to fatal error if CUDA is enabled. Workaround for #882. 12 years ago
Eric Leblond e2334fbfe8 unix socket: fix typo in error message 12 years ago
Eric Leblond c2cbb43776 autotool: INCLUDES usage is deprecated 12 years ago
Eric Leblond 281d2f27f8 Fix compilation warning
A goto could lead to the use de_ctx without declaring it.
12 years ago
Victor Julien f4dcba6de3 In case of fragments, don't consider ports. Bug #847. 12 years ago
Anoop Saldanha e7f09f24c8 Code to enable cuda support for live mode pcap and af-packet. Keep an eye
out on the mailing list and http://planet.suricata-ids.org for performance
and other profiling data.
12 years ago
Victor Julien 51d6c63860 Luajit: fix compilation and tests after libhtp upgrade 12 years ago
Anoop Saldanha 48cf0585fb Suricata upgrade to libhtp 0.5.x.
Remove the support for now unsupported personalities from libhtp -
TOMCAT_6_0, APACHE and APACHE_2_2.  We instead use the APACHE_2
personality.
12 years ago
Victor Julien 080c15b3fc Enable libhtp 0.3.0 compilation and crash free UT run. Still see 5 failed tests. 12 years ago
Victor Julien 538da26812 Fix sgh mpm flags assignment 12 years ago
Eric Leblond 150cd39c6e detect-engine: do a direct update of flag
There is no reason not to update the flag directly. So do it
to avoid to crash the test.
12 years ago
Eric Leblond 2f2916d9ec ccccinelle: add formatted comment for flag test 12 years ago