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

multi-tenant: fix coverity warning #10395

Closed
wants to merge 1 commit into from

Conversation

victorjulien
Copy link
Member

Rework locking logic to avoid the following coverity warning.

** CID 1591966: Concurrent data access violations (MISSING_LOCK)
/src/detect-engine-loader.c: 475 in DetectLoadersSync()

474                     SCCtrlMutexLock(loader->tv->ctrl_mutex);
>>>     CID 1591966:  Concurrent data access violations  (MISSING_LOCK)
>>>     Accessing "loader->tv" without holding lock "DetectLoaderControl_.m". Elsewhere, "DetectLoaderControl_.tv" is written to with "DetectLoaderControl_.m" held 1 out of 1 times (1 of these accesses strongly imply that it is necessary).
475                     pthread_cond_broadcast(loader->tv->ctrl_cond);
476                     SCCtrlMutexUnlock(loader->tv->ctrl_mutex);

The warning is harmless.

Rework locking logic to avoid the following coverity warning.

** CID 1591966:  Concurrent data access violations  (MISSING_LOCK)
/src/detect-engine-loader.c: 475 in DetectLoadersSync()

    474                     SCCtrlMutexLock(loader->tv->ctrl_mutex);
    >>>     CID 1591966:  Concurrent data access violations  (MISSING_LOCK)
    >>>     Accessing "loader->tv" without holding lock "DetectLoaderControl_.m". Elsewhere, "DetectLoaderControl_.tv" is written to with "DetectLoaderControl_.m" held 1 out of 1 times (1 of these accesses strongly imply that it is necessary).
    475                     pthread_cond_broadcast(loader->tv->ctrl_cond);
    476                     SCCtrlMutexUnlock(loader->tv->ctrl_mutex);

The warning is harmless.
Copy link

codecov bot commented Feb 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (7956fa5) 82.52% compared to head (20c73f9) 82.52%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #10395   +/-   ##
=======================================
  Coverage   82.52%   82.52%           
=======================================
  Files         978      978           
  Lines      272158   272158           
=======================================
+ Hits       224591   224598    +7     
+ Misses      47567    47560    -7     
Flag Coverage Δ
fuzzcorpus 63.59% <0.00%> (-0.01%) ⬇️
suricata-verify 61.87% <100.00%> (+0.01%) ⬆️
unittests 62.83% <0.00%> (ø)

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

@victorjulien
Copy link
Member Author

Coverity confirmed to be happy.

@suricata-qa
Copy link

Information:

ERROR: QA failed on SURI_TLPW2_autofp_suri_time.

field baseline test %
SURI_TLPW2_autofp_stats_chk
.uptime 101 112 110.89%

Pipeline 18398

@@ -44,9 +44,9 @@ typedef struct DetectLoaderTask_ {
typedef struct DetectLoaderControl_ {
int id;
int result; /* 0 for ok, error otherwise */
ThreadVars *tv; /* loader threads threadvars - for waking them up */
SCMutex m;
SCMutex m; /**< mutex protectx result and task_list */
Copy link
Member

Choose a reason for hiding this comment

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

minor typo: protectx
Q: Why did you do this reordering of struct items? To have the cacheline boundary fall outside of task_list?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's not a perf critical struct, so I reordered things to have the mutex and the members it protects grouped together

Copy link
Member

Choose a reason for hiding this comment

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

ok. Thank you. This PR looks good to me. If you're fixing the typo in comment, I'll wait for the next PR to approve.

@victorjulien
Copy link
Member Author

replaced by #10412

@victorjulien victorjulien deleted the cov-issue/v1 branch March 8, 2024 13:35
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.

3 participants