]> git.ipfire.org Git - thirdparty/suricata.git/commit
ips/stream: handle low mem(cap) crash 3681/head
authorVictor Julien <victor@inliniac.net>
Fri, 22 Feb 2019 19:41:41 +0000 (20:41 +0100)
committerVictor Julien <victor@inliniac.net>
Mon, 25 Feb 2019 10:24:36 +0000 (11:24 +0100)
commitdceecd6804f058e92634c6a4fdb6a63457cb0eba
tree08211095e30fe75d38819b6bd84e5aa3d877d5f1
parentcc281f59ae1c6e2ab2f24df1ccf4994521a438d6
ips/stream: handle low mem(cap) crash

In low memory or memcap reached conditions a crash could happen in
inline stream detection.

The crash had the following path:

A packet would come in and it's data was added to the stream. Due
to earlier packet loss, the stream buffer uses a stream buffer block
tree to track the data blocks. When trying to add the current packets
block to the tree, the memory limit was reached and the add fails.

A bit later in the pipeline for the same packet, the inline stream
mpm inspection function gets the data to inspect. For inline mode
this is the current packet + stream data before and after the packet,
if available.

The code looking up the packets data in the stream would not
consider the possibility that the stream block returned wasn't
the right one. The tree search returns either the correct or the
next block. In adjusting the returned block to add the extra stream
data it would miscalculate offsets leading to a corrupt pointer to the
data.

This patch more carefully checks the result of the lookup, and
falls back to simply inspecting the packet payload if the lookup
didn't produce the expected result.

Bug 2842.

Reported-by: Ad Schellevis <ad@opnsense.org>
src/stream-tcp-reassemble.c