Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prefilter engines v99g #2310

Merged
merged 134 commits into from Sep 29, 2016
Merged

prefilter engines v99g #2310

merged 134 commits into from Sep 29, 2016

Commits on Sep 29, 2016

  1. detect-parse: add new func to get last sigmatch

    Add SigMatchGetLastSM which simply returns the very last SM added
    to the signature.
    
    Minor cleanups.
    victorjulien committed Sep 29, 2016
    Configuration menu
    Copy the full SHA
    c4dcb20 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    d461c78 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    3d5807b View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    b40ecb7 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    1380853 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    4229e60 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    704afeb View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    6d54b70 View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    bd03307 View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    d647db1 View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    ad3a55d View commit details
    Browse the repository at this point in the history
  12. Configuration menu
    Copy the full SHA
    ff70e0c View commit details
    Browse the repository at this point in the history
  13. Configuration menu
    Copy the full SHA
    a41695f View commit details
    Browse the repository at this point in the history
  14. Configuration menu
    Copy the full SHA
    7c47016 View commit details
    Browse the repository at this point in the history
  15. mpm: remove Cleanup API call

    It's unused by all of the implementations.
    victorjulien committed Sep 29, 2016
    Configuration menu
    Copy the full SHA
    4c0ab68 View commit details
    Browse the repository at this point in the history
  16. prefilter: rename PatternMatcherQueue datatype

    In preparation of the introduction of more general purpose prefilter
    engines, rename PatternMatcherQueue to PrefilterRuleStore. The new
    engines will fill this structure a similar way to the current mpm
    prefilters.
    victorjulien committed Sep 29, 2016
    Configuration menu
    Copy the full SHA
    bb0cd0e View commit details
    Browse the repository at this point in the history
  17. detect: rename non_mpm lists/vars to non_pf

    Rename to non_pf: non prefilter.
    victorjulien committed Sep 29, 2016
    Configuration menu
    Copy the full SHA
    17bc029 View commit details
    Browse the repository at this point in the history
  18. detect: rename SignatureNonMpmStore

    New name is SignatureNonPrefilterStore to reflect that it's not just
    about MPM anymore.
    victorjulien committed Sep 29, 2016
    Configuration menu
    Copy the full SHA
    3dad824 View commit details
    Browse the repository at this point in the history
  19. prefilter: introduce prefilter engines

    Introduce abstraction layer for prefilter engines.
    victorjulien committed Sep 29, 2016
    Configuration menu
    Copy the full SHA
    5bcdbe3 View commit details
    Browse the repository at this point in the history
  20. http_uri: mpm prefilter engine

    Inspect partial request line as well.
    victorjulien committed Sep 29, 2016
    Configuration menu
    Copy the full SHA
    b62c4cc View commit details
    Browse the repository at this point in the history
  21. Configuration menu
    Copy the full SHA
    72f2a78 View commit details
    Browse the repository at this point in the history
  22. Configuration menu
    Copy the full SHA
    9ff5703 View commit details
    Browse the repository at this point in the history
  23. Configuration menu
    Copy the full SHA
    746a169 View commit details
    Browse the repository at this point in the history
  24. Configuration menu
    Copy the full SHA
    7a46364 View commit details
    Browse the repository at this point in the history
  25. Configuration menu
    Copy the full SHA
    a43a693 View commit details
    Browse the repository at this point in the history
  26. Configuration menu
    Copy the full SHA
    61c3748 View commit details
    Browse the repository at this point in the history
  27. Configuration menu
    Copy the full SHA
    5218849 View commit details
    Browse the repository at this point in the history
  28. Configuration menu
    Copy the full SHA
    86d303e View commit details
    Browse the repository at this point in the history
  29. Configuration menu
    Copy the full SHA
    4d57b2f View commit details
    Browse the repository at this point in the history
  30. Configuration menu
    Copy the full SHA
    9cab3ea View commit details
    Browse the repository at this point in the history
  31. http_headers: mpm prefilter engines

    Register for both regular headers and trailers.
    victorjulien committed Sep 29, 2016
    Configuration menu
    Copy the full SHA
    9b6fd6b View commit details
    Browse the repository at this point in the history
  32. Configuration menu
    Copy the full SHA
    5646dd9 View commit details
    Browse the repository at this point in the history
  33. Configuration menu
    Copy the full SHA
    cef12ed View commit details
    Browse the repository at this point in the history
  34. http_raw_header: mpm prefilter engine

    Register for both regular headers and trailer.
    victorjulien committed Sep 29, 2016
    Configuration menu
    Copy the full SHA
    0019a7b View commit details
    Browse the repository at this point in the history
  35. Configuration menu
    Copy the full SHA
    7acdc66 View commit details
    Browse the repository at this point in the history
  36. Configuration menu
    Copy the full SHA
    08407b6 View commit details
    Browse the repository at this point in the history
  37. sgh: remove unused flags

    victorjulien committed Sep 29, 2016
    Configuration menu
    Copy the full SHA
    82d3c0b View commit details
    Browse the repository at this point in the history
  38. Configuration menu
    Copy the full SHA
    85cb749 View commit details
    Browse the repository at this point in the history
  39. prefilter: implement prefilter keyword

    Introduce prefilter keyword to force a keyword to be used as prefilter.
    
    e.g.
    alert tcp any any -> any any (content:"A"; flags:R; prefilter; sid:1;)
    alert tcp any any -> any any (content:"A"; flags:R; sid:2;)
    alert tcp any any -> any any (content:"A"; dsize:1; prefilter; sid:3;)
    alert tcp any any -> any any (content:"A"; dsize:1; sid:4;)
    
    In sid 2 and 4 the content keyword is used in the MPM engine.
    In sid 1 and 3 the flags and dsize keywords will be used.
    victorjulien committed Sep 29, 2016
    Configuration menu
    Copy the full SHA
    5623969 View commit details
    Browse the repository at this point in the history
  40. Configuration menu
    Copy the full SHA
    f80623f View commit details
    Browse the repository at this point in the history
  41. Configuration menu
    Copy the full SHA
    99b9896 View commit details
    Browse the repository at this point in the history
  42. Configuration menu
    Copy the full SHA
    ea26ee9 View commit details
    Browse the repository at this point in the history
  43. Configuration menu
    Copy the full SHA
    8798bf4 View commit details
    Browse the repository at this point in the history
  44. prefilter: engine for tcp flags keyword

    If there are many rules for TCP flags these rules would be inspected
    against each TCP packet. Even though the flags check is not expensive,
    the combined cost of inspecting multiple rules against each and every
    packet is high.
    
    This patch implements a prefilter engine for flags. If a rule group
    has rules looking for specific flags and engine for that flag or
    flags combination is set up. This way those rules are only inspected
    if the flag is actually present in the packet.
    victorjulien committed Sep 29, 2016
    Configuration menu
    Copy the full SHA
    31ad0a1 View commit details
    Browse the repository at this point in the history
  45. prefilter: engine for ack rules

    Rules for the 'ack' keyword are uncommon, but if used inspected
    against almost every packet.
    victorjulien committed Sep 29, 2016
    Configuration menu
    Copy the full SHA
    3b4aa06 View commit details
    Browse the repository at this point in the history
  46. Configuration menu
    Copy the full SHA
    9ccd0c0 View commit details
    Browse the repository at this point in the history
  47. detect-dsize: enable prefilter support

    Enable prefilter support for the dsize keyword.
    victorjulien committed Sep 29, 2016
    Configuration menu
    Copy the full SHA
    065d9bc View commit details
    Browse the repository at this point in the history
  48. Configuration menu
    Copy the full SHA
    9195708 View commit details
    Browse the repository at this point in the history
  49. Configuration menu
    Copy the full SHA
    4104f8c View commit details
    Browse the repository at this point in the history
  50. Configuration menu
    Copy the full SHA
    14b0537 View commit details
    Browse the repository at this point in the history
  51. Configuration menu
    Copy the full SHA
    822e034 View commit details
    Browse the repository at this point in the history
  52. Configuration menu
    Copy the full SHA
    9ce3006 View commit details
    Browse the repository at this point in the history
  53. Configuration menu
    Copy the full SHA
    b88c0a5 View commit details
    Browse the repository at this point in the history
  54. Configuration menu
    Copy the full SHA
    10f8e63 View commit details
    Browse the repository at this point in the history
  55. Configuration menu
    Copy the full SHA
    d5e5c11 View commit details
    Browse the repository at this point in the history
  56. Configuration menu
    Copy the full SHA
    f5d2166 View commit details
    Browse the repository at this point in the history
  57. Configuration menu
    Copy the full SHA
    6a3917b View commit details
    Browse the repository at this point in the history
  58. Configuration menu
    Copy the full SHA
    3a86aea View commit details
    Browse the repository at this point in the history
  59. Configuration menu
    Copy the full SHA
    fbe7e0a View commit details
    Browse the repository at this point in the history
  60. Configuration menu
    Copy the full SHA
    5537e25 View commit details
    Browse the repository at this point in the history
  61. Configuration menu
    Copy the full SHA
    9187c20 View commit details
    Browse the repository at this point in the history
  62. prefilter: add 'extra match' logic to packet engines

    Many of the packet engines are very generic. Rules are generally more
    limited.
    
    A rule like 'alert tcp any any -> any 888 (flags:S; sid:1;)' would still
    be inspected against every SYN packet in most cases (it depends a bit on
    rule grouping though).
    
    This extra match logic adds an additional check to these packet engines.
    It can add a check based on alproto, source port and dest port. It uses
    only one of these 3. Priority order is src port > alproto > dst port.
    
    For the ports only 'single' ports are used at this time.
    victorjulien committed Sep 29, 2016
    Configuration menu
    Copy the full SHA
    e2eb9f8 View commit details
    Browse the repository at this point in the history
  63. Configuration menu
    Copy the full SHA
    ace8f9f View commit details
    Browse the repository at this point in the history
  64. Configuration menu
    Copy the full SHA
    34e3484 View commit details
    Browse the repository at this point in the history
  65. Configuration menu
    Copy the full SHA
    fbb0490 View commit details
    Browse the repository at this point in the history
  66. Configuration menu
    Copy the full SHA
    a270dfa View commit details
    Browse the repository at this point in the history
  67. Configuration menu
    Copy the full SHA
    a1accbb View commit details
    Browse the repository at this point in the history
  68. Configuration menu
    Copy the full SHA
    a41bf2a View commit details
    Browse the repository at this point in the history
  69. Configuration menu
    Copy the full SHA
    e3b98d5 View commit details
    Browse the repository at this point in the history
  70. Configuration menu
    Copy the full SHA
    9bb12cc View commit details
    Browse the repository at this point in the history
  71. Configuration menu
    Copy the full SHA
    7329219 View commit details
    Browse the repository at this point in the history
  72. Configuration menu
    Copy the full SHA
    2e878c2 View commit details
    Browse the repository at this point in the history
  73. Configuration menu
    Copy the full SHA
    36f713c View commit details
    Browse the repository at this point in the history
  74. Configuration menu
    Copy the full SHA
    1256038 View commit details
    Browse the repository at this point in the history
  75. Configuration menu
    Copy the full SHA
    dba14b6 View commit details
    Browse the repository at this point in the history
  76. Configuration menu
    Copy the full SHA
    e1eb481 View commit details
    Browse the repository at this point in the history
  77. detect: simplify content inspection types

    Instead of a type per buffer type, pass just 3 possible types:
    packet, stream, state.
    
    The individual types weren't used. State is just there to be
    not packet and not stream.
    victorjulien committed Sep 29, 2016
    Configuration menu
    Copy the full SHA
    ae5846b View commit details
    Browse the repository at this point in the history
  78. mpm: add App Layer MPM registery

    Register keywords globally at start up.
    
    Create a map of the registery per detection engine. This we need because
    the sgh_mpm_context value is set per detect engine.
    
    Remove APP_MPMS_MAX.
    victorjulien committed Sep 29, 2016
    Configuration menu
    Copy the full SHA
    5b2e36a View commit details
    Browse the repository at this point in the history
  79. Configuration menu
    Copy the full SHA
    7289d12 View commit details
    Browse the repository at this point in the history
  80. Configuration menu
    Copy the full SHA
    38e018e View commit details
    Browse the repository at this point in the history
  81. Configuration menu
    Copy the full SHA
    7b98c00 View commit details
    Browse the repository at this point in the history
  82. Configuration menu
    Copy the full SHA
    7813a83 View commit details
    Browse the repository at this point in the history
  83. Configuration menu
    Copy the full SHA
    e4ea38a View commit details
    Browse the repository at this point in the history
  84. Configuration menu
    Copy the full SHA
    6d0632a View commit details
    Browse the repository at this point in the history
  85. Configuration menu
    Copy the full SHA
    43b281a View commit details
    Browse the repository at this point in the history
  86. Configuration menu
    Copy the full SHA
    cf96db0 View commit details
    Browse the repository at this point in the history
  87. Configuration menu
    Copy the full SHA
    644d4dc View commit details
    Browse the repository at this point in the history
  88. Configuration menu
    Copy the full SHA
    91695c8 View commit details
    Browse the repository at this point in the history
  89. Configuration menu
    Copy the full SHA
    b5cd488 View commit details
    Browse the repository at this point in the history
  90. Configuration menu
    Copy the full SHA
    7466144 View commit details
    Browse the repository at this point in the history
  91. Configuration menu
    Copy the full SHA
    a1a2187 View commit details
    Browse the repository at this point in the history
  92. Configuration menu
    Copy the full SHA
    57ae3c4 View commit details
    Browse the repository at this point in the history
  93. Configuration menu
    Copy the full SHA
    e68b221 View commit details
    Browse the repository at this point in the history
  94. Configuration menu
    Copy the full SHA
    6dd4dff View commit details
    Browse the repository at this point in the history
  95. fast_pattern: register app layer mpms automatically

    Allow for duplicate registrations for the same list. After the first
    registration new calls will be ignored.
    victorjulien committed Sep 29, 2016
    Configuration menu
    Copy the full SHA
    960461f View commit details
    Browse the repository at this point in the history
  96. http_request_line: implement keyword and mpm

    Implemented as 'stickybuffer'.
    
    Move all logic into the keyword file and remove bad tests that tested
    URI instead of request line.
    victorjulien committed Sep 29, 2016
    Configuration menu
    Copy the full SHA
    4c98b6c View commit details
    Browse the repository at this point in the history
  97. http_response_body: implement keyword with mpm

    Implemented as 'stickybuffer'.
    victorjulien committed Sep 29, 2016
    Configuration menu
    Copy the full SHA
    f1e3840 View commit details
    Browse the repository at this point in the history
  98. detect state: reorganize flags

    List the common non-buffer specific flags on top.
    victorjulien committed Sep 29, 2016
    Configuration menu
    Copy the full SHA
    bac37fc View commit details
    Browse the repository at this point in the history
  99. detect-engine: improved inspect engines

    Inspect engines are called per signature per sigmatch list. Most
    wrap around DetectEngineContentInspection, but it's more generic.
    
    Until now, the inspect engines were setup in a large per ipproto,
    per alproto, per direction table. For stateful inspection each
    engine needed a global flag.
    
    This approach had a number of issues:
    1. inefficient: each inspection round walked the table and then
       checked if the inspect engine was even needed for the current
       rule.
    2. clumsy registration with global flag registration.
    3. global flag space was approaching the need for 64 bits
    4. duplicate registration for alprotos supporting both TCP and
       TCP (DNS).
    
    This patch introduces a new approach.
    
    First, it does away with the per ipproto engines. This wasn't used.
    
    Second, it adds a per signature list of inspect engine containing
    only those engines that actually apply to the rule.
    
    Third, it gets rid of the global flags and replaces it with flags
    assigned per rule per engine.
    victorjulien committed Sep 29, 2016
    Configuration menu
    Copy the full SHA
    5f99475 View commit details
    Browse the repository at this point in the history
  100. detect-mpm: cleanup

    victorjulien committed Sep 29, 2016
    Configuration menu
    Copy the full SHA
    ad3c97f View commit details
    Browse the repository at this point in the history
  101. Configuration menu
    Copy the full SHA
    9a0bbd6 View commit details
    Browse the repository at this point in the history
  102. detect-engine: new registration call

    Make it more in line with MPM registration.
    victorjulien committed Sep 29, 2016
    Configuration menu
    Copy the full SHA
    5bde86b View commit details
    Browse the repository at this point in the history
  103. Configuration menu
    Copy the full SHA
    0feeb8d View commit details
    Browse the repository at this point in the history
  104. Configuration menu
    Copy the full SHA
    cc96fed View commit details
    Browse the repository at this point in the history
  105. Configuration menu
    Copy the full SHA
    b96c2c5 View commit details
    Browse the repository at this point in the history
  106. Configuration menu
    Copy the full SHA
    4096f76 View commit details
    Browse the repository at this point in the history
  107. Configuration menu
    Copy the full SHA
    eb19eb3 View commit details
    Browse the repository at this point in the history
  108. Configuration menu
    Copy the full SHA
    b314829 View commit details
    Browse the repository at this point in the history
  109. Configuration menu
    Copy the full SHA
    cd8b1b0 View commit details
    Browse the repository at this point in the history
  110. Configuration menu
    Copy the full SHA
    b1adea6 View commit details
    Browse the repository at this point in the history
  111. Configuration menu
    Copy the full SHA
    fc857c5 View commit details
    Browse the repository at this point in the history
  112. Configuration menu
    Copy the full SHA
    edb2936 View commit details
    Browse the repository at this point in the history
  113. Configuration menu
    Copy the full SHA
    a00629a View commit details
    Browse the repository at this point in the history
  114. Configuration menu
    Copy the full SHA
    0496b3f View commit details
    Browse the repository at this point in the history
  115. Configuration menu
    Copy the full SHA
    20e93ba View commit details
    Browse the repository at this point in the history
  116. Configuration menu
    Copy the full SHA
    cd70575 View commit details
    Browse the repository at this point in the history
  117. Configuration menu
    Copy the full SHA
    200a4c1 View commit details
    Browse the repository at this point in the history
  118. Configuration menu
    Copy the full SHA
    a87c196 View commit details
    Browse the repository at this point in the history
  119. Configuration menu
    Copy the full SHA
    e28e98b View commit details
    Browse the repository at this point in the history
  120. Configuration menu
    Copy the full SHA
    c9bb762 View commit details
    Browse the repository at this point in the history
  121. Configuration menu
    Copy the full SHA
    2db094a View commit details
    Browse the repository at this point in the history
  122. Configuration menu
    Copy the full SHA
    08d0fe0 View commit details
    Browse the repository at this point in the history
  123. Configuration menu
    Copy the full SHA
    6f253e1 View commit details
    Browse the repository at this point in the history
  124. Configuration menu
    Copy the full SHA
    8a0bea8 View commit details
    Browse the repository at this point in the history
  125. Configuration menu
    Copy the full SHA
    9e35fa7 View commit details
    Browse the repository at this point in the history
  126. detect app-layer-event: clean up registration

    Move engine and registration into the keyword file.
    
    Register as 'ALPROTO_UNKNOWN' instead of per alproto. The
    registration will only apply it to those rules that have
    events set.
    victorjulien committed Sep 29, 2016
    Configuration menu
    Copy the full SHA
    a24870f View commit details
    Browse the repository at this point in the history
  127. Configuration menu
    Copy the full SHA
    58ac402 View commit details
    Browse the repository at this point in the history
  128. detect: reshuffle keyword registration order

    The order of keyword registration currently affects inspect engine
    registration order and ultimately the order of inspect engines per
    rule. Which in turn affects state keeping.
    
    This patch makes sure the ordering is the same as with older
    releases.
    victorjulien committed Sep 29, 2016
    Configuration menu
    Copy the full SHA
    d36c0c1 View commit details
    Browse the repository at this point in the history
  129. Configuration menu
    Copy the full SHA
    8321f04 View commit details
    Browse the repository at this point in the history
  130. prefilter: use array of engines per sgh

    Instead of the linked list of engines setup an array
    with the engines. This should provide better locality.
    
    Also shrink the engine structure so that we can fit
    2 on a cacheline.
    
    Remove the FreeFunc from the runtime engines. Engines
    now have a 'gid' (global id) that can be used to look
    up the registered Free function.
    victorjulien committed Sep 29, 2016
    Configuration menu
    Copy the full SHA
    798ba01 View commit details
    Browse the repository at this point in the history
  131. Configuration menu
    Copy the full SHA
    4402274 View commit details
    Browse the repository at this point in the history
  132. Configuration menu
    Copy the full SHA
    358eacf View commit details
    Browse the repository at this point in the history
  133. http_header: don't separately inspect trailer yet

    Currently the regular 'Header' inspection code will run each time
    after the HTTP progress moved beyond 'headers'. This will include
    the trailers if there are any.
    
    Leave the code in place as this model will change in the not too
    distant future.
    victorjulien committed Sep 29, 2016
    Configuration menu
    Copy the full SHA
    d9811e5 View commit details
    Browse the repository at this point in the history
  134. Configuration menu
    Copy the full SHA
    5bd906a View commit details
    Browse the repository at this point in the history