Commit Graph

5013 Commits (2002067fb1c1a3bfcf1f3a69d3ec84cf950e1010)
 

Author SHA1 Message Date
Eric Leblond 6630456a67 af-packet: fix livedev packets counter
Packets counter is incremented in AFPDumpCounters and it was
also incremented during packet reading. The result was a value
that is twice the expected result.

Spotted-by: Victor Julien <victor@inliniac.net>
11 years ago
Victor Julien f9213d7cc6 stream-tcp: proper error if segment pool init fails
Until now a PoolInit failure for the segment pools would result in
an abort() through BUG_ON(). This patch adds a proper error message,
then exits.

Bug #1108.
11 years ago
Victor Julien 7e38347d99 stream-tcp: fix error handling in segment pool
When TcpSegmentPoolInit fails (e.g. because of a too low memcap),
it would free the segment. However, the segment memory is managed
by the Pool API, which would also free the same memory location.
This patch fixes that.

Also, memset the structure before any checks are done, as the segment
memory is passed to TcpSegmentPoolCleanup in case of error as well.

Bug #1108
11 years ago
Victor Julien 9442dce451 commandline parsing: check optarg ptr before using it
Fixes:
** CID 1075221:  Dereference after null check  (FORWARD_NULL)
/src/suricata.c: 1344 in ParseCommandLine()

The reason it gave this warning is that in other paths using optarg
there was a check, so the checker assumed optarg can be NULL.
11 years ago
Victor Julien 9f2ce16ef3 icmpv6: Fix Coverity warnings on ND_* types
This patch fixes:
** CID 1187544:  Missing break in switch  (MISSING_BREAK)
/src/decode-icmpv6.c: 268 in DecodeICMPV6()

** CID 1187545:  Missing break in switch  (MISSING_BREAK)
/src/decode-icmpv6.c: 270 in DecodeICMPV6()

** CID 1187546:  Missing break in switch  (MISSING_BREAK)
/src/decode-icmpv6.c: 272 in DecodeICMPV6()

** CID 1187547:  Missing break in switch  (MISSING_BREAK)
/src/decode-icmpv6.c: 274 in DecodeICMPV6()

It duplicates the logic instead of adding 'fall through' statements
as the debug statements were wrong and confusing. For ND_REDIRECT
all 5 ND_* types would have been printed.
11 years ago
Ken Steele e381af98dd Only update mPipe stats occasionally around the packet loop.
Check for termination or stats update only once every 10,000 times
around the mPipe packet processing loop, to reduce locking.
11 years ago
Victor Julien 3c9a135c0f isdataat: fix coverity issue
During keyword setup there was a path that in theory could lead to
indexing an array with a negative int.

Coverity 400608
11 years ago
Victor Julien aa8918abd1 fast-pattern: fix error check in keyword setup
Check the right variable. Coverity 1038096
11 years ago
Victor Julien 3fa958b9a7 byte_extract/test/jump: fix coverity issues
During keyword setup there was a path that in theory could lead to
indexing an array with a negative int.

Coverity 992695, 400605, 400604
11 years ago
Victor Julien e82c6efaca Minor cleanups
Remove useless checks: coverity 1038130, 1038131, 1038132
Small other fixes: coverity 1164817
11 years ago
Victor Julien 2b734b8d8a htp: fix pointer check logic
Don't check pointer after it has already been used.

Coverity 1047545
11 years ago
Victor Julien abdc0072aa rule reload: fix unitialized memory access on error
Coverity 709220
11 years ago
Victor Julien d8c486231c output-json: fix minor memory leak on error
If the json file couldn't be opened, a minor memory leak would occur.

Coverity 1166039
11 years ago
Victor Julien b4ab9a0a3c ftp: fix memory leak
db pointers in both directions were not freed. This patch frees them
in the state free function.

Bug #1090
11 years ago
Victor Julien d63df6937c tls: fix uninitialized var use
errcode wasn't initialized and in some code paths it remained
uninitialized, leading to us evaluating this uninitialized value.

Bug #1091
11 years ago
Victor Julien 95fa5ae1d2 smtp: don't read uninitialized value
If a reply would be seen before a command, a read of a uninitialized
value could happen.

This patch adds a check for this.

Bug #1089.
11 years ago
Victor Julien 0416a8428d htp: don't assume HTPCallbackRequestLine is the first callback
By assuming that HTPCallbackRequestLine would always be run first,
an memory leak was introduced. It would not check if user data already
existed in the tx, causing it to overwrite the user data pointer is
it already existed.

Bug #1092.
11 years ago
Victor Julien 42227e8713 configure: fix typo in libjansson warning message 11 years ago
Victor Julien 4e561d6b20 pcap/afpacket: update counters at exit
In really short Suricata runtimes the capture counters would not
be updated. This patch does a force update at the end of the
capture loops in pcap and af-packet.
11 years ago
Victor Julien 3ec6bcf284 Make sure tls-events is part of the dist
Added it to Makefile.am so it will be part of the dist created by
make distcheck.
11 years ago
Victor Julien a97662e08c dns: if no (valid) config is found, use defaults
This patch will set up probing parsers if no (valid) config is
found.

Add a warning in those cases.
11 years ago
Victor Julien ab10c0a099 app-layer: tell pp registrar if config was found
The probing parser registration function
AppLayerProtoDetectPPParseConfPorts was a void, meaning it would
give no feedback to the registering protocol implementation. If a
config was missing, it would just give up.

This patch changes it to return a bool. 0 if no config was found,
1 if a config was found.

This allows the caller to setup a default case.
11 years ago
Victor Julien ec4288f7c2 dns yaml: fix detect ports of tcp relying on udp
The probing parser detection ports yaml settings of the TCP part
of the DNS parser accidentally used udp as protocol string, causing
the wrong part of the YAML to be evaluated.
11 years ago
Victor Julien ad51a57b91 app-layer-event: make error reporting more clear
If the protocol is disabled, app-layer-event would print a cryptic
error message. This patch makes sure we inform the user the protocol
is in fact disabled.
11 years ago
Victor Julien df10559d80 dns: fix message of decoder rule 2240008
The message now reflects that the rule matches on:
    app-layer-event:dns.state_memcap_reached;
11 years ago
Victor Julien d2a6b61d76 yaml: add and comment missing dns settings
DNS memcap settings "global-memcap" and "state-memcap" were missing.

Additionally, add request-flood setting.
11 years ago
Victor Julien 2421da6eec Update Changelog for 2.0rc1 release 11 years ago
Victor Julien f791d0f5c5 vlan/QinQ: add vlan_qinq counter
This patch introduces a new counter "decoder.vlan_qinq". It counts
packets that have more than two stacked vlan layers.

Packets with 2 vlan layers will both increment "decoder.vlan" and
"decoder.vlan_qinq".
11 years ago
Victor Julien c95df281e3 eve-log: add warning if enabled but not supported
If we're not compiled against libjansson, the eve-log output is not
available. This patch adds a warning.
11 years ago
Jason Ish 33e4cc065f Promote nodes set with --set to sequence nodes as needed.
A node isn't known to be a sequence node until the YAML is parsed.
If a node sequence node was set on the command line, promote
it to a sequence node when it is discovered by YAML to be
a sequence node.

Fixes comment #18 in issue 921.
11 years ago
Victor Julien 18edec8769 vlan: support QinQ ethernet types
Add support for 802.1AD and 802.1QinQ in ethernet and vlan parsing.

Tickets: #814, #1103, #1104
11 years ago
Victor Julien 91f8c33b0a defrag: fix reassembly with vlan
When creating a pseudo packet with the reassembled IP packet, the
parent's vlan id or id's are also needed. The defrag packet is run
through decode and the flow engine, where the vlan id is necessary
for connecting the packet to the correct flow.
11 years ago
Eric Leblond b603ad62e5 af-packet: declare TP_STATUS_VLAN_VALID if needed
Some old distribution don't ship recent enough linux header. This
result in TP_STATUS_VLAN_VALID being undefined. This patch defines
the constant and use it as it is used in backward compatible method
in the code: the flag is not set by kernel and a test on vci value
will be made.

This should fix https://redmine.openinfosecfoundation.org/issues/1106
11 years ago
Victor Julien f7b1aefaf4 Bug 1107: decoders: bail out on pseudo packets
Flow-timeout code injects pseudo packets into the decoders, leading
to various issues. For a full explanation, see:
  https://redmine.openinfosecfoundation.org/issues/1107

This patch works around the issues with a hack. It adds a check to
each of the decoder entry points to bail out as soon as a pseudo
packet from the flow timeout is encountered.

Ticket #1107.
11 years ago
Victor Julien 85760a7044 Flow: fix flow reference cnt issues
FlowReference stores the flow in the destination pointer and increases
the flow reference counter (use_cnt). This should only be called once
per destination pointer. The reference counter is decremented when
FlowDereference is called. Multiple FlowReference calls would lead to
multiple use_cnt bumps, while there would be only one FlowRereference.
This lead to a use_cnt that would never become 0, meaning the flow
would stay in the hash for the entire lifetime of the process.

The fix here is to check if the destination pointer is already set to
the flow. If so, we don't increase the reference counter.

As this is really a bug, this condition will lead to a BUG_ON if the
DEBUG_VALIDATION checking is enabled.
11 years ago
Victor Julien fdca557e01 ipv4 decoder: set 'invalid' event on icmpv6
ICMPv6 on IPv4 is invalid, so if we encounter this we set an event
and flag the packet as invalid.

Ticket #1105.
11 years ago
Victor Julien 43aa74d711 debug-validation: fix packet check
On fragments and invalid packets we can have p->proto set, while the
matching protocol header pointer is null.
11 years ago
Victor Julien 01b80e2d8f detect ip-only: update radix usage
Update IP-only lookups to the changed radix API.

The return of user_data is treated as a succesful lookup, instead of
the node.
11 years ago
Victor Julien b75eb77295 host-os-info: update radix lookups
Update host OS lookups to use the new API.

The return of user_data is treated as a succesful lookup, instead of
the node.
11 years ago
Victor Julien fd193107de unused reputation: radix update
Update the unused reputation code to compile after radix update.
11 years ago
Victor Julien cd91738a4b defrag: update radix usage
Update defrag timeout lookup to use the updated radix API.

The return of user_data is treated as a succesful lookup, instead of
the node.
11 years ago
Victor Julien d0a26c6a17 radix: update HTP config lookup logic
The HTP config tree is a radix. The lookups are updated to the new API.
The return of user_data is treated as a succesful lookup, instead of
the node itself.
11 years ago
Victor Julien 3b914eb7ba radix: update tests after API change
This patch updates all the radix tests to the new API. In most cases
it just passes a NULL user data return pointer.

It also removes the tests related to SC_RADIX_NODE_USERDATA, as this
macro is removed.

Bug #1073
11 years ago
Victor Julien 7b4be598c4 radix: don't modify node prefix on lookup
The radix tree stores user data. However, it had no function to return
this data to the consumers of the API. Instead, on lookup, it would
set a field "user_data_result" in the nodes prefix structure which
could then be read by the caller.

Apart for this not being a very nice design as it exposes API internals
to the caller, it is not thread safe. By updating the global data
structure without any form (or suggestion) of locking, threads could
overwrite the same field unexpectedly.

This patch modifies the lookup logic to get rid of this stored
user_data_result. Instead, all the lookup functions how take an
addition argument: void **user_data_result.

Through this pointer the user data is returned. It's allowed to be
NULL, in this case the user data is ignored.

This is a significant API change, that affects a lot of tests and
callers. These will be updated in follow up patches.

Bug #1073.
11 years ago
Jason Ish 7a9da787f9 Don't alert on valid ICMP6 solicit/advert messages.
Handles ND_ROUTER_SOLICIT, ND_ROUTER_ADVERT, ND_NEIGHBOUR_ADMIN,
ND_NEIGHBOUR_SOLICIT and ND_REDIRECT.  Don't set ICMPV6_UNKONWN_CODE
if code is the expected value of 0.
11 years ago
Ken Steele 65d8ae937d Remove extra ] configure.ac for HAVE_DETECT_DISABLED
Saw a warning about unknow command ']' running distcheck and tracked it back
to this error.
11 years ago
Victor Julien 7726cecbaa Fix CUDA test warning. 11 years ago
Anoop Saldanha 29fb9b099a CUDA: Fix header file resolution issues. 11 years ago
Eric Leblond 2cd6e1287f af-packet: no VLAN id from msg header for old kernel
This patch uses the new function SCKernelVersionIsAtLeast to know
that we've got a old kernel that do not strip the VLAN header from
the message before sending it to userspace.
11 years ago
Eric Leblond 1ccb93ab50 Add new function to work on kernel version.
This patch adds a new file containing a function that can be used
to compare the version number of the running kernel with a specific
version.
11 years ago