]> git.ipfire.org Git - thirdparty/suricata.git/log
thirdparty/suricata.git
7 years agorunmodes: fix 'threads' option parsing 2942/head
Victor Julien [Fri, 13 Oct 2017 07:22:49 +0000 (09:22 +0200)] 
runmodes: fix 'threads' option parsing

Don't cast int to uint8_t for no reason. Add warning that upper
limit for theads is 1024.

Small code cleanups.

Bug: #2243

7 years agooutput: harden output deinit
Victor Julien [Sun, 15 Oct 2017 19:25:07 +0000 (21:25 +0200)] 
output: harden output deinit

If thread setup fails allow output deinit code to be called with
NULL data without crashing.

7 years agostream: improve error handling of ssn pool
Victor Julien [Fri, 13 Oct 2017 07:05:02 +0000 (09:05 +0200)] 
stream: improve error handling of ssn pool

With large number of threads the default memcap leads to pool setup
failures. Make sure these are reported properly so that the user
knows what is going on.

Bug: #2242

7 years agodetect/state: fix offset mask logic
qiangbei [Tue, 17 Oct 2017 07:01:37 +0000 (09:01 +0200)] 
detect/state: fix offset mask logic

changed 0xef to 0x7f

7 years agodcerpc: set hard limit for stub data buffer size
Victor Julien [Tue, 17 Oct 2017 06:55:58 +0000 (08:55 +0200)] 
dcerpc: set hard limit for stub data buffer size

Avoid traffic being able to endlessly grow the stub buffer by
setting a 1MB hard limit.

Bug #2241

7 years agodetect: don't rescan when just distance is used
Victor Julien [Sat, 4 Mar 2017 12:40:39 +0000 (13:40 +0100)] 
detect: don't rescan when just distance is used

Content inspection optimization: when just distance is used without
within we don't need to search recursively.

E.g. content:"a"; content:"b"; distance:1; will scan the buffer for
'a' and when it finds 'a' it will scan the remainder for 'b'. Until
now, the failure to find 'b' would lead to looking for the next 'a'
and then for 'b' after that. However, we already inspected the
entire buffer for 'b', so we know this will fail.

7 years agodetect: avoid needless recursive scanning
Victor Julien [Fri, 3 Mar 2017 14:38:43 +0000 (15:38 +0100)] 
detect: avoid needless recursive scanning

Don't recursively inspect a detect list if the recursion
doesn't increase chance of success.

7 years agodoc/file_data: add note on negated matching 2926/head
Victor Julien [Thu, 5 Oct 2017 09:11:13 +0000 (11:11 +0200)] 
doc/file_data: add note on negated matching

Explain issue #2216 and how to avoid it.

Backport http_server_body notes from 4.0 branch.

7 years agodebug: free pcre memory used for output filtering
Victor Julien [Tue, 3 Oct 2017 08:31:39 +0000 (10:31 +0200)] 
debug: free pcre memory used for output filtering

7 years agotls: don't set event on small input data
Victor Julien [Fri, 29 Sep 2017 17:10:46 +0000 (19:10 +0200)] 
tls: don't set event on small input data

On very small data the max loop count could be 0. Make sure
it's always at least 1.

7 years agoprscript: update urls to use OISF repo
Eric Leblond [Sat, 30 Sep 2017 10:35:14 +0000 (12:35 +0200)] 
prscript: update urls to use OISF repo

7 years agodns: fix last timestamp handling
Derek [Thu, 7 Sep 2017 03:23:25 +0000 (20:23 -0700)] 
dns: fix last timestamp handling

Fixes incorrect variable in ticket #2207

In app-layer-dns-tcp.c in the DNSTCPResponseParse function
a variable is set to last_req when it should be last_resp.
This makes it consistent with UDP DNS response parsing.

7 years agoaf-packet: free bpf program
Eric Leblond [Mon, 18 Sep 2017 18:30:20 +0000 (20:30 +0200)] 
af-packet: free bpf program

This fixes a small memory leak when Suricata is running with a
BPF filter.

7 years agoaf-packet: call thread deinit function
Eric Leblond [Mon, 18 Sep 2017 18:24:29 +0000 (20:24 +0200)] 
af-packet: call thread deinit function

7 years agodoc: reflect most recent cpu affinity settings
Andreas Herz [Sat, 9 Sep 2017 21:22:06 +0000 (23:22 +0200)] 
doc: reflect most recent cpu affinity settings

Some settings like output-cpu-set never been used and detect got renamed
to worker. This reflects those changes already present in the yaml also
within the documentation.

7 years agoapp-layer-ssl: fix bug with >255 records in one stream
Mats Klepsland [Wed, 9 Aug 2017 19:07:03 +0000 (21:07 +0200)] 
app-layer-ssl: fix bug with >255 records in one stream

7 years agorule-parser: bump sids within siggroup test
Andreas Herz [Fri, 11 Aug 2017 21:53:55 +0000 (23:53 +0200)] 
rule-parser: bump sids within siggroup test

7 years agorule-parser: detect duplicate rev keyword
Andreas Herz [Fri, 11 Aug 2017 21:25:44 +0000 (23:25 +0200)] 
rule-parser: detect duplicate rev keyword

7 years agorule-parser: detect duplicate sid keyword
Andreas Herz [Fri, 11 Aug 2017 21:24:22 +0000 (23:24 +0200)] 
rule-parser: detect duplicate sid keyword

7 years agorule-parser: detect duplicate classtype keyword
Andreas Herz [Fri, 11 Aug 2017 21:11:46 +0000 (23:11 +0200)] 
rule-parser: detect duplicate classtype keyword

7 years agoafpacket: free ring mem on error
Victor Julien [Tue, 29 Aug 2017 10:57:53 +0000 (12:57 +0200)] 
afpacket: free ring mem on error

7 years agoBug #2201: af_packet - treat BPF filter error as fatal
Alexander Gozman [Sun, 20 Aug 2017 12:22:34 +0000 (15:22 +0300)] 
Bug #2201: af_packet - treat BPF filter error as fatal

There is no need to try to set erroneous BPF filter again and again. Such attempts
lead to constant mmap() calls without corresponding munmap() when 'use-mmap' is enabled.

7 years agoapp-layer-tls: don't decode client certificates
Mats Klepsland [Wed, 2 Aug 2017 12:49:43 +0000 (14:49 +0200)] 
app-layer-tls: don't decode client certificates

Decoding client certificate overwrites the validity dates from the
server certificate, so we therefore don't decode it, since we don't
do anything with it (right now) anyway.

Fixes Bug #2050

7 years agodetect-msg: cleanup error message
Victor Julien [Tue, 1 Aug 2017 08:13:10 +0000 (10:13 +0200)] 
detect-msg: cleanup error message

7 years agorule-parser: ignore duplicated msg keyword
Andreas Herz [Sat, 29 Jul 2017 22:14:50 +0000 (00:14 +0200)] 
rule-parser: ignore duplicated msg keyword

7 years agoaf-packet: optimize BPF
Eric Leblond [Fri, 30 Jun 2017 13:00:40 +0000 (15:00 +0200)] 
af-packet: optimize BPF

This patch turn on code optimization on BPF filter building by
libpcap. This allow to reduce the size of the BPF bytecode and
thus increase the size of BPF filter supported by Suricata.

Reported-by: Martijn van Oosterhout
7 years agogcc7: format-truncation fix for lua
Victor Julien [Fri, 14 Jul 2017 09:05:51 +0000 (11:05 +0200)] 
gcc7: format-truncation fix for lua

8 years agoredis: support for rpush in list mode 2872/head
Julian [Sun, 28 May 2017 10:22:25 +0000 (12:22 +0200)] 
redis: support for rpush in list mode

This adds a new redis mode rpush. Also more consistent config keywords orientated at the redis command: lpush and publish.
Keeping list and channel config keywords for backwards compatibility. Removed unnecessary checks.

8 years agochangelog: update for 3.2.3 release suricata-3.2.3
Victor Julien [Wed, 12 Jul 2017 14:51:19 +0000 (16:51 +0200)] 
changelog: update for 3.2.3 release

8 years agoder/asn1: limit recursion
Victor Julien [Mon, 10 Jul 2017 08:15:54 +0000 (10:15 +0200)] 
der/asn1: limit recursion

Limit the number of recursive calls in the DER/ASN.1 decoder to avoid
stack overflows.

Found using AFL.

8 years agostream: don't reset state on syn/ack resend
Victor Julien [Mon, 10 Jul 2017 12:33:09 +0000 (14:33 +0200)] 
stream: don't reset state on syn/ack resend

Bug #1958.

The reset was originally created for issue #523, but that works
well without the reset as well.

8 years agoradix: fix risky malloc call 2836/head
Victor Julien [Thu, 13 Jul 2017 08:04:47 +0000 (10:04 +0200)] 
radix: fix risky malloc call

GCC7 said:
  CC       util-radix-tree.o
In file included from util-debug-filters.h:29:0,
                 from util-debug.h:34,
                 from suricata-common.h:421,
                 from util-radix-tree.c:26:
util-radix-tree.c: In function ‘SCRadixAddKey’:
util-mem.h:177:12: error: argument 1 range [1844674407156206796818446744073709551615] exceeds maximum object size 9223372036854775807 [-Werror=alloc-size-larger-than=]
     ptrmem = malloc((a)); \
     ~~~~~~~^~~~~~~~~~~~~
util-radix-tree.c:749:42: note: in expansion of macro ‘SCMalloc’
             if ( (inter_node->netmasks = SCMalloc((node->netmask_cnt - i) *
                                          ^~~~~~~~
In file included from suricata-common.h:69:0,
                 from util-radix-tree.c:26:
/usr/include/stdlib.h:443:14: note: in a call to allocation function ‘malloc’ declared here
 extern void *malloc (size_t __size) __THROW __attribute_malloc__ __wur;
              ^~~~~~

scan-build said:
util-radix-tree.c:749:42: warning: Call to 'malloc' has an allocation size of 0 bytes
            if ( (inter_node->netmasks = SCMalloc((node->netmask_cnt - i) *
                                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./util-mem.h:177:14: note: expanded from macro 'SCMalloc'
    ptrmem = malloc((a)); \
             ^~~~~~~~~~~
1 warning generated.

8 years agogcc7: fix format-truncation warnings in runmodes
Victor Julien [Thu, 13 Jul 2017 07:57:40 +0000 (09:57 +0200)] 
gcc7: fix format-truncation warnings in runmodes

Example:

util-runmodes.c: In function ‘RunModeSetIPSAutoFp’:
util-runmodes.c:496:40: error: ‘snprintf’ output may be truncated before the last format character [-Werror=format-truncation=]
         snprintf(qname, sizeof(qname), "pickup%d", thread+1);
                                        ^~~~~~~~~~
util-runmodes.c:496:9: note: ‘snprintf’ output between 8 and 17 bytes into a destination of size16
         snprintf(qname, sizeof(qname), "pickup%d", thread+1);
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Solved by reducing 'thread' to a uint16_t and limiting the max
thread count to 1024.

8 years agogcc7: fix format truncation warning
Victor Julien [Thu, 13 Jul 2017 07:06:39 +0000 (09:06 +0200)] 
gcc7: fix format truncation warning

detect-rpc.c: In function ‘DetectRpcParse’:
detect-rpc.c:225:50: error: ‘%s’ directive argument is null [-Werror=format-truncation=]
                 SCLogError(SC_ERR_INVALID_VALUE, "invalid rpc option %s",args[i]);
                                                  ^
util-debug.h:239:77: note: in definition of macro ‘SCLogErr’
             int _sc_log_ret = snprintf(_sc_log_msg, SC_LOG_MAX_LOG_MSG_LEN, __VA_ARGS__);   \
                                                                             ^~~~~~~~~~~
detect-rpc.c:225:17: note: in expansion of macro ‘SCLogError’
                 SCLogError(SC_ERR_INVALID_VALUE, "invalid rpc option %s",args[i]);
                 ^~~~~~~~~~

8 years agogcc7: fixes for format string warnings
Victor Julien [Wed, 12 Jul 2017 16:44:33 +0000 (18:44 +0200)] 
gcc7: fixes for format string warnings

GCC 7.1.1 on Fedora gave several warnings with -Wimplicit-fallthrough
and -Wformat-truncation

This patch addresses the warnings.

8 years agopcap: fix linktype raw issues 2825/head
Victor Julien [Tue, 27 Jun 2017 13:07:40 +0000 (15:07 +0200)] 
pcap: fix linktype raw issues

On OpenBSD 6.0 and 6.1 the following pcap gets a datalink type of
101 instead of our defined DLT_RAW.

    File type:           Wireshark/tcpdump/... - pcap
    File encapsulation:  Raw IP
    File timestamp precision:  microseconds (6)
    Packet size limit:   file hdr: 262144 bytes
    Number of packets:   23
    File size:           11 kB
    Data size:           11 kB
    Capture duration:    7,424945 seconds
    First packet time:   2017-05-25 21:59:31,957953
    Last packet time:    2017-05-25 21:59:39,382898
    Data byte rate:      1536 bytes/s
    Data bit rate:       12 kbps
    Average packet size: 496,00 bytes
    Average packet rate: 3 packets/s
    SHA1:                120cff9878b93ac74b68fb9216027bef3b3c018f
    RIPEMD160:           35fa287bf30d8be8b8654abfe26e8d3883262e8e
    MD5:                 13fe4bc50fe09bdd38f07739bd1ff0f0
    Strict time order:   True
    Number of interfaces in file: 1
    Interface #0 info:
                         Encapsulation = Raw IP (7/101 - rawip)
                         Capture length = 262144
                         Time precision = microseconds (6)
                         Time ticks per second = 1000000
                         Number of stat entries = 0
                         Number of packets = 23

On Linux it is 12.

On the tcpdump/libpcap site the DLT_RAW is defined as 101:
http://www.tcpdump.org/linktypes.html

Strangely, on OpenBSD the DLT_RAW macro is defined as 14 as expected.
So for some reason, libpcap on OpenBSD uses 101 which seems to match
the tcpdump/libpcap documentation.

So this patch adds support for datalink 101 as RAW.

8 years agolog: destroy file mutex
Victor Julien [Wed, 28 Jun 2017 07:23:42 +0000 (09:23 +0200)] 
log: destroy file mutex

8 years agolog: wrap rotation and write in lock
Jason Ish [Mon, 26 Jun 2017 17:04:46 +0000 (11:04 -0600)] 
log: wrap rotation and write in lock

The application log is subject to rotation, so the check for
rotation, the actual rotation and write needs to be done under
lock to ensure the file pointer is in a consisten state
at the time of write().

Fixes issue:
https://redmine.openinfosecfoundation.org/issues/2155

8 years agochangelog: update for 3.2.2 release suricata-3.2.2
Victor Julien [Wed, 7 Jun 2017 12:38:29 +0000 (14:38 +0200)] 
changelog: update for 3.2.2 release

8 years agopcre: on ppc64 disable only for specific versions 2758/head
Victor Julien [Thu, 13 Apr 2017 07:58:36 +0000 (09:58 +0200)] 
pcre: on ppc64 disable only for specific versions

Disable jit only for libpcre 8.39 and 8.40 as those were the buggy
versions.

Thanks to Zoltán Herczeg.

8 years agopcre: disable jit on powerpc64
Victor Julien [Thu, 6 Apr 2017 11:05:35 +0000 (13:05 +0200)] 
pcre: disable jit on powerpc64

It appears that both using gcc and clang something gets misoptimised
around pcre's jit. So disable jit for now.

8 years agoluajit: cleanup states before return to pool 2757/head
Victor Julien [Thu, 1 Jun 2017 21:49:28 +0000 (23:49 +0200)] 
luajit: cleanup states before return to pool

8 years agolua/streaming: fix http body logging
Victor Julien [Thu, 1 Jun 2017 21:15:43 +0000 (23:15 +0200)] 
lua/streaming: fix http body logging

8 years agodefrag: (windows) detect more overlaps 2727/head
Jason Ish [Mon, 6 Mar 2017 20:38:04 +0000 (14:38 -0600)] 
defrag: (windows) detect more overlaps

8 years agodefrag: (linux) fix an error in overlapping fragments
Jason Ish [Mon, 6 Mar 2017 17:23:48 +0000 (11:23 -0600)] 
defrag: (linux) fix an error in overlapping fragments

If a subsequent fragment has a lower offset than a previous
one and overlaps, trim off the beginning of the previous
fragment.

Based on an issue reported privately.

8 years agodefrag: use new unit test macros
Jason Ish [Mon, 6 Mar 2017 03:17:47 +0000 (21:17 -0600)] 
defrag: use new unit test macros

Also reformat unit test functions to Suricata style.

8 years agodoc: rephrase nocase placement explanation
Andreas Herz [Tue, 30 May 2017 20:46:47 +0000 (22:46 +0200)] 
doc: rephrase nocase placement explanation

8 years agolog-tlsstore: fix error handling
Eric Leblond [Fri, 19 May 2017 09:34:38 +0000 (11:34 +0200)] 
log-tlsstore: fix error handling

In case of realloc error, the length of the encoding buffer was not
reset and this could result in trying to write to NULL pointer.

8 years agounix socket: improve output of unix mode 2720/head
Victor Julien [Wed, 24 May 2017 19:30:48 +0000 (21:30 +0200)] 
unix socket: improve output of unix mode

8 years agodns: fix log filtering 2719/head
Jason Ish [Tue, 9 May 2017 23:40:56 +0000 (17:40 -0600)] 
dns: fix log filtering

Previously only a subset of the records could be selected
in custom. Now allow any to be selected.

8 years agomodbus: fix compiler warnings about alignment
Victor Julien [Wed, 5 Apr 2017 19:19:33 +0000 (15:19 -0400)] 
modbus: fix compiler warnings about alignment

app-layer-modbus.c:1226:39: warning: taking address of packed member 'transactionId' of class or structure 'ModbusHeader_' may result in an unaligned pointer value [-Waddress-of-packed-member]
    if (ModbusExtractUint16(modbus, &(header->transactionId), input, input_len, &offset)    ||
                                      ^~~~~~~~~~~~~~~~~~~~~
app-layer-modbus.c:1228:39: warning: taking address of packed member 'protocolId' of class or structure 'ModbusHeader_' may result in an unaligned pointer value [-Waddress-of-packed-member]
        ModbusExtractUint16(modbus, &(header->protocolId), input, input_len, &offset)       ||
                                      ^~~~~~~~~~~~~~~~~~
app-layer-modbus.c:1230:39: warning: taking address of packed member 'length' of class or structure 'ModbusHeader_' may result in an unaligned pointer value [-Waddress-of-packed-member]
        ModbusExtractUint16(modbus, &(header->length), input, input_len, &offset)           ||
                                      ^~~~~~~~~~~~~~
3 warnings generated.

Bug #2088

8 years agopool: fix compiler warning
Victor Julien [Wed, 5 Apr 2017 13:13:17 +0000 (15:13 +0200)] 
pool: fix compiler warning

clang-4.0 reported:

util-pool.c:242:13: warning: logical not is only applied to the left hand side of this bitwise operator [-Wlogical-not-parentheses]
        if (! pb->flags & POOL_BUCKET_PREALLOCATED) {
            ^           ~
util-pool.c:242:13: note: add parentheses after the '!' to evaluate the bitwise operator first
        if (! pb->flags & POOL_BUCKET_PREALLOCATED) {
            ^
              (                                   )
util-pool.c:242:13: note: add parentheses around left hand side expression to silence this warning
        if (! pb->flags & POOL_BUCKET_PREALLOCATED) {
            ^
            (          )
util-pool.c:261:13: warning: logical not is only applied to the left hand side of this bitwise operator [-Wlogical-not-parentheses]
        if (! pb->flags & POOL_BUCKET_PREALLOCATED) {
            ^           ~
util-pool.c:261:13: note: add parentheses after the '!' to evaluate the bitwise operator first
        if (! pb->flags & POOL_BUCKET_PREALLOCATED) {
            ^
              (                                   )
util-pool.c:261:13: note: add parentheses around left hand side expression to silence this warning
        if (! pb->flags & POOL_BUCKET_PREALLOCATED) {
            ^
            (          )
2 warnings generated.

8 years agoaf-packet: fix cppcheck false positive
Victor Julien [Mon, 3 Apr 2017 14:09:18 +0000 (16:09 +0200)] 
af-packet: fix cppcheck false positive

[src/source-af-packet.c:1903]: (error) Resource leak: fd

8 years agobug 2113: unix-socket start up race
Victor Julien [Tue, 16 May 2017 07:39:02 +0000 (09:39 +0200)] 
bug 2113: unix-socket start up race

8 years agoflow-worker: clean up thread init 2634/head
Victor Julien [Thu, 16 Feb 2017 15:41:06 +0000 (16:41 +0100)] 
flow-worker: clean up thread init

8 years agoautoconf - look for stdbool.h
Jason Ish [Mon, 16 Jan 2017 22:02:43 +0000 (16:02 -0600)] 
autoconf - look for stdbool.h

8 years agohttp: fix body tracking corner case
Victor Julien [Wed, 29 Mar 2017 09:15:51 +0000 (11:15 +0200)] 
http: fix body tracking corner case

In some cases, observed with inspect limits 0, the body tracking could
get confused. When all chunks were already freed, a new chunk would
be considered to be the start of the body. This would overwrite the
bodies 'content_len_so_far' tracker, instead of adding to it. This in
turn could lead to a assertion abort in the inspection code.

This patch redoes the append code to always add the current lenght. It
cleans up the code to remove redundant logic.

Issue: https://redmine.openinfosecfoundation.org/issues/2078
Reported-By: Jørgen Bøhnsdalen
8 years agoaf-packet: fix parsing packet in TPACKET_V3 mode
Alexander Gozman [Mon, 20 Feb 2017 13:47:31 +0000 (16:47 +0300)] 
af-packet: fix parsing packet in TPACKET_V3 mode

AFPParsePacketV3() saved tpacket_block_desc structure
instead of tpacket3_hdr. As a result, reconstructed
packets were wrong.

Bug #2047.

8 years agoaf-packet: get VLAN info for packets in TPACKET_V3 mode
Alexander Gozman [Mon, 20 Feb 2017 13:43:10 +0000 (16:43 +0300)] 
af-packet: get VLAN info for packets in TPACKET_V3 mode

8 years agoaf-packet: write VLAN info for both TPACKET_V2 and V3
Alexander Gozman [Mon, 20 Feb 2017 13:41:18 +0000 (16:41 +0300)] 
af-packet: write VLAN info for both TPACKET_V2 and V3

8 years agodefrag: fix argument used in macro to match signature
Jason Ish [Mon, 20 Mar 2017 16:54:51 +0000 (10:54 -0600)] 
defrag: fix argument used in macro to match signature

"p" was being used in the macro but was not an argument to
the macro, but it worked due to the context of the macro.

Use the actual macro argument, d2, instead of p.

Results in no change to generated code.

8 years agodocs: fix statement about flow:to_server
Jon Zeolla [Mon, 13 Mar 2017 16:51:44 +0000 (12:51 -0400)] 
docs: fix statement about flow:to_server

8 years agodocs: clarify how iprep works
Jon Zeolla [Mon, 13 Mar 2017 16:49:04 +0000 (12:49 -0400)] 
docs: clarify how iprep works

8 years agodetect: fix ssl_state test
Victor Julien [Thu, 9 Mar 2017 11:57:40 +0000 (12:57 +0100)] 
detect: fix ssl_state test

8 years agobytejump: don't print errors when matching
Victor Julien [Mon, 6 Mar 2017 09:54:57 +0000 (10:54 +0100)] 
bytejump: don't print errors when matching

When bytejump was told to convert some payload data to int from a
string it would print an error to the screen if the conversion
failed. This is unwanted as the payload is controlled by an attacker
and printing is expensive.

8 years agoapp-layer: fix gap handling in protocol detection
Victor Julien [Sun, 26 Feb 2017 18:56:38 +0000 (19:56 +0100)] 
app-layer: fix gap handling in protocol detection

A GAP during protocol detection would lead to all reassembly
getting disabled, so also the raw reassembly. In addition, it
could prevent the opposing side from doing protocol detection.

This patch remove the 'disable reassembly' logic. Stream engine
will take the stream with GAP and app-layer will make the proto
detection as complete.

8 years agofile store: store multiple files if available
Victor Julien [Fri, 10 Mar 2017 18:12:32 +0000 (19:12 +0100)] 
file store: store multiple files if available

8 years agoapp-layer: fix memleak on bad traffic
Victor Julien [Thu, 23 Feb 2017 15:45:32 +0000 (16:45 +0100)] 
app-layer: fix memleak on bad traffic

If state was alloc'd after protocol detection, but then the direction
turned out to be wrong, the state would not be freed.

8 years agoippair: fix xbits unset memleak
Victor Julien [Mon, 27 Feb 2017 19:38:41 +0000 (20:38 +0100)] 
ippair: fix xbits unset memleak

8 years agoippair: use both addresses in hash
Victor Julien [Mon, 27 Feb 2017 17:32:22 +0000 (18:32 +0100)] 
ippair: use both addresses in hash

8 years agostream: validate SACK right edge to be in window
Victor Julien [Mon, 27 Feb 2017 11:27:11 +0000 (12:27 +0100)] 
stream: validate SACK right edge to be in window

8 years agoipv4: update checksum function to be like tcp/udp
Jason Ish [Tue, 21 Feb 2017 19:42:50 +0000 (13:42 -0600)] 
ipv4: update checksum function to be like tcp/udp

Update the IPv4 checksum function to be like the
changed TCP/UDP checksum functions for consistency.

8 years agotcp/udp: rename checksum functions for better meaning
Jason Ish [Tue, 21 Feb 2017 19:31:41 +0000 (13:31 -0600)] 
tcp/udp: rename checksum functions for better meaning

The TCP/UDP checksum functions no longer just calculate
the checksum, they can validate as well as calculate so
use a more generic name.

8 years agotcp/udp: fix checksum validation when 0xffff
Jason Ish [Fri, 17 Feb 2017 22:04:23 +0000 (16:04 -0600)] 
tcp/udp: fix checksum validation when 0xffff

Issue:
https://redmine.openinfosecfoundation.org/issues/2041

One approach to fixing this issue to just validate the
checksum instead of regenerating it and comparing it. This
method is used in some kernels and other network tools.

When validating, the current checksum is passed in as an
initial argument which will cause the final checksum to be 0
if OK. If generating a checksum, 0 is passed and the result
is the generated checksum.

8 years agoqa/appveyor: install libiconv-devel 2632/head
Victor Julien [Fri, 24 Mar 2017 09:15:09 +0000 (10:15 +0100)] 
qa/appveyor: install libiconv-devel

8 years agotravis: macos: unlink all deps, then relink
Jason Ish [Fri, 24 Mar 2017 19:59:39 +0000 (13:59 -0600)] 
travis: macos: unlink all deps, then relink

Kind of ugly, but first unlink all dependencies then install.
The deps that don't get an upgrade will remain unlinked, so
relink all dependencies as relinking an already linked dep
does not error out.

8 years agotravis: fix pkg-config in mac builds
Victor Julien [Fri, 24 Mar 2017 11:40:18 +0000 (12:40 +0100)] 
travis: fix pkg-config in mac builds

Unlink pkg-config before installing.

8 years agotravis: fix libpcre in mac builds
Jason Ish [Fri, 17 Mar 2017 17:11:07 +0000 (11:11 -0600)] 
travis: fix libpcre in mac builds

It looks like Travis changed their Mac image and pcre is now
installed by default. In case it gets removed again, just unlink
it before re-installing so it doesn't fail on install.

8 years agoMakefile: fix race condition in make install-full
Jason Ish [Thu, 16 Feb 2017 19:02:58 +0000 (13:02 -0600)] 
Makefile: fix race condition in make install-full

Use recursive make for the install process so it
is executed in a predictable order.

Addresses issue:
https://redmine.openinfosecfoundation.org/issues/1470
which triggered on OSX/macOS.

8 years agochangelog: update for 3.2.1 release suricata-3.2.1
Victor Julien [Wed, 15 Feb 2017 07:49:07 +0000 (08:49 +0100)] 
changelog: update for 3.2.1 release

8 years agodns: fix outputs with 0-len A/AAAA records
Victor Julien [Mon, 13 Feb 2017 09:39:26 +0000 (10:39 +0100)] 
dns: fix outputs with 0-len A/AAAA records

8 years agodns: fix out of bounds read
Victor Julien [Thu, 9 Feb 2017 14:40:30 +0000 (15:40 +0100)] 
dns: fix out of bounds read

On a zero size A or AAAA record, 4 or 16 bytes would still be
read.

Found with AFL+ASAN.

8 years agodefrag - take protocol into account during re-assembly
Jason Ish [Sun, 5 Feb 2017 13:57:54 +0000 (07:57 -0600)] 
defrag - take protocol into account during re-assembly

The IP protocol was not being used to match fragments with
their packets allowing a carefully constructed packet
with a different protocol to be matched, allowing re-assembly
to complete, creating a packet that would not be re-assembled
by the destination host.

8 years agoafl: add ethernet and erspan entry points 2552/head
Victor Julien [Sun, 12 Feb 2017 06:52:04 +0000 (07:52 +0100)] 
afl: add ethernet and erspan entry points

8 years agoafl: clean up commandline parsing
Victor Julien [Sat, 11 Feb 2017 09:47:38 +0000 (10:47 +0100)] 
afl: clean up commandline parsing

8 years agoafl: pass a packet queue to decoder calls
Victor Julien [Fri, 10 Feb 2017 18:58:27 +0000 (19:58 +0100)] 
afl: pass a packet queue to decoder calls

8 years agoafl: set the packet data so pktlen gets set
Jason Ish [Fri, 10 Feb 2017 17:21:57 +0000 (11:21 -0600)] 
afl: set the packet data so pktlen gets set

8 years agoafl: minimalistic script to start AFL fuzzers
Victor Julien [Thu, 9 Feb 2017 18:10:02 +0000 (19:10 +0100)] 
afl: minimalistic script to start AFL fuzzers

in suricata source dir:

mkdir afl
cd afl
bash ../scripts/afl/runafl.sh decoder-ipv4

8 years agoafl: util script to list crashed series
Victor Julien [Thu, 9 Feb 2017 17:34:20 +0000 (18:34 +0100)] 
afl: util script to list crashed series

8 years agoafl: improve packet fuzz testing
Victor Julien [Thu, 9 Feb 2017 17:22:18 +0000 (18:22 +0100)] 
afl: improve packet fuzz testing

Due to the use of AFL_LOOP and initialization/deinit outside of it,
part of the fuzzing relied on the global 'state' in flow and defrag.
Because of this crashes that were found could not be reproduced. The
saved crash input was only the last in the series.

This patch addresses that. It requires a new output directory 'dump'
where the packet fuzzers will store all their input. If the AFL_LOOP
fails the files will not be removed and this 'serie' can be read
again for reproducing the issue.

e.g.: AFL would work with:
--afl-decoder-ppp=@@

and after a crash is found the produced serie can be read with:
--afl-decoder-ppp-serie=1486656919-514163

The series have a timestamp as name and a suffix that controls the
order in which the files will be 'replayed' in Suricata.

8 years agoafl: add decoder ipv4 option
Victor Julien [Thu, 9 Feb 2017 08:45:54 +0000 (09:45 +0100)] 
afl: add decoder ipv4 option

8 years agompm-ac: fix integer overflow on allocation 2550/head
Sascha Steinbiss [Wed, 8 Feb 2017 11:39:06 +0000 (12:39 +0100)] 
mpm-ac: fix integer overflow on allocation

The size of a memory buffer to be allocated was kept in a signed int
instead of a size_t, leading to an overflow when large lists of long
and diverse patterns cause the amount of AC states to blow up (>2GB).
Fixes Redmine issues #1827 and #1843.

Signed-off-by: Sascha Steinbiss <sascha@steinbiss.name>
8 years agoalert: silence compiler type warning
Sascha Steinbiss [Wed, 8 Feb 2017 11:40:00 +0000 (12:40 +0100)] 
alert: silence compiler type warning

The `ts_ecr' and `ts_val' struct fields are integer types, not
pointers. This leads GCC 6.3.0 to complain about comparisons to
NULL.

Signed-off-by: Sascha Steinbiss <sascha@steinbiss.name>
8 years agodetect: don't run IP inspection on non-IP packets 2549/head
Victor Julien [Wed, 8 Feb 2017 12:55:34 +0000 (13:55 +0100)] 
detect: don't run IP inspection on non-IP packets

The code to get the rule group (sgh) would return the group for
IP proto 0 instead of nothing. This lead to certain types of rules
unintentionally matching (False Positive).

Since the packets weren't actually IP, the logged alert records
were missing the IP header.

Bug #2017.

8 years agoafl: fix ENIP, switch DNS to UDP and add --afl-dnstcp*
Victor Julien [Wed, 8 Feb 2017 08:20:54 +0000 (09:20 +0100)] 
afl: fix ENIP, switch DNS to UDP and add --afl-dnstcp*

8 years agoafl: with -Wshadow issues
Victor Julien [Wed, 8 Feb 2017 07:40:46 +0000 (08:40 +0100)] 
afl: with -Wshadow issues

8 years agoaf-packet: add VLAN header when needed in IPS mode
Eric Leblond [Tue, 1 Nov 2016 21:09:31 +0000 (22:09 +0100)] 
af-packet: add VLAN header when needed in IPS mode

When packet is coming from a real ethernet card, the kernel is
stripping the vlan header and delivering a modified packet so
we need to insert the VLAN header back before sending the packet
on the wire.

To do so, we pass an option to the raw socket to add a reserve
before the packet data. It will get Suricata some head room to
to move the ethernet addresses before there actual place and
and insert the VLAN header in the correct place.

We get VLAN info from the ring buffer as the call of AFPWrite is
always done in the release function so we still have access to the
memory.

8 years agodetect-tls-sni: add link to documentation 2534/head
Eric Leblond [Mon, 30 Jan 2017 19:25:41 +0000 (20:25 +0100)] 
detect-tls-sni: add link to documentation

8 years agodoc: document the tls_sni keyword
Eric Leblond [Mon, 30 Jan 2017 19:24:10 +0000 (20:24 +0100)] 
doc: document the tls_sni keyword

8 years agodetect-tls: add url field pointing to doc
Eric Leblond [Mon, 30 Jan 2017 19:13:04 +0000 (20:13 +0100)] 
detect-tls: add url field pointing to doc