Suricata is a network Intrusion Detection System, Intrusion Prevention System and Network Security Monitoring engine developed by the OISF and the Suricata community.
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
Go to file
Eric Leblond 4a1a008009 af-packet: fix looping in ring buffer.
A crash can occurs in the following conditions:
 * Suricata running in other mode than "workers"
 * Kernel fill in the ring buffer
Under this conditions, it is possible that the capture thread reads
a packet that has not yet released by one of the treatment threads
because there is no modification done on the ring buffer entry when
a packet is read. Doing, this it access to memory which can be
released to the kernel and modified. This results in a kind of memory
corruption.

This bug has only been seen recently and this has to be linked with the
read speed improvement recently made in AF_PACKET support.

The patch fixes the issue by modifying the tp_status bitmask in the
ring buffer. It sets the TP_STATUS_USER_BUSY flag when it is confirmed
that the packet will be treated. And at the start of the read, it exits
from the reading loop (returning to poll) when it reaches a packet with
the flag set. As tp_status is set to 0 during packet release the flag
is destroyed when releasing the packet.

Regarding concurrency, we've got a sequence of modification. The
capture thread read the packet and set the flag, then it passes the
queue and the packet get processed by other threads. The change on
tp_status are thus made at different time.

Regarding the value of the flag, the patch uses the last bit of
tp_status to avoid be impacting by a change in kernel. I will
propose a patch to have TP_STATUS_USER_BUSY included in kernel
as this is a generic issue for multithreading application using
AF_PACKET mechanism.
13 years ago
benches
contrib/file_processor Included Action::Syslog by default in config 14 years ago
doc Add missing Makefile.am files for rules/ and doc/ dir. 14 years ago
libhtp spelling corrections documented in redmine bug#533 13 years ago
m4
qa Update coccinelle script to match syntax evolution. 14 years ago
rules decode: decode IPv6-in-IPv6 13 years ago
src af-packet: fix looping in ring buffer. 13 years ago
.gitignore
COPYING
ChangeLog Update changelog for 1.4beta1 13 years ago
LICENSE
Makefile.am Add threshold.config example to EXTRA_DIST as well. 13 years ago
Makefile.cvs
acsite.m4
autogen.sh autotools: error on autoreconf is an error 13 years ago
classification.config
configure.ac Add --enable-luajit option to configure 13 years ago
doxygen.cfg doxygen: generate doc for acquisition modules 13 years ago
mkinstalldirs
reference.config Add md5 to reference.config. 14 years ago
suricata.yaml.in af-packet: add optional emergency mode 13 years ago
threshold.config Add threshold.config file. 13 years ago