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

Datasets locking/v1 #12182

Closed
wants to merge 2 commits into from
Closed

Commits on Nov 29, 2024

  1. datasets: remove futile locking constructs

    In a recent warning reported by scan-build, datasets were found to be
    using a blocking call in a critical section.
    
    datasets.c:187:12: warning: Call to blocking function 'fgets' inside of critical section [unix.BlockInCriticalSection]
      187 |     while (fgets(line, (int)sizeof(line), fp) != NULL) {
          |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    datasets.c:292:12: warning: Call to blocking function 'fgets' inside of critical section [unix.BlockInCriticalSection]
      292 |     while (fgets(line, (int)sizeof(line), fp) != NULL) {
          |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    datasets.c:368:12: warning: Call to blocking function 'fgets' inside of critical section [unix.BlockInCriticalSection]
      368 |     while (fgets(line, (int)sizeof(line), fp) != NULL) {
          |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    datasets.c:442:12: warning: Call to blocking function 'fgets' inside of critical section [unix.BlockInCriticalSection]
      442 |     while (fgets(line, (int)sizeof(line), fp) != NULL) {
          |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    datasets.c:512:12: warning: Call to blocking function 'fgets' inside of critical section [unix.BlockInCriticalSection]
      512 |     while (fgets(line, (int)sizeof(line), fp) != NULL) {
          |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    5 warnings generated.
    
    Upon an analysis of the code, it was established that the call to all
    the affected parts of the code is made by the fn DatasetGet which seems
    to be only used by DetectDatasetSetup. A call to these Setup fns are
    made by the rule loaders at the initialization of the detection engine
    for a setup of expected keywords. Since this happens even before the
    engine is started and there is just one thread active at the time, these
    calls can be exempted from being marked critical section.
    
    Dataset data is saved, accessed, looked up from the common THash API
    when the actual traffic is matched against them.
    
    Bug 7398
    inashivb committed Nov 29, 2024
    Configuration menu
    Copy the full SHA
    aa5f9a3 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    25d4ecb View commit details
    Browse the repository at this point in the history