Commit Graph

9677 Commits (bc1fd4c6fc6c6e97ebd4ff1accc572f1d85caa3c)
 

Author SHA1 Message Date
Victor Julien bc1fd4c6fc changelog: update for 4.1.7 6 years ago
Victor Julien 2a9bb46b4a rust: build and dist fixes
Bring up to date with 5.0.x.
6 years ago
Jason Ish 2c5b4dbbb5 rust/Makefile: Don't include Cargo.toml
There is no need to include Cargo.toml in the distribution,
it is always generated from Cargo.toml.in during
./configure.

(cherry picked from commit c6f168eb98)
6 years ago
vanlink 3224a593a0 stream/reassembly: fix data overlap check
Fix function CheckOverlap bug.

(cherry picked from commit 2456f27d08)
6 years ago
Victor Julien 8f40658061 streaming/api: fix overlap check
In some cases a SBB could be seen as overlapping with the requested
offset, when it was in fact precisely before it. In some special cases
this could lead to the stream engine not progressing the 'raw' progress.

(cherry picked from commit 2c050187a3)
6 years ago
Victor Julien 726d326084 nfs: implement post-GAP transaction cleanup
Close all prior transactions in the direction of the GAP, except the
file xfers. Those use their own logic described below.

After a GAP all normal transactions are closed. File transactions
are left open as they can handle GAPs in principle. However, the
GAP might have contained the closing of a file and therefore it
may remain active until the end of the flow.

This patch introduces a time based heuristic for these transactions.
After the GAP all file transactions are stamped with the current
timestamp. If 60 seconds later a file has seen no update, its marked
as closed.

This is meant to fix resource starvation issues observed in long
running SMB sessions where packet loss was causing GAPs. Due to the
similarity of the NFS and SMB parsers, this issue is fixed for NFS
as well in this patch.

Bug #3424.
Bug #3425.

(cherry picked from commit f68c255f09)
6 years ago
Victor Julien 22af774800 threading: fix global declaration of trans_q
(cherry picked from commit bd3fac73b1)
6 years ago
Victor Julien 0e36544719 tls: fix missing extern logic for cert_id tracking
(cherry picked from commit aeefc82eb9)
6 years ago
Victor Julien 389ac211a1 stats: fix missing extern keyword
(cherry picked from commit 62c0f3d2b4)
6 years ago
Victor Julien 6541310c6d defrag: fix use of globals
(cherry picked from commit 903291f88a)
6 years ago
Victor Julien c28285a228 threading: fix queue handlers globals use
(cherry picked from commit 5c3c6c609c)
6 years ago
Victor Julien edf3714767 htp: fix globals use for flags
(cherry picked from commit 3ae1854d2f)
6 years ago
Victor Julien 36340d09d9 proto: fix globals use
(cherry picked from commit 85289f3283)
6 years ago
Victor Julien 0f3854013e flow: fix global variable use
(cherry picked from commit 5e583f3a12)
6 years ago
Victor Julien 57378688e0 stream: fix global declaration of the config
(cherry picked from commit 29f54a34ae)
6 years ago
Victor Julien 8b665b85ac threading/modules: fix global declarations
(cherry picked from commit 2436daccd9)
6 years ago
Victor Julien 50ebe000c8 ippair: fix global declarations
(cherry picked from commit c5f4b41881)
6 years ago
Victor Julien f7941518c0 host: fix global declarations
(cherry picked from commit 0a006d2258)
6 years ago
Victor Julien 11c15a3041 mpm: fix global declarations
(cherry picked from commit 29780d6164)
6 years ago
Victor Julien 41e44556f1 detect: fix global declaration of sigmatch_table
(cherry picked from commit b89059bda7)
6 years ago
Victor Julien 84174441f1 spm: fix global declaration of spm_table
(cherry picked from commit 0118e07d57)
6 years ago
Victor Julien 380bc80e09 threading: fix global declaration of threading_set_cpu_affinity
(cherry picked from commit a12c0b499d)
6 years ago
Victor Julien decb327d6e unix-socket: avoid using global variable w/o extern
(cherry picked from commit 45955d2e58)
6 years ago
Victor Julien 626d8976d2 decode: fix default-packet-size global variable
(cherry picked from commit a9a522fac3)
6 years ago
Timo Sigurdsson da0e5dcbbb init: Fix dropping privileges in nflog runmode
Using the run-as configuration option with the nflog capture method
results in the following error during the startup of suricata:
[ERRCODE: SC_ERR_NFLOG_BIND(248)] - nflog_bind_pf() for AF_INET failed

This is because SCDropMainThreadCaps does not have any capabilities
defined for the nflog runmode (unlike other runmodes). Therefore, apply
the same capabilities to the nflog runmode that are already defined for
the nfqueue runmode. This has been confirmed to allow suricata start
and drop its privileges in the nflog runmode.

Fixes redmine issue #3265.

Signed-off-by: Timo Sigurdsson <public_timo.s@silentcreek.de>
(cherry picked from commit 1262ecbde0)
6 years ago
Victor Julien 6d28097fe4 afl: fix compilation
(cherry picked from commit f05c12b70f)
6 years ago
Danny Browning 716189d6c9 source-pcap-file: Pcap File Init Failure Handling (#1694)
Better handle case where pcap file receive thread fails to initialize. Allow
initialize to complete, but terminate the thread quickly. Delay exiting
unix socket runmode as late as possible.

(cherry picked from commit c0ab45aa6f)
6 years ago
Jason Ish 1a2eba906b travis: remove cocci and macos builds
These tests are covered by Github actions and removing
them may speed up the Travis builds to get results sooner.

Its still worth keeping some of these builds as they test
more compile time options than the Github Actions currently
do.

Backport of 222a81f85d.
6 years ago
Jason Ish bb613fbd2a rust: remove unnecessary parentheses (Rust 1.40 fixup)
Rust 1.40 in strict mode will now fail the build on the
presence of unnecessary parentheses.

warning: unnecessary parentheses around type
  --> src/smb/smb2_ioctl.rs:41:12
   |
41 |         -> (&mut SMBTransaction)
   |            ^^^^^^^^^^^^^^^^^^^^^ help: remove these parentheses
   |
   = note: `#[warn(unused_parens)]` on by default

(cherry picked from commit 5ee8323028)
6 years ago
Jeff Lucovsky 75b48f2c90 modbus: Update correct TX flags
(cherry picked from commit d4428d94de)
6 years ago
Victor Julien 184894fb56 smb: handle file transactions post-GAP
After a GAP all normal transactions are closed. File transactions
are left open as they can handle GAPs in principle. However, the
GAP might have contained the closing of a file and therefore it
may remain active until the end of the flow.

This patch introduces a time based heuristic for these transactions.
After the GAP all file transactions are stamped with the current
timestamp. If 60 seconds later a file has seen no update, its marked
as closed.

This is meant to fix resource starvation issues observed in long
running SMB sessions where packet loss was causing GAPs.
6 years ago
Jason Ish b530fee787 flow: expose last time as a function
This function returns the individual components
of the timeval in output pointers making it suitable
for use over Rust FFI.
6 years ago
Fabrice Fontaine 5826cc9a7a configure.ac: fix --disable-geoip
$enableval should be used to know if the user has passed --enable-geoip
or --disable-geoip

Fixes:
 - http://autobuild.buildroot.org/results/a7a34f760ae5fe0922fdb720b8234dbcd85ed222

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
(cherry picked from commit 61becb29bf)
6 years ago
Jason Ish e5c9407901 github-ci: use container for 18.04 build
As the action runs natively on 18.04 we were not explicitly
setting a container, but this means we're using what GitHub
provides us as a default state which might be broken. Instead
use the standard Ubuntu 18.04 container.

(cherry picked from commit b9515671be)
6 years ago
Victor Julien c91a7ad9dc changelog: update for 4.1.6 6 years ago
Victor Julien 3b1e2bd2d4 detect/asn1: fix offset bounds checking
(cherry picked from commit 627cc23769)
6 years ago
Jason Ish 14ad0ec24d ipv4: continue parsing options after invalid option
As long as an option has a valid length, we can continue
parsing the options after an invalid one.

(cherry picked from commit 8609939e60)
6 years ago
Jason Ish b76f1830ae ipv4: fail packet decoding on bad ipv4 option length
Currently all failures in IPv4 option decode are ignore with
respect to continuing to handle the packet.

Change this to fail, and abort handling the packet if the
option length is invalid.

Ticket 3328:
https://redmine.openinfosecfoundation.org/issues/3328

(cherry picked from commit df8db1ddb0)
6 years ago
Jeff Lucovsky b42f10b967 decode: Change return type of IPv4 and TCP options decode
The return value from the options decoder in TCP and IPv4 is ignored.
This commit changes the return type of the function to `void` and
modifies existing return points to return without a value.

When an error occurs, the packet state is being set to indicate whether
it's valid or not and the existing return value is never used.

(cherry picked from commit 8e464530ef)
6 years ago
Victor Julien 1c63d39058 stream: reject broken ACK packets
Fix evasion posibility by rejecting packets with a broken ACK field.
These packets have a non-0 ACK field, but do not have a ACK flag set.

Bug #3324.

Reported-by: Nicolas Adba
(cherry picked from commit fa692df37a)
6 years ago
Victor Julien ea0659de76 stream: fix SYN_SENT RST/FIN injection
RST injection during the SYN_SENT state could trick Suricata into marking
a session as CLOSED. The way this was done is: using invalid TSECR value
in RST+ACK packet. The ACK was needed to force Linux into considering the
TSECR value and compare it to the TSVAL from the SYN packet.

The second works only against Windows. The client would not use a TSVAL
but the RST packet would. Windows will reject this, but Suricata considered
the RST valid and triggered the CLOSED logic.

This patch addresses both. When the SYN packet used timestamp support
the timestamp of incoming packet is validated. Otherwise, packet responding
should not have a timestamp.

Bug #3286

Reported-by: Nicolas Adba
(cherry picked from commit 9f0294fadc)
6 years ago
Victor Julien 268a79cc1f configure: require libhtp 0.5.32
(cherry picked from commit 9bcc1118e1)
6 years ago
Victor Julien 2838d1130c htp: close request only from request side
This allows the response side to keep going for just
a bit longer.

(cherry picked from commit 040aff5197)
6 years ago
Victor Julien 7dd8089add stream: in IDS mode, call app-layer at EOF
On stream end call app-layer with empty message in IDS mode.

(cherry picked from commit 77539e08fc)
6 years ago
Victor Julien 8b9e0c9858 stats: fix stats not always syncing in flow timeout
(cherry picked from commit 83bbe287e7)
6 years ago
Victor Julien 27caf51cac threading: add debug validation for stale packets
(cherry picked from commit 58b9a2dc21)
6 years ago
Victor Julien d954cd7550 threading: fix shutdown race condition
A BUG_ON statement would seemingly randomly trigger during the threading
shutdown logic. After a packet thread reached the THV_RUNNING_DONE state,
it would sometimes still receive flow timeout packets which would then
remain unprocessed.

1 main:   TmThreadDisableReceiveThreads(); <- stop capturing packets
2 worker: -> TmThreadTimeoutLoop (THV_FLOW_LOOP) phase starts
3 main:   FlowForceReassembly();           <- inject packets from flow engine
4 main:   TmThreadDisablePacketThreads();  <- then disable packet threads
5 main:   -> checks if 'worker' is ready processing packets
6 main:   -> sends THV_KILL to worker
7 worker: breaks out of TmThreadTimeoutLoop and changes to THV_RUNNING_DONE.

Part of the problem was with (5) above. When checking if the worker was
already done with its work, TmThreadDisablePacketThreads would not consider
the injected flow timeout packets. The second part of the problem was with (7),
where the worker checked if it was ready with the TmThreadTimeoutLoop in a
thread unsafe way.

As a result TmThreadDisablePacketThreads would not wait long enough for the
worker(s) to finish its work and move the threads to the THV_RUNNING_DONE
phase by issuing the THV_KILL command.

When waiting for packet processing threads to process all in-flight packets,
also consider the 'stream_pq'. This will have received the flow timeout
packets.

Bug #1871.

(cherry picked from commit fe9aeed0f0)
6 years ago
Victor Julien e6bf601068 threading: fix flow timeout loop race
(cherry picked from commit 825173a2ba)
6 years ago
Victor Julien c251403ce7 threads: improve flow timeout loop
Improve thread safety and remove BUG_ON

(cherry picked from commit 92d38683ce)
6 years ago
Victor Julien 166b2a8216 threading: improve thread queues checking by dumping more info
(cherry picked from commit 56354afd41)
6 years ago