]> git.ipfire.org Git - thirdparty/suricata.git/log
thirdparty/suricata.git
7 years agocuda: remove 3128/head
Victor Julien [Sat, 30 Dec 2017 13:55:26 +0000 (14:55 +0100)] 
cuda: remove

Remove CUDA support as it has been broken for a long time.

Ticket #2382.

7 years agoscan-build: fix memleak warning in port parsing 3117/head
Victor Julien [Thu, 21 Dec 2017 11:07:46 +0000 (12:07 +0100)] 
scan-build: fix memleak warning in port parsing

7 years agodetect/tos: minor cleanups
Victor Julien [Thu, 21 Dec 2017 11:02:33 +0000 (12:02 +0100)] 
detect/tos: minor cleanups

7 years agodetect/tos: fix memleak in error path
Victor Julien [Thu, 21 Dec 2017 11:00:28 +0000 (12:00 +0100)] 
detect/tos: fix memleak in error path

7 years agoscan-build: simplify FatalErrorOnInit macro
Victor Julien [Thu, 21 Dec 2017 10:10:52 +0000 (11:10 +0100)] 
scan-build: simplify FatalErrorOnInit macro

7 years agoscan-build: don't use memory wrappers
Victor Julien [Thu, 21 Dec 2017 10:01:12 +0000 (11:01 +0100)] 
scan-build: don't use memory wrappers

7 years agoscan-build: fix warning in radix tree
Victor Julien [Thu, 21 Dec 2017 10:00:28 +0000 (11:00 +0100)] 
scan-build: fix warning in radix tree

7 years agoscan-build: fix warning in streaming buffer
Victor Julien [Thu, 21 Dec 2017 09:59:03 +0000 (10:59 +0100)] 
scan-build: fix warning in streaming buffer

7 years agothreads: avoid NULL-ptr deref in thread init wait
Victor Julien [Thu, 21 Dec 2017 09:47:52 +0000 (10:47 +0100)] 
threads: avoid NULL-ptr deref in thread init wait

** CID 1426745:  Null pointer dereferences  (FORWARD_NULL)
/src/tm-threads.c: 2135 in TmThreadWaitOnThreadInit()

________________________________________________________________________________________________________
*** CID 1426745:  Null pointer dereferences  (FORWARD_NULL)
/src/tm-threads.c: 2135 in TmThreadWaitOnThreadInit()
2129         struct timeval cur_ts;
2130         gettimeofday(&start_ts, NULL);
2131
2132     again:
2133         gettimeofday(&cur_ts, NULL);
2134         if ((cur_ts.tv_sec - start_ts.tv_sec) > 120) {
>>>     CID 1426745:  Null pointer dereferences  (FORWARD_NULL)
>>>     Dereferencing null pointer "tv".
2135             SCLogError(SC_ERR_THREAD_INIT, "thread \"%s\" failed to "
2136                     "initialize in time: flags %04x", tv->name,
2137                     SC_ATOMIC_GET(tv->flags));
2138             return TM_ECODE_FAILED;
2139         }
2140

7 years agoRust: fix probing function prototype: change sign and add Flow
Pierre Chifflier [Wed, 29 Nov 2017 11:07:44 +0000 (12:07 +0100)] 
Rust: fix probing function prototype: change sign and add Flow

7 years agomingw: improve ipaddress parsing 3112/head
Victor Julien [Mon, 11 Dec 2017 17:18:28 +0000 (18:18 +0100)] 
mingw: improve ipaddress parsing

7 years agomingw: fix issues in pcap directory code
Victor Julien [Mon, 11 Dec 2017 12:32:47 +0000 (13:32 +0100)] 
mingw: fix issues in pcap directory code

Fix issues with 'stat' and explicitly skip . and ..

7 years agomingw: wrapper for usleep in threads
Victor Julien [Mon, 27 Nov 2017 13:31:45 +0000 (14:31 +0100)] 
mingw: wrapper for usleep in threads

usleep on MinGW doesn't behave as expected. Added replacement
wrapper around 'Sleep(msec)'. As that has msec resolution and
not a usec resolution, change the various thread init and stop
functions to test for the actual time waited instead of counting
the usecs passed to usleep.

7 years agomingw/cygwin: explicitly disable unix socket
Victor Julien [Mon, 27 Nov 2017 08:06:03 +0000 (09:06 +0100)] 
mingw/cygwin: explicitly disable unix socket

7 years agomingw: use c:\Program Files\Suricata for w64
Victor Julien [Mon, 27 Nov 2017 07:51:35 +0000 (08:51 +0100)] 
mingw: use c:\Program Files\Suricata for w64

7 years agoipv6: add string validation function
Victor Julien [Sun, 26 Nov 2017 10:17:57 +0000 (11:17 +0100)] 
ipv6: add string validation function

7 years agoipv4: add string validation function
Victor Julien [Sun, 26 Nov 2017 10:09:19 +0000 (11:09 +0100)] 
ipv4: add string validation function

7 years agodecode/mime: improve ip address validation
Victor Julien [Sun, 26 Nov 2017 08:58:03 +0000 (09:58 +0100)] 
decode/mime: improve ip address validation

inet_pton on Windows/MinGW is very liberal, so do manual validation
of IP address formatting.

7 years agomingw: work around mingw more liberal ip parsing
Victor Julien [Sat, 25 Nov 2017 13:23:35 +0000 (14:23 +0100)] 
mingw: work around mingw more liberal ip parsing

7 years agoconsole: no color for native windows build
Victor Julien [Sat, 25 Nov 2017 09:34:34 +0000 (10:34 +0100)] 
console: no color for native windows build

7 years agomingw: disable pid checking from pidfile
Victor Julien [Mon, 17 Jul 2017 14:20:22 +0000 (16:20 +0200)] 
mingw: disable pid checking from pidfile

kill() call is not supported in MinGW

7 years agomingw: fix 'struct tm' compilation issue
Victor Julien [Mon, 17 Jul 2017 14:19:32 +0000 (16:19 +0200)] 
mingw: fix 'struct tm' compilation issue

7 years agostrptime: add implementation from NetBSD
Victor Julien [Mon, 17 Jul 2017 13:26:43 +0000 (15:26 +0200)] 
strptime: add implementation from NetBSD

As MinGW doesn't come with strptime take the BSD licensed
implementation from NetBSD. More specifically, the one from

https://github.com/Alexpux/MINGW-packages/blob/master/mingw-w64-libkml/strptime.c

It's slightly modified to get rid on 'uint'.

7 years agomingw: add SCNtohl and SCNtohs macro's
Victor Julien [Mon, 17 Jul 2017 11:45:44 +0000 (13:45 +0200)] 
mingw: add SCNtohl and SCNtohs macro's

On MinGW the result of ntohl needs to be casted to uint32_t and
the result of ntohs to uint16_t. To avoid doing this everywhere
add SCNtohl and SCNtohs macros.

7 years agomingw: fix use of undefined USR2 signal
Victor Julien [Mon, 17 Jul 2017 11:22:58 +0000 (13:22 +0200)] 
mingw: fix use of undefined USR2 signal

7 years agomingw: fix compilation of signals code
Victor Julien [Mon, 17 Jul 2017 09:02:47 +0000 (11:02 +0200)] 
mingw: fix compilation of signals code

7 years agomingw: work around mingw mkdir
Victor Julien [Sat, 15 Jul 2017 07:40:11 +0000 (09:40 +0200)] 
mingw: work around mingw mkdir

mingw doesn't come with a posix compliant mkdir as it only takes
a single argument.

7 years agoeve: remove json format option - was not used
Jason Ish [Mon, 11 Dec 2017 21:31:58 +0000 (15:31 -0600)] 
eve: remove json format option - was not used

7 years agoeve.flow: removed unused http parameters
Jason Ish [Tue, 19 Dec 2017 22:50:25 +0000 (16:50 -0600)] 
eve.flow: removed unused http parameters

7 years agoeve: fix context datatype used in init functions
Jason Ish [Tue, 19 Dec 2017 21:49:27 +0000 (15:49 -0600)] 
eve: fix context datatype used in init functions

Many were using AlertJsonThread instead of OutputJsonCtx,
but as the datatypes were similar enough no harm was done.

Now that they are using their proper datatype, removed
AlertJsonThread from output.h as its no longer used.

7 years agoeve.dnp3: removed unsed context field
Jason Ish [Tue, 19 Dec 2017 21:46:31 +0000 (15:46 -0600)] 
eve.dnp3: removed unsed context field

7 years agoeve.flow: remove "hi" log message
Jason Ish [Tue, 19 Dec 2017 21:44:17 +0000 (15:44 -0600)] 
eve.flow: remove "hi" log message

7 years agoeve.netflow: remove "hi" log message
Jason Ish [Tue, 19 Dec 2017 21:43:50 +0000 (15:43 -0600)] 
eve.netflow: remove "hi" log message

7 years agorust: add --enable-rust-debug
Victor Julien [Wed, 20 Dec 2017 13:14:34 +0000 (14:14 +0100)] 
rust: add --enable-rust-debug

Add option to put Rust code in non-'--release' mode, preserving
debug symbols.

Until now Suricata would have to be compiled with --enable-debug for
this.

7 years agohostbits: fix test setup 3108/head
Victor Julien [Sat, 14 Oct 2017 21:14:31 +0000 (23:14 +0200)] 
hostbits: fix test setup

7 years agofile_data: move tests into tests/
Victor Julien [Sat, 14 Oct 2017 08:09:57 +0000 (10:09 +0200)] 
file_data: move tests into tests/

7 years agofile_data: unify inspect engines
Victor Julien [Thu, 12 Oct 2017 16:19:23 +0000 (18:19 +0200)] 
file_data: unify inspect engines

Call HTTP from the generic file_data engine.

7 years agofile_data: smtp file_data to generic file_data
Victor Julien [Fri, 29 Sep 2017 21:09:15 +0000 (23:09 +0200)] 
file_data: smtp file_data to generic file_data

Generalize the SMTP file_data inspection into a 'files'
file_data inspection that can be used for any protocol
that uses the File API.

7 years agodetect: minor cleanup
Victor Julien [Sun, 8 Oct 2017 16:28:30 +0000 (18:28 +0200)] 
detect: minor cleanup

7 years agoapp-layer: use bool for 'HasDecoderEvents'
Victor Julien [Sun, 8 Oct 2017 16:23:22 +0000 (18:23 +0200)] 
app-layer: use bool for 'HasDecoderEvents'

7 years agodetect: no tcp flags in mask for pseudo packets
Victor Julien [Tue, 7 Nov 2017 10:28:01 +0000 (11:28 +0100)] 
detect: no tcp flags in mask for pseudo packets

7 years agodetect/mpm: micro optimization in setup
Victor Julien [Sun, 17 Dec 2017 19:08:12 +0000 (20:08 +0100)] 
detect/mpm: micro optimization in setup

7 years agodetect: remove old simd references
Victor Julien [Sun, 8 Oct 2017 12:28:19 +0000 (14:28 +0200)] 
detect: remove old simd references

7 years agodecode/vlan: don't consider ARP 'unknown'
Victor Julien [Wed, 20 Dec 2017 08:30:42 +0000 (09:30 +0100)] 
decode/vlan: don't consider ARP 'unknown'

7 years agopfring: minor code cleanups
Victor Julien [Wed, 20 Dec 2017 08:03:33 +0000 (09:03 +0100)] 
pfring: minor code cleanups

7 years agopfring: add warning for stripped vlan header case
Victor Julien [Wed, 20 Dec 2017 07:57:29 +0000 (08:57 +0100)] 
pfring: add warning for stripped vlan header case

According to PF_RING upstream the vlan header should never be stripped
from the packet PF_RING feeds to Suricata. But upstream also indicated
keeping the check would be a good "safety check".

So in addition to the check, add a warning that warns once (per thread
for implementation simplicity) if the vlan hdr does appear to be stripped
after all.

7 years agopfring: fix vlan handling issues
Victor Julien [Tue, 19 Dec 2017 19:17:39 +0000 (20:17 +0100)] 
pfring: fix vlan handling issues

When Suricata was monitoring traffic with a single vlan layer, the stats
and output instead showed 2. This was caused by the raw packets PF_RING
feeds Suricata would hold the vlan header, but the code assumed that
the header was stripped and the vlan_id passed to Suricata through
PF_RING's extended_hdr.parsed_pkt.

This patch adds the following logic: Check vlan id from the parser packet
PF_RING prepared. PF_RING sets the vlan_id based on its own parsing or
based on the hardware offload. It gives no indication on where the vlan_id
came from, so we rely on the vlan_offset field. If it's 0, we assume the
PF_RING parser did not see the vlan header and got it from the hardware
offload. In this case we will use this information directly, as we won't
get a raw vlan header later. If PF_RING did set the offset, we do the
parsing in the Suricata decoder so that we have full control.

PF_RING *should* put back the vlan header in all cases, and also set the
vlan_offset field, but as a extra precaution keep the check described
above.

Bug #2355.

7 years agoapp-layer-ftp: add memcap for ftp
Eric Leblond [Fri, 24 Nov 2017 15:59:34 +0000 (16:59 +0100)] 
app-layer-ftp: add memcap for ftp

Add a memory cap for the FTP protocol.

7 years agodoc: update file extraction document
Eric Leblond [Sun, 19 Nov 2017 19:27:17 +0000 (20:27 +0100)] 
doc: update file extraction document

Define the list of protocol parsers supporting extraction in one
single place following Andreas Herz' suggestion.

7 years agodoc: update following ftp-data changes
Eric Leblond [Sun, 19 Nov 2017 19:22:46 +0000 (20:22 +0100)] 
doc: update following ftp-data changes

7 years agodetect-ftpdata: match on ftp-data operation
Eric Leblond [Sun, 19 Nov 2017 19:21:08 +0000 (20:21 +0100)] 
detect-ftpdata: match on ftp-data operation

This keyword mathes on ftp operation STOR and RETR. It will allow
rules writer to select if the alert has to be on a put or a fetch
operation.

It is now possible to write a signature like:

  alert ftp-data any any -> any any (msg:"FTP data get firwmare"; ftdata_command:retr; sid:2; rev:1;)

to alert when a file is retrieved from a FTP server.

7 years agoapp-layer-ftp: add ftp-data support
Eric Leblond [Wed, 13 Sep 2017 14:48:29 +0000 (15:48 +0100)] 
app-layer-ftp: add ftp-data support

Use expectation to be able to identify connections that are
ftp data. It parses the PASV response, STOR message and the
RETR message to provide extraction of files.

Implementation in Rust of FTP messages parsing is available.

Also this patch changes some var name prefixed by ssh to ftp.

7 years agoapp-layer-expectation: expectation system
Eric Leblond [Tue, 12 Sep 2017 13:11:01 +0000 (14:11 +0100)] 
app-layer-expectation: expectation system

This patch provides a working expectation system. This will allow
suricata to have a way to identify parallel connections opened by
a protocol such as FTP.

Expectation are a chained list and there is a cleaning by timeout
of the entries.

This patch also defined a counter of expectations that is also
used to check if we need to query IPPairs. This way we only query
the IPPairs store if we have an expectation.

7 years agoapp-layer: add Flow to probing parser functions
Eric Leblond [Tue, 12 Sep 2017 15:43:41 +0000 (16:43 +0100)] 
app-layer: add Flow to probing parser functions

7 years agoflow: add parent_id field
Eric Leblond [Sat, 16 Sep 2017 12:28:22 +0000 (13:28 +0100)] 
flow: add parent_id field

This patch adds a parent_id field to the Flow structure that
contain the flow ID of the parent connection for protocol with
dynamic parallel connection opening like FTP.

7 years agodetect: increase signature mask length
Eric Leblond [Fri, 15 Sep 2017 13:33:33 +0000 (14:33 +0100)] 
detect: increase signature mask length

7 years agosuricata: storage early to get it everywhere
Eric Leblond [Tue, 12 Sep 2017 21:53:51 +0000 (22:53 +0100)] 
suricata: storage early to get it everywhere

7 years agodoc: add memcap commands in unix-socket section 3104/head
Giuseppe Longo [Fri, 1 Dec 2017 13:48:54 +0000 (14:48 +0100)] 
doc: add memcap commands in unix-socket section

7 years agosuricatasc: add commands for memcap handling
Giuseppe Longo [Mon, 20 Nov 2017 14:22:54 +0000 (15:22 +0100)] 
suricatasc: add commands for memcap handling

7 years agorunmode-unix-socket: add commands for memcap handling
Giuseppe Longo [Mon, 20 Nov 2017 14:19:45 +0000 (15:19 +0100)] 
runmode-unix-socket: add commands for memcap handling

This permits to handle memcap values through
unix socket for:
- stream
- stream-reassembly
- flow
- applayer-proto-http
- defrag
- ippair
- host

It will be possible to show or change a memcap value
for a specified configuration and list all memcap values
available.

The following commands are registered for unix-socket:
- memcap-set
- memcap-show
- memcap-list

Output:
>>> memcap-show flow
Success:
{
    "value": "64mb"
}

>>> memcap-set flow 64mb
Success:
"memcap value for 'flow' updated: 67108864"

Command with invalid memcap key:
>>> memcap-set udp 32mb
Error:
"Available config: stream stream-reassembly flow applayer-proto-http defrag ippair host"

Command with an invalid memcap value:
>>> memcap-set http 32mmb
Error:
"error parsing memcap specified, value not changed"

7 years agohost: get/set memcap value
Giuseppe Longo [Mon, 20 Nov 2017 14:13:00 +0000 (15:13 +0100)] 
host: get/set memcap value

This adds new functions that will be called
through unix-socket and permit to update
and show memcap value.

The memcap value needs to be handled in a
thread safe way, so for this reason it is
declared as atomic var.

Another function is added to gets
the memuse value since it will be shown
through unix-socket.

7 years agoippair: get/set memcap value
Giuseppe Longo [Mon, 20 Nov 2017 14:11:15 +0000 (15:11 +0100)] 
ippair: get/set memcap value

This adds new functions that will be called
through unix-socket and permit to update
and show memcap value.

The memcap value needs to be handled in a
thread safe way, so for this reason it is
declared as atomic var.

Another function is added to gets
the memuse value since it will be shown
through unix-socket.

7 years agodefrag: get/set memcap value
Giuseppe Longo [Mon, 20 Nov 2017 14:09:17 +0000 (15:09 +0100)] 
defrag: get/set memcap value

This adds new functions that will be called
through unix-socket and permit to update
and show memcap value.

The memcap value needs to be handled in a
thread safe way, so for this reason it is
declared as atomic var.

Another function is added to gets
the memuse value since it will be shown
through unix-socket.

7 years agohtp: destroy atomic vars
Giuseppe Longo [Mon, 11 Dec 2017 08:42:56 +0000 (09:42 +0100)] 
htp: destroy atomic vars

Atomic vars declared in app-layer-htp-mem.c were not
destroyed when suricata is shutdown.

7 years agohtp: get/set memcap value
Giuseppe Longo [Mon, 20 Nov 2017 14:06:54 +0000 (15:06 +0100)] 
htp: get/set memcap value

This adds new functions that will be called
through unix-socket and permit to update
and show memcap value.

The memcap value needs to be handled in a
thread safe way, so for this reason it is
declared as atomic var.

7 years agoflow: get/set memcap value
Giuseppe Longo [Mon, 20 Nov 2017 14:02:32 +0000 (15:02 +0100)] 
flow: get/set memcap value

This adds new functions that will be called
through unix-socket and permit to update
and show memcap value.

The memcap value needs to be handled in a
thread safe way, so for this reason it is
declared as atomic var.

FlowGetMemuse() function is made as public
because the memuse value will be shown
through unix-socket.

7 years agostream-tcp: get/set memcap value
Giuseppe Longo [Mon, 20 Nov 2017 13:39:22 +0000 (14:39 +0100)] 
stream-tcp: get/set memcap value

This adds new functions that will be called
through unix-socket and permit to update
and show memcap value.

The memcap value needs to be handled in a
thread safe way, so for this reason it is
declared as atomic var.

7 years agostream-tcp-reassemble: declare 'size' as uint64_t
Giuseppe Longo [Wed, 13 Dec 2017 11:26:35 +0000 (12:26 +0100)] 
stream-tcp-reassemble: declare 'size' as uint64_t

According to all checking memcap functions,
the size passed as argument is declared as uint64_t
except for StreamTcpReassembleCheckMemcap where it's
defined as uint32_t.

7 years agoHash table: free bucker in case of insertion error
Pierre Chifflier [Mon, 17 Mar 2014 17:59:35 +0000 (18:59 +0100)] 
Hash table: free bucker in case of insertion error

This fixes a warning raised by cppcheck.

7 years agoHash table: check hash array size when inserting element
Pierre Chifflier [Fri, 14 Mar 2014 17:59:11 +0000 (18:59 +0100)] 
Hash table: check hash array size when inserting element

If the hash function returns an index greater than the array size of the
hash table, the index is not checked. Even if this is the responsibility
of the caller, add a safety check to avoid errors.

7 years agodoc: document log reopen unix socket command
Eric Leblond [Tue, 12 Dec 2017 11:48:42 +0000 (12:48 +0100)] 
doc: document log reopen unix socket command

7 years agounix-socket: add logs reopen command
Eric Leblond [Mon, 27 Nov 2017 10:23:24 +0000 (11:23 +0100)] 
unix-socket: add logs reopen command

We did had a race condition with running logrotate with multiple
EVE Json files. Consequence was one of the file not being reopen
by suricata that did continue to write to the rotated one.

Trying fix on signal handler did fail so this patch implements
log rotation support by adding a dedicated command to unix socket
to reopen the log files.

7 years agodns-log: don't register if HAVE_RUST 3103/head
Jason Ish [Mon, 18 Dec 2017 12:58:18 +0000 (06:58 -0600)] 
dns-log: don't register if HAVE_RUST

Log just one notice message when attempting to register
this logger with HAVE_RUST, instead of logging on
every attempt to output a DNS record.

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

7 years agorust/dns - convert more type values to text
Jason Ish [Mon, 18 Dec 2017 12:46:17 +0000 (06:46 -0600)] 
rust/dns - convert more type values to text

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

Convert more record type and errr code values to text.
Remove duplicate type declarations.

7 years agoConf: Multipe NULL-pointer dereferences in PostConfLoadedSetup
Wolfgang Hotwagner [Mon, 18 Dec 2017 14:49:38 +0000 (14:49 +0000)] 
Conf: Multipe NULL-pointer dereferences in PostConfLoadedSetup

Multiple NULL-pointer dereferences after ConfGet in PostConfLoadedSetup can cause suricata to terminate with segfaults. The ASAN-output:

ASAN:DEADLYSIGNAL =================================================================
5734ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x7f1a9a3967cc bp 0x7ffdff033ad0 sp 0x7ffdff033250 T0)
 0 0x7f1a9a3967cb (/usr/lib/x86_64-linux-gnu/libasan.so.3+0x447cb)
 1 0x55ba65f66f27 in PostConfLoadedSetup /root/suricata-1/src/suricata.c:2652
 2 0x55ba65f6870e in main /root/suricata-1/src/suricata.c:2898
 3 0x7f1a96aeb2b0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202b0)
 4 0x55ba65af9039 in _start (/usr/local/bin/suricata+0xc8039)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV (/usr/lib/x86_64-linux-gnu/libasan.so.3+0x447cb)

This commit fixes Bug #2370 by replacing ConfGet by ConfGetValue

7 years agoConf: Multipe NULL-pointer dereferences after ConfGetBool in StreamTcpInitConfig
Wolfgang Hotwagner [Sun, 17 Dec 2017 22:15:27 +0000 (22:15 +0000)] 
Conf: Multipe NULL-pointer dereferences after ConfGetBool in StreamTcpInitConfig

There are multiple NULL-pointer dereferences after calling ConfGetBool in StreamTcpInitConfig. ConfGetBool calls ConfGet which doesn't check the vptr-argument. This is a sample ASAN-output:

1453ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x7f2969b83a28 bp 0x7ffdbf613a90 sp 0x7ffdbf613210 T0)
 0 0x7f2969b83a27 in strcasecmp (/usr/lib/x86_64-linux-gnu/libasan.so.3+0x51a27)
 1 0x564185accefd in ConfValIsTrue /root/suricata-1/src/conf.c:559
 2 0x564185accb4f in ConfGetBool /root/suricata-1/src/conf.c:512
 3 0x564185dcbe05 in StreamTcpInitConfig /root/suricata-1/src/stream-tcp.c:381
 4 0x564185e21a88 in PreRunInit /root/suricata-1/src/suricata.c:2264
 5 0x564185e24d2c in PostConfLoadedSetup /root/suricata-1/src/suricata.c:2763
 6 0x564185e2570e in main /root/suricata-1/src/suricata.c:2898
 7 0x7f29662cb2b0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202b0)
 8 0x5641859b6039 in _start (/usr/local/bin/suricata+0xc8039)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV (/usr/lib/x86_64-linux-gnu/libasan.so.3+0x51a27) in strcasecmp
1453ABORTING

This commit replaces ConfGet by ConfGetValue in ConfGetBool. This does not only fix Bug #2368 but might also fix others too.

7 years agoConf: Multipe NULL-pointer dereferences in HostInitConfig
Wolfgang Hotwagner [Sun, 17 Dec 2017 21:54:15 +0000 (21:54 +0000)] 
Conf: Multipe NULL-pointer dereferences in HostInitConfig

Multiple NULL-pointer dereferences after ConfGet in HostInitConfig can cause suricata to terminate with segfaults. The ASAN-output:

==29747==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x7ff937904646 bp
    0 0x7ff937904645 in strlen (/lib/x86_64-linux-gnu/libc.so.6+0x80645)
    1 0x7ff93b146eec  (/usr/lib/x86_64-linux-gnu/libasan.so.3+0x3beec)
    2 0x5618387c86a3 in HostInitConfig /root/suricata-1/src/host.c:174
    3 0x56183893eccb in PostConfLoadedSetup /root/suricata-1/src/suricata.c:2752
    4 0x56183893f70e in main /root/suricata-1/src/suricata.c:2898
    5 0x7ff9378a42b0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202b0)
    6 0x5618384d0039 in _start (/usr/local/bin/suricata+0xc8039)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV (/lib/x86_64-linux-gnu/libc.so.6+0x80645) in strlen

This commit fixes Bug #2367

7 years agocontent: fix depth/within, offset/distance mix
Victor Julien [Fri, 15 Dec 2017 08:44:12 +0000 (09:44 +0100)] 
content: fix depth/within, offset/distance mix

7 years agotemplate scripts: fixup detect setup scripts 3093/head
Jason Ish [Wed, 13 Dec 2017 22:18:40 +0000 (16:18 -0600)] 
template scripts: fixup detect setup scripts

Update scripts to reflect recent changes in the detection files.

7 years agodetect-engine: add missing mutex unlock
Andreas Herz [Thu, 14 Dec 2017 00:10:33 +0000 (01:10 +0100)] 
detect-engine: add missing mutex unlock

7 years agorule-reload: fix possible hangup with SIGUSR2
Andreas Herz [Wed, 13 Dec 2017 23:59:30 +0000 (00:59 +0100)] 
rule-reload: fix possible hangup with SIGUSR2

In some cases the rule reload could hang. The pending USR2 signals will
be recognized even with the <2 check. Also the SCLogWarning shouldn't be
used in the handler (see Warning about SCLog* API above in the code).

7 years agodoc: initial suricata-update page 3090/head
Victor Julien [Wed, 6 Dec 2017 21:54:31 +0000 (22:54 +0100)] 
doc: initial suricata-update page

7 years agopcap-directory: fix double free in error path 3085/head
Victor Julien [Wed, 13 Dec 2017 12:05:23 +0000 (13:05 +0100)] 
pcap-directory: fix double free in error path

7 years agoapp-layer/counters: check counter id
Victor Julien [Wed, 13 Dec 2017 09:28:19 +0000 (10:28 +0100)] 
app-layer/counters: check counter id

Check counter id before updating a counter. In case of a disabled
parser with the protocol detection enable, the id can be 0. In
debug mode this would lead to a BUG_ON.

7 years agosource-pcap-file: Fix coverity findings (Bug #2356)
Danny Browning [Wed, 13 Dec 2017 01:07:09 +0000 (18:07 -0700)] 
source-pcap-file: Fix coverity findings (Bug #2356)

https://redmine.openinfosecfoundation.org/issues/2356

Address issues found by coverity for resource leaks and use after free.

7 years agosuricata: pcap-file-continuous ignores other options (Bug #2253)
Danny Browning [Tue, 12 Dec 2017 20:07:42 +0000 (13:07 -0700)] 
suricata: pcap-file-continuous ignores other options (Bug #2253)

https://redmine.openinfosecfoundation.org/issues/2353

Command line option pcap-file-continuous was ignoring command line options
passed after its usage. Fixed bug, fixed formatting of help command
regarding pcap-file-continuous.

7 years agoqa: add more drmemory suppressions for hyperscan
Victor Julien [Tue, 5 Dec 2017 14:36:22 +0000 (15:36 +0100)] 
qa: add more drmemory suppressions for hyperscan

7 years agoprefilter/profile: validate end > start
Victor Julien [Tue, 12 Dec 2017 20:05:34 +0000 (21:05 +0100)] 
prefilter/profile: validate end > start

Seen underflow issues on profiling on arm (gettimeofday based.

7 years agoconf: multiple NULL-pointer dereferences in StreamTcpInitConfig 3078/head
Wolfgang Hotwagner [Mon, 11 Dec 2017 20:20:00 +0000 (20:20 +0000)] 
conf: multiple NULL-pointer dereferences in StreamTcpInitConfig

There are several NULL-pointer derefs in StreamTCPInitConfig. All of them happen because ConfGet returns 1 even if the value is NULL(due to misconfiguration for example).
This commit introduces a new function "ConfGetValue". It adds return values for NULL-pointer to ConfGet and could be used as a replacement for ConfGet.

Note: Simply modify ConfGet might not be a good idea, because there are some places where ConfGet should return 1 even if "value" is NULL. For example if ConfGet should get a Config-Leave in the yaml-hierarchy.

Bug: 2354

7 years agoconf: multiple NULL-pointer dereferences in FlowInitConfig
Wolfgang Hotwagner [Sat, 9 Dec 2017 13:18:49 +0000 (13:18 +0000)] 
conf: multiple NULL-pointer dereferences in FlowInitConfig

This commit fixes multiple NULL-pointer dereferences in FlowInitConfig after reading in config-values(flow.hash-size, flow.prealloc and flow.memcap) for flow. Here is a sample ASAN-output:

=================================================================
ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x7fea73456646 bp 0x7fffd70e1ba0 sp 0x7fffd70e1328 T0)
0 0x7fea73456645 in strlen (/lib/x86_64-linux-gnu/libc.so.6+0x80645)
1 0x7fea76c98eec (/usr/lib/x86_64-linux-gnu/libasan.so.3+0x3beec)
2 0x5643efb4c205 in FlowInitConfig /root/suricata-1/src/flow.c:455
3 0x5643efcd1751 in PreRunInit /root/suricata-1/src/suricata.c:2247
4 0x5643efcd49f4 in PostConfLoadedSetup /root/suricata-1/src/suricata.c:2748
5 0x5643efcd5402 in main /root/suricata-1/src/suricata.c:2884
6 0x7fea733f62b0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202b0)
7 0x5643ef8761a9 in _start (/usr/local/bin/suricata+0xc51a9)

Ticketno: Bug #2349

7 years agoconf: use of NULL-pointer in DetectLoadCompleteSigPath
Wolfgang Hotwagner [Fri, 8 Dec 2017 22:01:38 +0000 (22:01 +0000)] 
conf: use of NULL-pointer in DetectLoadCompleteSigPath

The "sig_file" argument of DetectLoadCompleteSigPath() is not checked for NULL-values. If this argument is NULL a SEGV occurs because of a dereferenced NULL-pointer in strlen in PathIsAbsolute. This commit fixes bug #2347. Here is the ASAN-output:

==17170==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x7fd1afa00646 bp 0x7ffe8398e6d0 sp 0x7ffe8398de58 T0)
    0 0x7fd1afa00645 in strlen (/lib/x86_64-linux-gnu/libc.so.6+0x80645)
    1 0x7fd1b3242eec  (/usr/lib/x86_64-linux-gnu/libasan.so.3+0x3beec)
    2 0x5561c8cddf7f in PathIsAbsolute /root/suricata-1/src/util-path.c:40
    3 0x5561c8cddfea in PathIsRelative /root/suricata-1/src/util-path.c:65
    4 0x5561c89275e4 in DetectLoadCompleteSigPath /root/suricata-1/src/detect.c:264
    5 0x5561c8929e75 in SigLoadSignatures /root/suricata-1/src/detect.c:486
    6 0x5561c8c0f2b3 in LoadSignatures /root/suricata-1/src/suricata.c:2419
    7 0x5561c8c1051d in PostConfLoadedDetectSetup /root/suricata-1/src/suricata.c:2550
    8 0x5561c8c12424 in main /root/suricata-1/src/suricata.c:2887
    9 0x7fd1af9a02b0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202b0)
    10 0x5561c87b31a9 in _start (/usr/local/bin/suricata+0xc51a9)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV (/lib/x86_64-linux-gnu/libc.so.6+0x80645) in strlen

7 years agoconf: NULL-pointer dereference in ConfUnixSocketIsEnable
Wolfgang Hotwagner [Fri, 8 Dec 2017 21:39:11 +0000 (21:39 +0000)] 
conf: NULL-pointer dereference in ConfUnixSocketIsEnable

The value for the configuration-option "unix-command.enabled" is not properly checked in ConfUnixSocketIsEnable. This causes a NULL-pointer dereference in strcmp. This commit fixes bug #2346. The ASAN-output looks like:

ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x7f03b69737cc bp 0x7ffcef322c10 sp 0x7ffcef322390 T0)
0 0x7f03b69737cb (/usr/lib/x86_64-linux-gnu/libasan.so.3+0x447cb)
1 0x5617a76d3f55 in ConfUnixSocketIsEnable /root/suricata-1/src/util-conf.c:104
2 0x5617a741b6e7 in DetectEngineMultiTenantSetup /root/suricata-1/src/detect-engine.c:2447
3 0x5617a769e0c3 in PostConfLoadedDetectSetup /root/suricata-1/src/suricata.c:2527
4 0x5617a76a0424 in main /root/suricata-1/src/suricata.c:2887
5 0x7f03b30c82b0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202b0)
6 0x5617a72411a9 in _start (/usr/local/bin/suricata+0xc51a9)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV (/usr/lib/x86_64-linux-gnu/libasan.so.3+0x447cb

7 years agoconf: Memory-leak in DetectAddressTestConfVars
Wolfgang Hotwagner [Fri, 8 Dec 2017 21:05:29 +0000 (21:05 +0000)] 
conf: Memory-leak in DetectAddressTestConfVars

There is a memory-leak in DetectAddressTestConfVars. If the programm takes the "goto error"-path, the pointers gh and ghn will not be freed. This commit fixes bug #2345. Here is the ASAN-output:

=================================================================
ERROR: LeakSanitizer: detected memory leaks

Direct leak of 24 byte(s) in 1 object(s) allocated from:
0 0x7f4347cb1d28 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.3+0xc1d28)
1 0x55fe1fc8dcfc in DetectAddressHeadInit /root/suricata-1/src/detect-engine-address.c:1534
2 0x55fe1fc8c50a in DetectAddressTestConfVars /root/suricata-1/src/detect-engine-address.c:1306
3 0x55fe1ff356bd in PostConfLoadedSetup /root/suricata-1/src/suricata.c:2696
4 0x55fe1ff365eb in main /root/suricata-1/src/suricata.c:2884
5 0x7f43443892b0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202b0)

Direct leak of 24 byte(s) in 1 object(s) allocated from:
0 0x7f4347cb1d28 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.3+0xc1d28)
1 0x55fe1fc8dcfc in DetectAddressHeadInit /root/suricata-1/src/detect-engine-address.c:1534
2 0x55fe1fc8c524 in DetectAddressTestConfVars /root/suricata-1/src/detect-engine-address.c:1310
3 0x55fe1ff356bd in PostConfLoadedSetup /root/suricata-1/src/suricata.c:2696
4 0x55fe1ff365eb in main /root/suricata-1/src/suricata.c:2884
5 0x7f43443892b0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202b0)

SUMMARY: AddressSanitizer: 48 byte(s) leaked in 2 allocation(s).

7 years agooutput: don't deadlock on log reopen failure
Victor Julien [Thu, 7 Dec 2017 16:47:03 +0000 (17:47 +0100)] 
output: don't deadlock on log reopen failure

If output log reopen fails, don't try to output the error. This would
lead to a deadlock as reopen was called from a SCLogMessage call. This
call already held the output lock.

Bug #2306.

7 years agoconfigure: style fixup
Victor Julien [Mon, 11 Dec 2017 16:58:20 +0000 (17:58 +0100)] 
configure: style fixup

7 years agodetect: move rule loading into loader files
Victor Julien [Sun, 8 Oct 2017 11:52:12 +0000 (13:52 +0200)] 
detect: move rule loading into loader files

7 years agodetect: move keyword registration into own file
Victor Julien [Sun, 8 Oct 2017 10:37:41 +0000 (12:37 +0200)] 
detect: move keyword registration into own file

7 years agodetect: move grouping/building code into own file
Victor Julien [Sun, 8 Oct 2017 10:17:33 +0000 (12:17 +0200)] 
detect: move grouping/building code into own file

Clean up main detect.c file by moving things related to rule
grouping out.

7 years agodetect: move unittests into tests/
Victor Julien [Sun, 8 Oct 2017 09:55:55 +0000 (11:55 +0200)] 
detect: move unittests into tests/

7 years agompm/ac-ks: apply offset/depth
Victor Julien [Mon, 6 Nov 2017 13:41:39 +0000 (14:41 +0100)] 
mpm/ac-ks: apply offset/depth