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

Mt fixes/v6 #9365

Closed
wants to merge 13 commits into from
Closed

Mt fixes/v6 #9365

wants to merge 13 commits into from

Conversation

victorjulien
Copy link
Member

Replaces #9359.

SV_BRANCH=OISF/suricata-verify#1349

Fixes multi-tenant multi-loader crashes.

Bug: OISF#6247.
Implement a new design for handling var name id's. The old logic
was aware of detection engine versions and generally didn't work
well for multi-tenancy cases. Other than memory leaks and crashes,
logging of var names worked or failed based on which tenant was
loaded last.

This patch implements a new approach, where there is a global store
of vars and their id's for the lifetime of the program.

Overall Design:

Base Store: "base"

Used during keyword registration. Operates under lock. Base is shared
between all detect engines, detect engine versions and tenants.
Each variable name is ref counted.

During the freeing of a detect engine / tenant, unregistration decreases
the ref cnt.

Base has both a string to id and a id to string hash table. String to
id is used during parsing/registration. id to string during unregistration.

Active Store Pointer (atomic)

The "active" store atomic pointer points to the active lookup store. The call
to `VarNameStoreActivate` will build a new lookup store and hot swap
the pointer.

Ensuring memory safety. During the hot swap, the pointer is replaced, so
any new call to the lookup functions will automatically use the new store.
This leaves the case of any lookup happening concurrently with the pointer
swap. For this case we add the old store to a free list. It gets a timestamp
before which it cannot be freed.

Free List

The free list contains old stores that are waiting to get removed. They
contain a timestamp that is checked before they are freed.

Bug: OISF#6044.
Bug: OISF#6201.
Switch to DetectParseRegex and use a local pcre2_match_data to
avoid concurrency issues.

Bug: OISF#6247.
Free all tenants registered in the master.
Add option to specify path from which to load the tenants.

Mostly meant to be used in testing.
Store yaml path in de ctx, for reloads w/o path.

This allows for a simpler `reload-tenant N`, where the previously
used yaml is reloaded.
Command to reload all tenants. Their original yaml path will be
used.
@victorjulien victorjulien mentioned this pull request Aug 9, 2023
@codecov
Copy link

codecov bot commented Aug 9, 2023

Codecov Report

Merging #9365 (fa0fd8b) into master (c5d83d0) will increase coverage by 0.14%.
The diff coverage is 71.20%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #9365      +/-   ##
==========================================
+ Coverage   82.18%   82.32%   +0.14%     
==========================================
  Files         968      968              
  Lines      274128   274186      +58     
==========================================
+ Hits       225287   225723     +436     
+ Misses      48841    48463     -378     
Flag Coverage Δ
fuzzcorpus 64.02% <44.75%> (-0.03%) ⬇️
suricata-verify 61.17% <61.30%> (+0.28%) ⬆️
unittests 62.88% <48.07%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

@suricata-qa
Copy link

Information: QA ran without warnings.

Pipeline 15550

@suricata-qa
Copy link

Information: QA ran without warnings.

Pipeline 15559

@victorjulien victorjulien mentioned this pull request Aug 10, 2023
@victorjulien
Copy link
Member Author

replaced by #9368

@victorjulien victorjulien deleted the mt-fixes/v6 branch August 12, 2023 05:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants