Commit Graph

4473 Commits (a7a77e32cac298a64c6c2ea5d30d4dc37ef3f5bc)
 

Author SHA1 Message Date
Victor Julien fb4967912c http: add meta-field-limit option
The meta-field-option allows for setting the hard limit of request
and response fields in HTTP. In requests this applies to the request
line and headers, not the body. In responses, this applies to the
response line and headers, not the body.

Libhtp uses a default limit of 18k. If this is reached an event is
raised.

Ticket 986.
11 years ago
Victor Julien 2ec57c36b4 SSE 4.2 memcmp: don't read beyond var boundary
In the SSE 4.2 SCMemcmpLowercase implementation, there would be a
_mm_load_si128 of a 2 byte array. However, _mm_load_si128 loads
16 bytes, causing it to read beyond the var. I don't think this lead
to crashes, as it was a static var, but clangs ASAN complained about
it.
11 years ago
Ken Steele d3c6913e28 Reduce the size of Packet structure
Share memory space for IPV4Vars and (IPV6Vars, IPV6ExtHdrs), since a
packet can only be either IPv4 or IPv6, but not both.

Share memory for TCPVars, UDPVars, ICMPV4Vars and ICMPV6Vars, since a
packet can only be only of these.

Then move other structure members around to remove holes reported by pahole.

This reduces the size of the Packet structure from 2944 bytes (46 cachelines)
down to 1976 (31 cachelines), a 33% reduction.
11 years ago
Victor Julien a8b971c710 http: strip 'proxy' part of http_uri
Strip the 'proxy' parts from the normalized uri as inspected by http_uri,
urilen, pcre /U and others.

  In a request line like:
    GET http://suricata-ids.org/blah/ HTTP/1.1
  the normalized URI will now be:
    /blah/

This doesn't affect http_raw_uri. So matching the hostname, etc is still
possible through this keyword.

Additionally, a new per HTTP 'personality' option was added to change
this behavior: "uri-include-all":

  uri-include-all: <true|false>
    Include all parts of the URI. By default the
    'scheme', username/password, hostname and port
    are excluded. Setting this option to true adds
    all of them to the normalized uri as inspected
    by http_uri, urilen, pcre with /U and the other
    keywords that inspect the normalized uri.
    Note that this does not affect http_raw_uri.

So adding uri-include-all:true to all personalities in the yaml will
restore the old default behavior.

Ticket 1008.
11 years ago
Ken Steele de6cbb01c8 Allocate mPIPE packet ingress queue in each worker thread.
Move the allocation of the mPipe ingress queue from a loop over
the number of workers in the main init function to being done inside
each worker thread. This allows allocating the memory locally on the
worker's CPU without needing to figure out ahead of time where that thread
will be running. This fixes one case of static mapping of workers to CPUs.

Use __thread to hold the queue rather than a global tables of queues.
11 years ago
Ken Steele 601c7c8e3c Cleanup Tile build for -Werror
Just the changes needed for the Tile architecture to compile cleanly with
-Werror.
11 years ago
Ken Steele f16b339fc4 Rename checksums to level3_comp_csum and level4_comp_csum.
This will also sharing even more memory in the Packet_ structure.
11 years ago
Eric Leblond 3dceca70ee suricata: move some code into PostConfLoadedSetup
All functions before daemonization are initialisation functions and thus the
call can be moved in PostConfLoadedSetup.
11 years ago
Victor Julien c89f03fc1e Remove mkinstalldirs (bug #1041) 11 years ago
Victor Julien a84c502e50 Add SSE support to --build-info 11 years ago
Victor Julien 49a54713da memcmp: don't use SSE intrinsics if less that 16 bytes are available in SSE_4_2 version. 11 years ago
Victor Julien 8ffa30dd88 profiling: don't init rule profiling ctx if rule profiling is disabled 11 years ago
Victor Julien 660636c5bc profiling: when config is missing, keyword profiling is disabled 11 years ago
Victor Julien 2982408155 pcap: register counters for old pcap versions as well 11 years ago
Victor Julien 9a42f621f5 Fix pcre_study error check
pcre_study returning NULL is not necessarily an error, from the man page
pcre_study(3):

  "If the function returns NULL, either it could not find any additional
   information, or there was an error. You can tell the difference by
   looking at the error value. It is NULL in first case."

Older libpcre versions would return NULL, causing errors.
11 years ago
Ken Steele c6a8d0ab6b Share Packet checksum values for TCP, UDP, IPv6. ICMPv4 and ICMPv6
Keep a separate checksum for IPV4, since a packet can have both an IPV4
checksum and a TCPV4 checksum, or IPV4 and UDPV4 checksum.

This will allow future sharing of more values.

Use PACKET_RESET_CHECKSUMS() in Unit Tests in place of setting the
individual checksum values.
11 years ago
Ken Steele 27caa8aea7 Add missing case for DNS_CONFIG
Found compiling with -Werror
11 years ago
Victor Julien 36bc8d5cd0 http & tls: fix transaction handling
When http and/or tls logging is disabled, the app layer would still
be flagged as logging. This caused transactions not to be freed until
the end of the flow as the logged tx id would never increment.

This fix postpones the setting of the app layer parser "logger"
flag to the point where we know the logger is enabled.
11 years ago
Victor Julien bee5ff172b dns: fix transaction handling
When logging is disabled, the app layer would still be flagged
as logging. This caused transactions not to be freed until the
end of the flow as the logged tx id would never increment.

This fix postpones the setting of the app layer parser "logger"
flag to the point where we know the logger is enabled.
11 years ago
Victor Julien 6730f3d5cc DNS: trigger logging for toserver dir when previous reply is lost. 11 years ago
Victor Julien 61cdd9be6b dns: detect case of request flooding
In the case where DNS requests are sent over the same flow w/o a
reply being received, we now set an event in the flow and refuse
to add more transactions to the state. This protects the DNS
handling from getting overloaded slowing down everything.

A new option to configure this behaviour was added:

app-layer:
  protocols:
    dnsudp:
       enabled: yes
       detection-ports:
         udp:
           toserver: 53
       request-flood: 750

The request-flood parameter can be 0 (disabling this feature) or a
positive integer. It defaults to 500.

This means that if 500 unreplied requests are seen in a row an event
is set. Rule 2240007 was added to dns-events.rules to match on this.
11 years ago
Ken Steele c1b9f0e1f4 Formatting and comment updates in flow files
Some reformatting to meet coding standards.

Added a few comments to make it more clear where p->flow gets set.
11 years ago
Victor Julien 72a147b6f1 detect: only inspect smsg for valid tcp packets
Packets that are rejected by the stream engine are not considered
part of an established tcp session. By allowing them to inspect
an smsg, some smsgs would not be properly inspected.
11 years ago
Ken Steele dfc2117e80 Add Unit test to check TCPv4 and IPV4 checksums together.
Copied SigTest26TCPV4Keyword and added check for invalid IPV4 checksums.
Created new SigTest26TCPV4AndIPV4Keyword test with a new packet with valid
IPV4 checksums.
11 years ago
Victor Julien 0c12ad6bd0 stream: fix sequence number on smsg
When multiple segments were put into a smsg, the seq would be updated
each time a segment was added. Because of this, the seq wasn't pointing
to the start of the data.

This caused some false negatives when the fast_pattern was in the raw
stream, but another part of the inspection was in the state. Because of
the wrong seq, the inspection of the smsg could be delayed. This in turn,
could make the inspection engine consider a TX inspected, even if it wasn't
fully yet.
11 years ago
Ken Steele 86c6861b40 Give Suricata priority to receive packets over Linux with mPIPE.
When installing the rules to tell mPIPE to send packet to Suricata,
give it a higher priority than the default used by Linux. This way if
Linux also tells mPIPE to send it packets, Suricata will get them
instead, as long as Suricata is running.
11 years ago
Victor Julien 9a7353e148 http: don't decode + to space by default
Libhtp decodes the + character in the query string to a space by default.
Suricata rules (e.g. etpro sid 2806767) are expecting to see the space in
the http_uri buffer.

Added an option per htp config to reenable this default behavior:

    query-plusspace-decode: yes

Bug #1035.
11 years ago
Victor Julien 25636597af Fix live rule reload confusing delayed detect
Fixes bug 1023 and the previous attempt to fix it.
11 years ago
Victor Julien 5906eeb8c8 detect: don't do rule reload during delayed detect
When both rule reloads and delayed detect are enabled, make sure we don't
trigger a reload during delayed detect initialization.

Bug #1023.
11 years ago
Victor Julien 7b687da726 profiling: add tracking of missing keywords 11 years ago
Victor Julien 5686c673ec profiling: per buffer profiling 11 years ago
Victor Julien 9419b9cbb6 detect: add tostring function for DETECT_SM_LIST_ enum. 11 years ago
Victor Julien 97bfcac444 profiling: introduce per keyword profiling
Initial version of per keyword profiling. Prints stats about
how ofter a keyword was checked and what the costs were.
11 years ago
Victor Julien 210eede033 content inspection: introduce no_match label 11 years ago
Victor Julien e416b2cdfb stream: fix IPv6 pseudo packet setup
Bug #1022: IPv6 pseudo packet setup using reverse logic of IPv4.
11 years ago
Victor Julien ef17b7b9f4 stream: reduce scope of StreamTcpPseudoPacketSetupHeader 11 years ago
Victor Julien ce4d262c7d IPv4 decoder compile warning fix 11 years ago
Victor Julien 07c97412f3 DNS: fix response name length logic
In some cases where the length would be calculated as 0 we'd loop until
we'd hit our loop limit.

Update name logic everywhere.
11 years ago
Anoop Saldanha 95ed53c590 Fix for #1003.
Now that we call stream reassembly directly from proto detection, we will
need to check if reassembly has been disabled inside the stream reassembly
callback.

This prevents any calls to bypass and re-enter proto detection, despite
having reassembly disabled.
11 years ago
Victor Julien 7ebd1e6433 Counters: fix delayed-detect counter registration
Make sure we register the detect.alerts counter before packet runtime starts
even in delayed detect mode. The registration of new counters at packet
runtime is not supported by the counters api and might lead to crashes as there
is no proper locking to allow for this operation.

This changes how delayed detect works a bit. Now we call the ThreadInit
callback twice. The first call will only register the counter. The 2nd call
will do all the other setup. This way the counter is registered before the
counters api starts operating in the packet runtime.

Fixes the segv reported in ticket #1018.
11 years ago
Victor Julien 9e88c51e24 Counters: move perf critical var to the top of the SCPerfContext struct 11 years ago
Victor Julien ed03196a20 Counter: fix accidental logic change 11 years ago
Victor Julien 45dfecafd4 Counters: remove unused updated field 11 years ago
Victor Julien 49087f21e4 Optimizations to reduce branch misses 11 years ago
Victor Julien 64f5129f12 Counters: remove unused tm_name comparison loops 11 years ago
Victor Julien 76c305c128 Counters: fix unix socket 11 years ago
Victor Julien 25aeeebdf7 Counters: merge SCPerfCounterName into SCPerfCounter as there was a 1 on 1 mapping 11 years ago
Victor Julien 3445d17ae5 Counters: remove SCPerfCounterValue struct as we no longer support multiple data types 11 years ago
Victor Julien 677cd03e52 Counters: more unused code removal 11 years ago
Victor Julien 8d4a61a789 Counters: remove unused code 11 years ago