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

Detect cleanups/v6 #9986

Closed
wants to merge 18 commits into from
Closed

Conversation

victorjulien
Copy link
Member

#9974 rebased, with comments addressed

Hitting the recursion limit should be rare.
This is a convinience addition to abstract away the internals of
the InspectionBuffer in keyword specific detection code.
Integrate with rest of content inspect code.
Use stack local var instead of DetectEngineThreadCtx member. Instead
setup a stack local struct that both counts and holds the limit. Make sure
the limit is a const so we can avoid rereading it.

This is part of an effort to reduce the size of the DetectEngineThreadCtx
structure and reduce the number of memory writes to it. Additionally, it
is part of an effect to reduce the number of places where detection
tracks various forms of state.
Flatten else branches after terminating ifs.
Since recursive content matching goes through the buffer from left to
right, it is possible to bail early when isdataat is part of the
recursive checking. If `isdataat:50,relative` fails for offset 10, it
will surely also fail for offset 20. So break inspection in such cases.

The exception is for dynamic isdataat, where the value is determined
by a prior byte_extract that may be updated during the recursion.
DetectEngineThreadCtx::replist is managed elsewhere.
Adjust includes to enable this.
Move reference count to top of DetectEngineThreadCtx, to move it to the
same cache line as the other members that are checked first in Detect().
Move members used by DetectEngineContentInspection() to the same cache line.
@victorjulien victorjulien added this to the 8.0 milestone Dec 7, 2023
Copy link
Member

@inashivb inashivb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Nice cleanups! :)

b->inspect_len, b->inspect_offset, b->flags, inspection_mode);
if (r == 1)
return true;
else
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: unnecessary else

@victorjulien victorjulien mentioned this pull request Dec 7, 2023
@suricata-qa
Copy link

Information: QA ran without warnings.

Pipeline 16909

@victorjulien
Copy link
Member Author

Merged in #9999, thanks!

@victorjulien victorjulien deleted the detect-cleanups/v6 branch February 20, 2024 12:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants