Commit Graph

4997 Commits (1bd189a07633aa92eb524c68c2873bfcef4e233e)
 

Author SHA1 Message Date
Victor Julien 4b57d0272c alert-debug log cleanups
Make all funcs but registration static.
Remove stale registation prototypes.
Move registation func to the bottom.
11 years ago
Victor Julien 504f39adef log-tls: convert to packet logger API
This patch converts log-tls to use the packet logger API. The packet
logger API was choosen as the TLS parser is not transaction aware.

To make sure the state is only logged once, the flag
SSL_AL_FLAG_STATE_LOGGED was added to the parser. This flag is checked
by the condition function, and set at the end of the Logger function.
11 years ago
Victor Julien bcf5c1f2fb log-tls: clean ups
Make all functions static. Remove separate ipv4 and ipv6 registration
functions. Move register function to the bottom so that we no longer
need function prototype declarations.
11 years ago
Victor Julien 28c4083700 dns: convert dns logger to TX logger API
Make sure to use the new logger TX API. For this the transaction
handling was improved as well.
11 years ago
Victor Julien 35aa6c1e66 Convert log-drop to packet logger api. 11 years ago
Victor Julien 15eb4b292d TX logging API: convert HTTP log
Convert the HTTP log to the new TX logging API.
11 years ago
Victor Julien ad70793f78 Introduce TX logging API
This patch introduces a new API for logging transactions from
tx-aware app layer protocols. It runs all the registered loggers
from a single thread module. This thread module takes care of the
transaction handling and flow locking. The logger just gets a
transaction to log out.

All loggers for a protocol will be run at the same time, so there
will not be any timing differences.

Loggers will no longer act as Thread Modules in the strictest sense.
The Func is NULL, and SetupOuputs no longer attaches them to the
thread module chain individually. Instead, after registering through
OutputRegisterTxModule, the setup data is used in the single logging
module.

The logger (LogFunc) is called for each transaction once, at the end
of the transaction.
11 years ago
Victor Julien 4049c2f74c Packet logging API: convert unified2
Convert unified2 alert to new logging API.
11 years ago
Victor Julien d43ac9ae98 Introduce packet logging output API
This patch introduces a new API for outputs that log based on the
packet, such as alert outputs. In converts fast-log to the new API.

The API gets rid of the concept of each logger being a thread module,
but instead there is one thread module that runs all packet loggers.
Through the registration function OutputRegisterPacketModule a log
module can register itself to be considered for each packet.

Each logger registers itself to this new API with 2 functions and the
OutputCtx object that was already used in the old implementation.
The function pointers are:

LogFunc:       the log function

ConditionFunc: this function is called before the LogFunc and only
               if this returns TRUE the LogFunc is called.

For a simple alert logger like fast-log, the condition function will
simply return TRUE if p->alerts.cnt > 0.
11 years ago
Victor Julien 3474c36b54 no-detect: handle protocols that have no logger
If a protocol parser is active without a logger when detection is
disabled, the transaction handling logic would fail. Now it will
return the proper tx id so we can clean up the complete transactions.
11 years ago
Victor Julien f4872a2f08 Add --disable-detection configure option
Add --disable-detection configure option to compile Suricata with
detection disabled.
11 years ago
Victor Julien 6a3621f2fe Error out if -s/-S are used with disable detect
When Suricata is started with --disabled-detection, the -s and -S
options make no sense. So error out.
11 years ago
Victor Julien 3e2205d08f detect-less: disable raw reassembly
When using --disable-detection automatically disable raw stream
reassembly by forcing stream.reassembly.raw to be false.
11 years ago
Victor Julien 5cc880c5c1 detect-less: add log only TX handling function
When running w/o detect, TX cleanup handling needs to ignore the
inspect_id as it's only updated by detect.

This patch introduces a new ActiveTx handler for logging only:
AppLayerTransactionGetActiveLogOnly

If --disable-detection is passed on the commandline, this function
is registered.
11 years ago
Victor Julien 50f5b246db Update main loop to handle detect-less
Update main startup and shutdown loops to work will when detect
is disabled. In this case de_ctx remains NULL.
11 years ago
Victor Julien 0e08f4b6fc update runmodes to handle detect-less
In runmodes setup, consider a NULL de_ctx to mean detect is disabled.
11 years ago
Victor Julien dfda0cd4b6 flow-time: handle detect-less case
Flow timeout code keeps track of thread module running detect, and
fails (hard) if it doesn't find it.

This changeset retrieves the global g_detect_disabled and passes
it to the timeout handling code during setup.
11 years ago
Victor Julien 258778cde4 Introduce g_detect_disabled global
This global will be set to TRUE if detect is disabled. The reason for
adding a global is that there currently is no clean way to pass
configuration options to management threads.
11 years ago
Victor Julien b44ec80590 Add --disable-detection commandline option
Flags the SuriInstance that the detection engine should be disabled.
Actual disabling is not yet implemented.
11 years ago
Victor Julien ef40fe1f31 flow-timeout: change error logic
If FlowForceReassemblyForFlowV2 can't get packets to inject into the
engine, until now it would bail and retry later. In case of resource
starvation issues, this would cause a lot of lock contention, as the
flow manager would try over and over again.

This patch limits FlowForceReassemblyForFlowV2 to one try per flow,
if it fails... bad luck. It will only fail in serious conditions,
which means we must prefer the health of the engine over the proper
inspection of the flow in question.
11 years ago
Victor Julien ad7eff555d app-layer-proto: speed up
AppLayer Proto detection code uses a mix of pattern search and
"probing parsers". The pattern search validates potential matches
using a single pattern search algo. The code was using SpmSearch
for this, but this made it inefficient as it builds a BoyerMoore
context for each search. This lead to significant memory pressure,
especially on high speed/bandwidth boxes.

This patch switches the search calls to BoyerMoore and BoyerMoore-
Nocase directly. This can be done as the ctx' were available already.
11 years ago
Victor Julien 347c0df9c4 app-layer-event: refactor
Move app layer event handling into app-layer-event.[ch].
Convert 'Set' macro's to functions.
Get rid of duplication in Set and SetRaw. Set now calls SetRaw.
Fix potentential int overflow condition in the event storage.
Update callers.
11 years ago
Victor Julien 4ce53753bc app-layer: shrink AppLayerParserState
Change layout to be more efficient, shrinks structure with 8 bytes.
11 years ago
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