]> git.ipfire.org Git - thirdparty/suricata.git/log
thirdparty/suricata.git
5 years agodetect: refactoring parsing of ip range 4886/head
Philippe Antoine [Sat, 25 Apr 2020 09:38:53 +0000 (11:38 +0200)] 
detect: refactoring parsing of ip range

To optimize first netmask

5 years agosignature: minimizes ip CIDR for ip range
Philippe Antoine [Wed, 22 Apr 2020 07:54:49 +0000 (09:54 +0200)] 
signature: minimizes ip CIDR for ip range

Example leading to over allocation is 41.232.107.2-43.252.37.6

5 years agodecode/erspan: Warn on ERSPAN Type I config 4882/head
Jeff Lucovsky [Thu, 23 Apr 2020 14:07:18 +0000 (10:07 -0400)] 
decode/erspan: Warn on ERSPAN Type I config

This commit checks whether pre-6.x settings for ERSPAN Type I are
present. ERSPAN Type I is no longer enabled/disabled through a
configuration setting -- it's always enabled.

When a setting exists to enable/disable ERSPAN Type I decoding, a
warning message is logged.

Enabling/disabling ERSPAN Type I decode has been deprecated in 6.x

5 years agodecode/erspan: Add warning ERSPAN Type I config
Jeff Lucovsky [Thu, 23 Apr 2020 14:05:05 +0000 (10:05 -0400)] 
decode/erspan: Add warning ERSPAN Type I config

This commit adds a warning value when ERSPAN Type I configuration
settings are detected; specifically, when ERSPAN Type I `enabled` is
specified.

Enabling/disabling ERSPAN Type I decode has been deprecated in 6.x

5 years agodoc: typo: http.server_body should be http.response_body
Jason Ish [Fri, 24 Apr 2020 15:55:13 +0000 (09:55 -0600)] 
doc: typo: http.server_body should be http.response_body

Thanks to Jason Williams for pointing this out.

5 years agoflowbits: fix hang in flowbits 'or' parsing
Victor Julien [Sat, 25 Apr 2020 12:25:29 +0000 (14:25 +0200)] 
flowbits: fix hang in flowbits 'or' parsing

5 years agofuzz: suppress too noisy htp errors check 4878/head
Victor Julien [Sat, 25 Apr 2020 05:48:25 +0000 (07:48 +0200)] 
fuzz: suppress too noisy htp errors check

5 years agonapatech: Correct timestamp rounding issue
Jeff Lucovsky [Fri, 24 Apr 2020 14:28:54 +0000 (10:28 -0400)] 
napatech: Correct timestamp rounding issue

This commit fixes the conversion of timestamps. Without the extra
parens, the resulting timestamp value for usecs will be 1 or 0 due to
the operator precedence order (+ takes precedence over ?:)

5 years agonapatech: Check for out-of-band control operations
Jeff Lucovsky [Fri, 24 Apr 2020 14:28:32 +0000 (10:28 -0400)] 
napatech: Check for out-of-band control operations

This commit causes the packet source to check for out of band control
operations when there are no packets immediately available.

5 years agodag: Check for out-of-band control operations
Jeff Lucovsky [Fri, 24 Apr 2020 14:27:20 +0000 (10:27 -0400)] 
dag: Check for out-of-band control operations

This commit causes the packet source to check for out of band control
operations when there are no packets immediately available.

5 years agonapatech: Restructure Packet/Hostbuffer release
Phil Young [Fri, 24 Apr 2020 21:43:32 +0000 (17:43 -0400)] 
napatech: Restructure Packet/Hostbuffer release

The end-of-processing has been restructured so that Packet and Hostbuffer
data structures are now released within the NapatechReleasePacket() callback
function.

5 years agoaf-packet: change type of cluster_id to uint16_t
Shivani Bhardwaj [Sat, 21 Dec 2019 07:40:25 +0000 (13:10 +0530)] 
af-packet: change type of cluster_id to uint16_t

5 years agosrc: remove multiple uses of atoi
Shivani Bhardwaj [Sat, 21 Dec 2019 07:36:01 +0000 (13:06 +0530)] 
src: remove multiple uses of atoi

atoi() and related functions lack a mechanism for reporting errors for
invalid values. Replace them with calls to the appropriate
ByteExtractString* functions.

Partially closes redmine ticket #3053.

5 years agoAdd wrappers for validating range checks
Shivani Bhardwaj [Tue, 21 Apr 2020 20:52:46 +0000 (02:22 +0530)] 
Add wrappers for validating range checks

5 years agofastlog: copyright year bump and remove stale comments 4864/head
Victor Julien [Fri, 24 Apr 2020 08:28:06 +0000 (10:28 +0200)] 
fastlog: copyright year bump and remove stale comments

5 years agofastlog: fix unlikely memleak
Victor Julien [Fri, 24 Apr 2020 08:27:18 +0000 (10:27 +0200)] 
fastlog: fix unlikely memleak

Fix memleak is case of alloc error during startup.

5 years agothash: suppress coverity fp's
Victor Julien [Fri, 24 Apr 2020 08:23:51 +0000 (10:23 +0200)] 
thash: suppress coverity fp's

5 years agodatasets: suppress coverity fp's
Victor Julien [Fri, 24 Apr 2020 08:21:11 +0000 (10:21 +0200)] 
datasets: suppress coverity fp's

5 years agorfb: Update incomplete handling in parser.
frank honza [Tue, 14 Apr 2020 10:04:13 +0000 (12:04 +0200)] 
rfb: Update incomplete handling in parser.

This commit adds an updated incomplete handling for the RFB-Parser. If
incomplete data is processed, the successfully consumed position and
length of remainder + 1 is returned. If the next packet is not empty
suricata will call the parser again.

This commit is a result of discussion on https://github.com/OISF/suricata/pull/4792.

5 years agogithub-ci: check all commits on pr
Jason Ish [Tue, 21 Apr 2020 15:29:57 +0000 (09:29 -0600)] 
github-ci: check all commits on pr

On a pull request, attempt to compile all commits from
the base branch to the head of the PR branch.

The job is in a separate workflow file to limit it to
pull-requests only, as the base branch is not available
on push (something to look into).

5 years agohttp: adds debug check against too many warnings
Philippe Antoine [Wed, 15 Apr 2020 12:31:37 +0000 (14:31 +0200)] 
http: adds debug check against too many warnings

5 years agodetect/ftp: FTP memory accounting fixes
Jeff Lucovsky [Tue, 21 Apr 2020 14:36:27 +0000 (10:36 -0400)] 
detect/ftp: FTP memory accounting fixes

This commit continues the work started by @vanlink and corrects the
accounting of FTP memory usage against the memcap limit.

5 years agoapp-layer: fix protocol detection bail conditions for TCP fastopen
Victor Julien [Tue, 21 Apr 2020 08:52:04 +0000 (10:52 +0200)] 
app-layer: fix protocol detection bail conditions for TCP fastopen

5 years agodetect/lua: Unregister object during free
Jeff Lucovsky [Wed, 22 Apr 2020 23:12:26 +0000 (19:12 -0400)] 
detect/lua: Unregister object during free

This commit removes the registration for the object being freed.

5 years agodetect: Provide `de_ctx` to free functions
Jeff Lucovsky [Wed, 22 Apr 2020 23:12:02 +0000 (19:12 -0400)] 
detect: Provide `de_ctx` to free functions

This commit makes sure that the `DetectEngineCtx *` is available
to each detector's "free" function.

5 years agodetect: Provide function to clear per-thread ctx
Jeff Lucovsky [Sat, 21 Mar 2020 14:10:09 +0000 (10:10 -0400)] 
detect: Provide function to clear per-thread ctx

This commit provides an interface to free previously allocated
per-thread contextual information on the keyword lists.

5 years agoflowbits: Allow support for flowbit ORing 4847/head
Shivani Bhardwaj [Wed, 29 Jan 2020 14:50:24 +0000 (20:20 +0530)] 
flowbits: Allow support for flowbit ORing

This patch allows to OR multiple flowbits on isset and isnotset flowbit
actions.

e.g.
Earlier in order to check if either fb1 or fb2 was set, it was required
to write two rules,
```
alert ip any any -> any any (msg:\"Flowbit fb1 isset\"; flowbits:isset,fb1; sid:1;)
alert ip any any -> any any (msg:\"Flowbit fb2 isset\"; flowbits:isset,fb2; sid:2;)
```

now, the same can be achieved with
```
alert ip any any -> any any (msg:\"Flowbit fb2 isset\"; flowbits:isset,fb1|fb2; sid:23;)
```

This operator can be used to check if one of the many flowbits is set
and also if one of the many flowbits is not set.

5 years agodoc/perf: minor improvements 4839/head
Victor Julien [Mon, 20 Apr 2020 13:39:32 +0000 (15:39 +0200)] 
doc/perf: minor improvements

5 years agodoc: add performance analysis section
Andreas Herz [Thu, 9 Apr 2020 13:23:40 +0000 (15:23 +0200)] 
doc: add performance analysis section

5 years agoftp: use switch for ftp commands for style
Philippe Antoine [Mon, 16 Mar 2020 13:52:32 +0000 (14:52 +0100)] 
ftp: use switch for ftp commands for style

5 years agoftp: FTPGetAlstateProgress for done port commands
Philippe Antoine [Mon, 16 Mar 2020 13:48:40 +0000 (14:48 +0100)] 
ftp: FTPGetAlstateProgress for done port commands

For a done transaction with command PORT,
we expect FTP_STATE_FINISHED
and we got FTP_STATE_PORT_DONE instead
which prevented logging of these transactions

We change the order of the evaluations to get the right result

5 years agoftp: indent FTPParseResponse again
Philippe Antoine [Fri, 20 Mar 2020 13:42:50 +0000 (14:42 +0100)] 
ftp: indent FTPParseResponse again

5 years agoftp: FTPParseResponse bufferizes lines
Philippe Antoine [Mon, 16 Mar 2020 13:46:51 +0000 (14:46 +0100)] 
ftp: FTPParseResponse bufferizes lines

Protects against evasion by TCP packet splitting

The problem arised if the FTP response is split on multiple packets

The fix is to bufferize the content, until we get a complete line

5 years agodetect: fix insertion in linked list for fast pattern
Philippe Antoine [Mon, 20 Apr 2020 11:57:44 +0000 (13:57 +0200)] 
detect: fix insertion in linked list for fast pattern

Make sure we do not add the same list_id twice
by checking at least all the lists with the current priority

5 years agoconf/datadir: fix possible out of bounds array access
Victor Julien [Fri, 17 Apr 2020 13:00:40 +0000 (15:00 +0200)] 
conf/datadir: fix possible out of bounds array access

5 years agodatasets: remove useless variables
Victor Julien [Fri, 17 Apr 2020 12:58:06 +0000 (14:58 +0200)] 
datasets: remove useless variables

5 years agodatasets: add 'dataset-remove' unix command
Victor Julien [Tue, 14 Apr 2020 12:21:31 +0000 (14:21 +0200)] 
datasets: add 'dataset-remove' unix command

5 years agodatasets: add 'remove' support
Victor Julien [Mon, 13 Apr 2020 14:31:50 +0000 (16:31 +0200)] 
datasets: add 'remove' support

5 years agothash: add 'remove' support
Victor Julien [Mon, 13 Apr 2020 14:31:35 +0000 (16:31 +0200)] 
thash: add 'remove' support

5 years agodatasets: improve 'dataset-add' error checking
Victor Julien [Mon, 13 Apr 2020 13:47:18 +0000 (15:47 +0200)] 
datasets: improve 'dataset-add' error checking

5 years agodatasets: fix return values for 'add's
Victor Julien [Tue, 14 Apr 2020 19:49:33 +0000 (21:49 +0200)] 
datasets: fix return values for 'add's

5 years agodatasets: fix ref cnt handling
Victor Julien [Tue, 14 Apr 2020 19:44:34 +0000 (21:44 +0200)] 
datasets: fix ref cnt handling

Each 'add' and 'lookup' would increment the use_cnt, without anything
bringing it back down.

Since there is no removal yet, nothing is actually affected by it yet.

5 years agodatasets: silence noisy 'dataset-add' log
Victor Julien [Tue, 14 Apr 2020 19:57:06 +0000 (21:57 +0200)] 
datasets: silence noisy 'dataset-add' log

5 years agobuild: default to c11 standard 4832/head
Victor Julien [Mon, 13 Apr 2020 07:10:20 +0000 (09:10 +0200)] 
build: default to c11 standard

Rearrange pcap includes to fix builds on MinGW

5 years agobuild: don't limit C std to c99 (gnu99)
Victor Julien [Mon, 13 Apr 2020 05:47:02 +0000 (07:47 +0200)] 
build: don't limit C std to c99 (gnu99)

Now that C11 atomics and thread local storage are supported, the
compiler can figure out what version to use.

5 years agoconfigure: check for u_int and friends
Victor Julien [Mon, 13 Apr 2020 19:04:45 +0000 (21:04 +0200)] 
configure: check for u_int and friends

5 years agofuzz: include pcap headers through suricata-common.h
Victor Julien [Tue, 14 Apr 2020 09:06:17 +0000 (11:06 +0200)] 
fuzz: include pcap headers through suricata-common.h

5 years agothreads: remove u_long usage
Victor Julien [Tue, 14 Apr 2020 11:19:01 +0000 (13:19 +0200)] 
threads: remove u_long usage

5 years agothreads: make thread local storage manadatory
Victor Julien [Sun, 12 Apr 2020 12:03:24 +0000 (14:03 +0200)] 
threads: make thread local storage manadatory

Support either the __thread GNUism or the C11 _Thread_local.

Use 'thread_local' to point to the one that is used. Convert existing
__thread user to 'thread_local'.

Remove non-thread-local code from the packet pool code.

5 years agoatomics: stdatomics.h version of SC_ATOMIC_* wrappers
Victor Julien [Sun, 12 Apr 2020 09:12:28 +0000 (11:12 +0200)] 
atomics: stdatomics.h version of SC_ATOMIC_* wrappers

5 years agodetect-engine/tags: avoid confusion over data type
Victor Julien [Sun, 12 Apr 2020 09:25:45 +0000 (11:25 +0200)] 
detect-engine/tags: avoid confusion over data type

5 years agoatomics: remove unused macros
Victor Julien [Sun, 12 Apr 2020 10:00:57 +0000 (12:00 +0200)] 
atomics: remove unused macros

5 years agoatomics: add SC_ATOMIC_INITPTR macro
Victor Julien [Sun, 12 Apr 2020 09:09:34 +0000 (11:09 +0200)] 
atomics: add SC_ATOMIC_INITPTR macro

Until now both atomic ints and pointers were initialized by SC_ATOMIC_INIT
by setting them to 0. However, C11's atomic pointer type cannot be
initialized this way w/o causing compiler warnings.

As a preparation to supporting C11's atomics, this patch introduces a
new macro to initialize atomic pointers and updates the relevant callers
to use it.

5 years agoatomics: change SC_ATOMIC_ADD to 'fetch_add'
Victor Julien [Sun, 12 Apr 2020 09:06:32 +0000 (11:06 +0200)] 
atomics: change SC_ATOMIC_ADD to 'fetch_add'

Until this point the SC_ATOMIC_ADD macro pointed to a 'add_fetch'
intrinsic. This patch changes it to a 'fetch_add'.

There are 2 reasons for this:

1. C11 stdatomics.h has only 'atomic_fetch_add' and no 'add_fetch'
   So this patch prepares for adding support for C11 atomics.

2. It was not consistent with SC_ATOMIC_SUB, which did use 'fetch_sub'
   and not 'sub_fetch'.

Most callers are not using the return value, so these are unaffected.
The callers that do use the return value are updated.

5 years agoatomics: avoid unnecessary (direct) CAS use
Victor Julien [Sun, 12 Apr 2020 09:25:12 +0000 (11:25 +0200)] 
atomics: avoid unnecessary (direct) CAS use

5 years agoatomics: remove useless SC_ATOMIC_DESTROY
Victor Julien [Sun, 12 Apr 2020 10:02:56 +0000 (12:02 +0200)] 
atomics: remove useless SC_ATOMIC_DESTROY

5 years agoatomics: remove spinlocked fallback
Victor Julien [Wed, 4 Mar 2020 14:45:15 +0000 (15:45 +0100)] 
atomics: remove spinlocked fallback

5 years agofuzz: fix applayer eof check segv
Victor Julien [Wed, 15 Apr 2020 20:46:19 +0000 (22:46 +0200)] 
fuzz: fix applayer eof check segv

5 years agofuzz: stop app layer target as Suricata
Philippe Antoine [Wed, 15 Apr 2020 12:30:48 +0000 (14:30 +0200)] 
fuzz: stop app layer target as Suricata

Before being overwhelmed by successive errors

5 years agoconf: returns instead of exiting in ConfYamlParse
Philippe Antoine [Wed, 15 Apr 2020 09:48:13 +0000 (11:48 +0200)] 
conf: returns instead of exiting in ConfYamlParse

So that we can keep on fuzzing even on too much recursion

5 years agofuzz: add missing debug validation to configure
Victor Julien [Tue, 14 Apr 2020 12:42:17 +0000 (14:42 +0200)] 
fuzz: add missing debug validation to configure

5 years agofuzz: add configure wrapper for oss-fuzz 4813/head
Victor Julien [Tue, 14 Apr 2020 09:02:50 +0000 (11:02 +0200)] 
fuzz: add configure wrapper for oss-fuzz

5 years agoincludes: don't include sys/types.h twice 4811/head
Victor Julien [Mon, 13 Apr 2020 08:22:43 +0000 (10:22 +0200)] 
includes: don't include sys/types.h twice

5 years agoprivs: include headers in suricata-common.h
Victor Julien [Mon, 13 Apr 2020 08:21:46 +0000 (10:21 +0200)] 
privs: include headers in suricata-common.h

5 years agoconf/yaml: include yaml.h after suricata-common.h
Victor Julien [Mon, 13 Apr 2020 08:21:07 +0000 (10:21 +0200)] 
conf/yaml: include yaml.h after suricata-common.h

5 years agodoc/install: refer to buster as Debian stable
Sascha Steinbiss [Fri, 10 Apr 2020 09:53:54 +0000 (11:53 +0200)] 
doc/install: refer to buster as Debian stable

5 years agofuzz/sigpcap: enable all of eve
Victor Julien [Mon, 13 Apr 2020 06:19:14 +0000 (08:19 +0200)] 
fuzz/sigpcap: enable all of eve

5 years agodetect/iponly: fix parsing of '0' valued netmask
Victor Julien [Sat, 11 Apr 2020 11:54:00 +0000 (13:54 +0200)] 
detect/iponly: fix parsing of '0' valued netmask

5 years agoutil/mem: reduce scope of win32 specific include 4806/head
Victor Julien [Thu, 28 Nov 2019 14:05:05 +0000 (15:05 +0100)] 
util/mem: reduce scope of win32 specific include

5 years agoutil/mem: cleanup by moving atomic from mem hdr
Victor Julien [Wed, 27 Nov 2019 19:03:44 +0000 (20:03 +0100)] 
util/mem: cleanup by moving atomic from mem hdr

5 years agoutil/mem: move most logic to functions
Victor Julien [Wed, 27 Nov 2019 16:37:37 +0000 (17:37 +0100)] 
util/mem: move most logic to functions

Reduce macro use and simplify code. Also reduces compiled code
size.

5 years agoutil/mem: remove old debug code for counting allocs
Victor Julien [Wed, 27 Nov 2019 17:13:32 +0000 (18:13 +0100)] 
util/mem: remove old debug code for counting allocs

5 years agologging: turn SCLog and SCLogErr into funcs
Victor Julien [Wed, 27 Nov 2019 11:01:01 +0000 (12:01 +0100)] 
logging: turn SCLog and SCLogErr into funcs

Reduces compiled code size.

5 years agocommon: add ATTR_FMT_PRINTF wrapper
Victor Julien [Thu, 28 Nov 2019 13:55:29 +0000 (14:55 +0100)] 
common: add ATTR_FMT_PRINTF wrapper

Wraps around __attribute__((format(printf, (x), (y))))

5 years agocommon: use suricata-common.h in more places
Victor Julien [Thu, 28 Nov 2019 13:47:53 +0000 (14:47 +0100)] 
common: use suricata-common.h in more places

5 years agocommon: use WARN_UNUSED macro
Victor Julien [Thu, 28 Nov 2019 13:18:59 +0000 (14:18 +0100)] 
common: use WARN_UNUSED macro

5 years agodetect/mpm: don't process empty store
Victor Julien [Thu, 28 Nov 2019 10:47:56 +0000 (11:47 +0100)] 
detect/mpm: don't process empty store

5 years agodns/tests: comment typo fixes 4802/head
Victor Julien [Fri, 10 Apr 2020 11:50:33 +0000 (13:50 +0200)] 
dns/tests: comment typo fixes

5 years agodecode: return bool network layer
Victor Julien [Mon, 2 Mar 2020 14:45:25 +0000 (15:45 +0100)] 
decode: return bool network layer

So that the caller can set the correct event type on error.

5 years agodecode/hdlc: initial support
Victor Julien [Thu, 13 Feb 2020 20:43:30 +0000 (21:43 +0100)] 
decode/hdlc: initial support

5 years agodecode: single network layer entrypoint
Victor Julien [Wed, 26 Feb 2020 13:06:26 +0000 (14:06 +0100)] 
decode: single network layer entrypoint

This way new layers can be added in a single place.

5 years agodecode: create linklayer entry point
Victor Julien [Fri, 21 Feb 2020 15:07:57 +0000 (16:07 +0100)] 
decode: create linklayer entry point

Make AF_PACKET and PCAP mode use it.

5 years agodecode/ieee8021ah: fix possible packet truncation
Victor Julien [Wed, 26 Feb 2020 19:34:25 +0000 (20:34 +0100)] 
decode/ieee8021ah: fix possible packet truncation

5 years agofuzz/siginit: cleanup detect engine every 1024 runs
Victor Julien [Thu, 9 Apr 2020 08:05:21 +0000 (10:05 +0200)] 
fuzz/siginit: cleanup detect engine every 1024 runs

5 years agoapp-layer-template: fix log typo
Andreas Herz [Thu, 9 Apr 2020 13:24:14 +0000 (15:24 +0200)] 
app-layer-template: fix log typo

5 years agoconf/yaml: limit recursion depth while paring YAML
Jason Ish [Thu, 9 Apr 2020 21:59:23 +0000 (15:59 -0600)] 
conf/yaml: limit recursion depth while paring YAML

A deeply nested YAML file can cause a stack-overflow while
reading in the configuration to do the recursive parser. Limit
the recursion level to something sane (128) to prevent this
from happening.

The default Suricata configuration has a recursion level of 128
so there is still lots of room to grow (not that we should).

Redmine ticket:
https://redmine.openinfosecfoundation.org/issues/3630

5 years agodetect/parse: properly free bidir sigs in error path
Victor Julien [Fri, 10 Apr 2020 08:02:43 +0000 (10:02 +0200)] 
detect/parse: properly free bidir sigs in error path

5 years agodetect/parse: fix minor memory leak in error path
Victor Julien [Fri, 10 Apr 2020 07:55:36 +0000 (09:55 +0200)] 
detect/parse: fix minor memory leak in error path

Only reachable on SCMalloc so should be unlikely to be reached.

5 years agofuzz: allow uninitialized stats api 4793/head
Victor Julien [Wed, 8 Apr 2020 20:08:39 +0000 (22:08 +0200)] 
fuzz: allow uninitialized stats api

5 years agofuzz: remove UNITTEST dependency
Victor Julien [Tue, 7 Apr 2020 10:41:12 +0000 (12:41 +0200)] 
fuzz: remove UNITTEST dependency

Expose UTH flow builder to new 'FUZZ' define as well. Move UTHbufferToFile
as well and rename it to a more generic 'TestHelperBufferToFile'.

This way UNITTESTS can be disabled. This leads to smaller code size
and more realistic testing as in some parts of the code things
behave slightly differently when UNITTESTS are enabled.

5 years agodns: improve probe_tcp handling of incomplete data
Philippe Antoine [Mon, 16 Mar 2020 09:22:35 +0000 (10:22 +0100)] 
dns: improve probe_tcp handling of incomplete data

5 years agosource/erf: validate record length before read
Jason Ish [Mon, 6 Apr 2020 16:50:36 +0000 (10:50 -0600)] 
source/erf: validate record length before read

Check the ERF record length before attempting to read it as
a record length less than the size of the record header
is invalid.

Redmine ticket:
https://redmine.openinfosecfoundation.org/issues/3593

5 years agofuzz/sigpcap: initialize empty packet pool 4785/head
Victor Julien [Tue, 7 Apr 2020 05:01:59 +0000 (07:01 +0200)] 
fuzz/sigpcap: initialize empty packet pool

Fixes runs with --enable-debug-validation. The target did not init a
packet pool, so for a tunnel packet would try to get a packet from
an uninitialized pool. In non-debug mode, this silently works by
falling back to a packet from alloc.

    (gdb) bt
    #0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
    #1  0x00007ffff35a6801 in __GI_abort () at abort.c:79
    #2  0x00007ffff359639a in __assert_fail_base (fmt=0x7ffff371d7d8 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=assertion@entry=0x555557fe7260 "!(pool->initialized == 0)",
        file=file@entry=0x555557fe7220 "tmqh-packetpool.c", line=line@entry=253, function=function@entry=0x555557fe7500 <__PRETTY_FUNCTION__.21181> "PacketPoolGetPacket") at assert.c:92
    #3  0x00007ffff3596412 in __GI___assert_fail (assertion=0x555557fe7260 "!(pool->initialized == 0)", file=0x555557fe7220 "tmqh-packetpool.c", line=253,
        function=0x555557fe7500 <__PRETTY_FUNCTION__.21181> "PacketPoolGetPacket") at assert.c:101
    #4  0x00005555577e24be in PacketPoolGetPacket () at tmqh-packetpool.c:253
    #5  0x0000555556914ecd in PacketGetFromQueueOrAlloc () at decode.c:183
    #6  0x00005555569161e1 in PacketTunnelPktSetup (tv=0x555559863980 <tv>, dtv=0x614000068e40, parent=0x61e0000fc080, pkt=0x61e0000fc470 "LL", len=72, proto=DECODE_TUNNEL_IPV4) at decode.c:286
    #7  0x00005555569de694 in DecodeIPv4inIPv6 (tv=0x555559863980 <tv>, dtv=0x614000068e40, p=0x61e0000fc080, pkt=0x61e0000fc470 "LL", plen=72) at decode-ipv6.c:59
    #8  0x00005555569e60b5 in DecodeIPV6ExtHdrs (tv=0x555559863980 <tv>, dtv=0x614000068e40, p=0x61e0000fc080, pkt=0x61e0000fc470 "LL", len=112) at decode-ipv6.c:522
    #9  0x00005555569e846f in DecodeIPV6 (tv=0x555559863980 <tv>, dtv=0x614000068e40, p=0x61e0000fc080, pkt=0x61e0000fc420 "cLL", len=255) at decode-ipv6.c:641
    #10 0x0000555556a032f9 in DecodeRaw (tv=0x555559863980 <tv>, dtv=0x614000068e40, p=0x61e0000fc080, pkt=0x61e0000fc420 "cLL", len=255) at decode-raw.c:70
    #11 0x0000555557659ba8 in DecodePcapFile (tv=0x555559863980 <tv>, p=0x61e0000fc080, data=0x614000068e40) at source-pcap-file.c:412
    #12 0x0000555556573401 in LLVMFuzzerTestOneInput (data=0x613000000047 "\241\262\315\064", size=339) at tests/fuzz/fuzz_sigpcap.c:158
    #13 0x0000555557a4dc66 in main (argc=2, argv=0x7fffffffdfa8) at tests/fuzz/onefile.c:51

That line:

    BUG_ON(pool->initialized == 0);

5 years agodoc: Update documentation for by_rule and by_both thresholds.
Todd Mortimer [Mon, 30 Mar 2020 23:49:32 +0000 (23:49 +0000)] 
doc: Update documentation for by_rule and by_both thresholds.

5 years agodetect/threshold: Add tests for thresholding by_rule and by_both.
Todd Mortimer [Mon, 30 Mar 2020 23:49:04 +0000 (23:49 +0000)] 
detect/threshold: Add tests for thresholding by_rule and by_both.

5 years agodetect/threshold: Add a common function to (re)allocate the by_rule threshold table.
Todd Mortimer [Mon, 30 Mar 2020 23:47:47 +0000 (23:47 +0000)] 
detect/threshold: Add a common function to (re)allocate the by_rule threshold table.

Ensure that the by_rule threshold table is initialized if a rule
is thresholded by_rule. Replace manual table reallocaton with calls
to the common function.

5 years agodetect/threshold: Refactor threshold calculation to handle by_rule and by_both.
Todd Mortimer [Mon, 30 Mar 2020 23:45:50 +0000 (23:45 +0000)] 
detect/threshold: Refactor threshold calculation to handle by_rule and by_both.

The only difference between threshold calculations for by_src/by_dst,
by_rule or by_both is which table stores the DetectThresholdEntry.
Refactor the ThresholdHandlePacket* functions to do table lookup and
storage individually, but calculate thresholds in a common function.

5 years agotime: Add TIMEVAL_EARLIER and TIMEVAL_DIFF_SEC macros.
Todd Mortimer [Mon, 30 Mar 2020 23:38:24 +0000 (23:38 +0000)] 
time: Add TIMEVAL_EARLIER and TIMEVAL_DIFF_SEC macros.

Make it easy to compare 'struct timeval's and get their difference.

5 years agodetect/threshold: Parse by_rule and by_both in rules.
Todd Mortimer [Mon, 30 Mar 2020 23:36:12 +0000 (23:36 +0000)] 
detect/threshold: Parse by_rule and by_both in rules.

Also add tests for parsing them.

5 years agoapp-layer/proto-detect: minor cleanup 4784/head
Victor Julien [Mon, 6 Apr 2020 17:35:24 +0000 (19:35 +0200)] 
app-layer/proto-detect: minor cleanup

Make sure the mask calculation is u32.