Commit Graph

4724 Commits (b94b8e03bdc9a8deb073db8faa129586a5d76eeb)
 

Author SHA1 Message Date
Victor Julien bf6ab333ff stream: use reassembly.memcap for stream chunks
Use the stream.reassembly.memcap for stream chunks (StreaMsg) as well.
11 years ago
Victor Julien 5206928702 stream: in SACK, always decrease memcap on free
We should always decrease the stream memcap on freeing SACK records.
11 years ago
Victor Julien 7a0649f9c4 pool: rename data structure fields to stack
Rename the following fields:
 -    uint32_t alloc_list_size;
 +    uint32_t alloc_stack_size;

 -    PoolBucket *alloc_list;
 +    PoolBucket *alloc_stack;

 -    PoolBucket *empty_list;
 -    uint32_t empty_list_size;
 +    PoolBucket *empty_stack;
 +    uint32_t empty_stack_size;

To reflect that these are in fact, stacks.
11 years ago
Victor Julien ee83809d8e pool: remove tail tracking in alloc list
The list fully acts like a stack now.
11 years ago
Victor Julien 228d1d3980 pool: document some of the Pool:: fields. 11 years ago
Victor Julien 4c9f9db770 pool: update internal counters at the proper time
Only update Pool::outstanding and Pool::allocated in PoolGet when
we are sure both Alloc and Init were successful.
11 years ago
Victor Julien 3c7f6ed876 stream: improve memcap checking
Only the TcpSegment structure would be checked for fitting in the
memcap, not the actual data.
11 years ago
Victor Julien feedb45770 stream: cast memcap checks to uint64_t 11 years ago
Victor Julien a77b9b36e5 app-layer: parser cleanup
Use f->protomap instead of calling FlowGetProtoMapping. Don't use
TcpSession *ssn ptr for anything other than TCP
11 years ago
Victor Julien 54d64a1237 detect: use pflow pointer
Use pflow pointer in SigMatchSignatures consistently. Also, when
needing access to the ipproto, use p->proto, not p->flow->proto.
11 years ago
Victor Julien 634eb1d35c app-layer proto detect: optimization
Don't use FlowGetProtoMapping at runtime, use f->protomap instead.
Add safety check to make sure its value is within range, as it's
used to index an array.

Update unittests to initialized flows (somewhat).
11 years ago
Victor Julien 4f1f395bb5 Coverity 1153935: fix confusing sizeof 11 years ago
Victor Julien 1f00ff6ab3 App-layer proto detect cleanups
Remove unnecessay inlining.
Rename functions with wrong naming scheme. E.g. AllocAppLayer.. instead
of AppLayer..Alloc.
Use AppProto instead of uint16_t.
Convert u16 ipproto cases to u8.
11 years ago
Victor Julien 657b83d238 dns: add event for when memcap is reached
Raise event if state-memcap is reached for a flow.
11 years ago
Victor Julien 9a21a2f64b dns: update counters
This patch updates the DNS counters from the main AppLayer entry
functions. Due to the limited scope of AppLayerThreadCtx some of
the logic had to be implemented in app-layer.c, where it doesn't
belong.
11 years ago
Victor Julien 66f764ce7b dns: register counters
Register dns memory counters.
Keep track of memcap reached conditions, and increment counters for
those.
11 years ago
Victor Julien 09e5ea230a app-layer: update UDP entry function
Update AppLayerHandleUdp to take the ThreadVars pointer as an
argument in prepraration of handling counters in this function.
11 years ago
Victor Julien 5f307acace Pass ThreadVars ptr to various thread init funcs
To be able to register counters from AppLayerGetCtxThread, the
ThreadVars pointer needs to be available in it and thus in it's
callers:

- AppLayerGetCtxThread
- DecodeThreadVarsAlloc
- StreamTcpReassembleInitThreadCtx
11 years ago
Victor Julien b844d4315f dns: add memcap checking
Add memuse tracking and memcap checking to the DNS parsers. Memuse
is tracked globally and per flow (state).

Memcaps are also checked per flow and globally before memory allocs
are done.
11 years ago
Victor Julien 850fac84d6 dns: make DNSTransactionAlloc static 11 years ago
Victor Julien d97e93ea71 dns: add memcap options
Add per state and global memcap option parsing.
11 years ago
Victor Julien 0130a89d52 dns: fix dns configure code
Yaml layout changed. DNS had to be updated to retrievel value
for dns flood from the correct location in the config tree.
11 years ago
Victor Julien 80456f3e7d Bug 1083 and 1084: add valgrind suppressions
Add suppressions as these are minor issues and likely not bugs in
Suricata.
11 years ago
Victor Julien 32271bdb66 app-layer-ssl: fix unusual memory leak
In some cases the TLS state pointers to subject and issuerdn could
be overwritten by a new memory allocation, causing us to loose
track of the old.

This has been observed in the case of improper VLAN handling, where
it was suspected that multiple unrelated TLS streams were mangled
together.
11 years ago
Victor Julien 28f14b1ed3 app-layer-ssl: style fixes
Coding style fixes for TLS handshake parser.
11 years ago
Victor Julien b57ac888f8 app-layer-ssl: code cleanup
Don't alloc a void ptr and then cast in every operation. Instead,
alloc a SSLState ptr and only case to void on returning the ptr.
11 years ago
Eric Leblond 7d104fde1d util-device: use safe tailq foreach
The loop is freeing elements so we need to use the safe version
of TIALQ_FOREACH.

This fixes a valgrind error:

 Thread 1 Suricata-Main:
 Invalid read of size 8
    at 0x8E129C: LiveDeviceListClean (util-device.c:167)
    by 0x89B742: main (suricata.c:2284)
  Address 0x8382988 is 24 bytes inside a block of size 40 free'd
    at 0x4C2A70C: free (vg_replace_malloc.c:468)
    by 0x8E1297: LiveDeviceListClean (util-device.c:179)
    by 0x89B742: main (suricata.c:2284)
11 years ago
Victor Julien 84f14438c3 Bug 980: fix HTTP memory cleanup at shutdown
Buffers in per thread HTTP header, client body and server body storage
would be freed based on the usage indicator instead of the size
indicator.

As the usage indicator (e.g. hsbd_buffers_list_len) could be reset
while leaving the memory untouched for later reuse, the free function
would not iterate over all memory blocks.

Removed DrMemory suppressions as well.

Bug #980.
11 years ago
Eric Leblond 82a2dd859b af-packet: fix problem introduced in recent commit
Logic of patch 98e4a14f6d was correct
but implementation is wrong because TP_STATUS_KERNEL is equal to
zero and thus can not be evaluated in a binary operation. This patch
updates the logic by doing two tests.

Reported-by: Alessandro Guido
11 years ago
Anoop Saldanha d06a193012 Remove BUG_ON(1) in app layer event second stage preparation function.
This lets us single out and print rules that result in a failure, than
just post a core dump.
11 years ago
Ken Steele 92a821cdd9 Fix make distcheck for Tile
src/Makefile.am was missing util-mpm-ac-tile-small.c which caused
release tarballs for fail to build on Tile-Gx.
11 years ago
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.
11 years ago
Victor Julien 06f9b0adbf Cygwin: make configure pass with -Werror 11 years ago
Victor Julien 2eeddf969d Cygwin: fix compilation
tm-threads.c:1190:5: error: unknown type name ‘DWORD’
11 years ago
Victor Julien 2f14d1e94e Fix compiler warning:
array subscript has type ‘char’ [-Werror=char-subscripts]
11 years ago
Victor Julien e4b39a413a Fix coccinelle autotools check 11 years ago
Victor Julien 7fb860ac47 coccinelle: add --disable-coccinelle to configure
This allows disabling of the expensive cocci QA checks during
QA.
11 years ago
Victor Julien 0d280e88d0 pool thread: undo CLS alignment
This breaks clang on 32bit.

Test PoolThreadTestGrow01                                         : process killed by signal 11
11 years ago
Victor Julien d5fdfa4bc1 Fix unittest size_t printing on 32bit 11 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.
11 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.
11 years ago
Victor Julien e1e2ebe2da memcmp: convert all pointer arguments to be const pointers, like memcmp itself uses. 11 years ago
Victor Julien a9bf939441 dns log: cleanups 11 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.
11 years ago
Ken Steele bc29684df4 Remove GCC -no-strict-aliasing compiler flag.
GCC typically generates better code without the -no-strict-aliasing flag.
It is only required if code makes assumptiosn that break strict aliasing.
The unit tests pass on x86 and Tile without the flag.
11 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.
11 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.
11 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.
11 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.
11 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.
11 years ago