-
Notifications
You must be signed in to change notification settings - Fork 724
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
SEGV hs_scan with HS_FLAG_SOM_LEFTMOST #350
Comments
Thanks for reporting this. This is indeed a historical issue left. We'll consider to add suitable quick check for scratch validity later. |
Please refer to latest develop branch. |
This document recommends the allocation of one scratch space per scanning context. Suricata relies on this performance technique. The commit for this change has caused this Suricata issue. I investigated and discovered that the validity check comparing the scratch and database Here's the performance tip from the documentation link: The hs_alloc_scratch() function can accept an existing scratch space and “grow” it to support scanning with another pattern database. This means that instead of allocating one scratch space for every database used by an application, one can call hs_alloc_scratch() with a pointer to the same hs_scratch_t and it will be sized appropriately for use with any of the given databases. |
@jlucovsky |
Thanks for addressing the issue so quickly! |
Roll back fix for github issue #350 About Scratch Usage: For compile time, scratch space is strongly recommended to be allocated immediately after database generation. For runtime, besides using scratch for corresponding database, Hyperscan also allows user to use larger scratch space allocated for another database. When multiple concurrent threads need to use the same databases and a new scratch space is required, cloning the largest one is always safe. This is realized based on API hs_scratch_size() and hs_clone_scratch(). Behaviors beyond above are discouraged and results are undefined.
Roll back fix for github issue #350 About Scratch Usage: For compile time, scratch space is strongly recommended to be allocated immediately after database generation. For runtime, besides using scratch for corresponding database, Hyperscan also allows user to use larger scratch space allocated for another database. When multiple concurrent threads need to use the same databases and a new scratch space is required, cloning the largest one is always safe. This is realized based on API hs_scratch_size() and hs_clone_scratch(). Behaviors beyond above are discouraged and results are undefined.
@jlucovsky Please refre to latest master. fix id: 0bf86a7 |
Thanks. I've verified proper operation on the Suricata LTS and current ( Thanks! |
@hongyang7 Will there be a new release with the update? Many of our users only used "released" software. Thus, could the change be in 5.4.2? |
@jlucovsky Please check for latest update. |
fix github issue intel#350
Roll back fix for github issue intel#350 About Scratch Usage: For compile time, scratch space is strongly recommended to be allocated immediately after database generation. For runtime, besides using scratch for corresponding database, Hyperscan also allows user to use larger scratch space allocated for another database. When multiple concurrent threads need to use the same databases and a new scratch space is required, cloning the largest one is always safe. This is realized based on API hs_scratch_size() and hs_clone_scratch(). Behaviors beyond above are discouraged and results are undefined.
Hello there,
I was experimenting with scratch buffer allocation and noticed that one specific pattern would cause a crash. The code I used is as follow, I have 2 similar patterns and only allocate the scratch buffer for
pattern1
but notpattern2
:Expected results: the second
hs_scan
should return an error, since the scratch buffer was not allocated properly for that patternActual results: the second
hs_scan
is SEGV, here is the stack trace:Note: there is no crash if I remove the
HS_FLAG_SOM_LEFTMOST
flag.Workaround: reallocating the scratch buffer with the second pattern solves the issue.
It sounds to me that some sanity checks are missing inside
hs_scan
.The text was updated successfully, but these errors were encountered: