-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
msr_global_mutex_lock: handle errors from apr_global_mutex_lock #3257
base: v2/master
Are you sure you want to change the base?
msr_global_mutex_lock: handle errors from apr_global_mutex_lock #3257
Conversation
Quality Gate failedFailed conditions See analysis details on SonarCloud Catch issues before they fail your Quality Gate with our IDE extension SonarLint |
#3255 acknowledged to be solved by the PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
} | ||
|
||
int rc = apr_global_mutex_unlock(msr->modsecurity->auditlog_lock); | ||
// We should have get the warning at lock time, so ignore it here |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// We should have get the warning at lock time, so ignore it here | |
// We should have been warnend during lock acquisition already, so don't log the same warning here |
|
||
int rc = apr_global_mutex_unlock(msr->modsecurity->auditlog_lock); | ||
// We should have get the warning at lock time, so ignore it here | ||
// if (rc != APR_SUCCESS) msr_log(msr, 1, "Audit log: Failed to unlock global mutex: %s", get_apr_error(msr->mp, rc)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// if (rc != APR_SUCCESS) msr_log(msr, 1, "Audit log: Failed to unlock global mutex: %s", get_apr_error(msr->mp, rc)); |
assert(msr->modsecurity); // lock is msr->modsecurity->..._lock | ||
assert(msr->mp); | ||
if (!lock) { | ||
msr_log(msr, 1, "%s: Global mutex was not created", fct); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
msr_log(msr, 1, "%s: Global mutex was not created", fct); | |
msr_log(msr, 1, "%s: Global mutex not initialised", fct); |
assert(msr->modsecurity); // lock is msr->modsecurity->..._lock | ||
assert(msr->mp); | ||
if (!lock) { | ||
msr_log(msr, 1, "%s: Global mutex was not created", fct); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
msr_log(msr, 1, "%s: Global mutex was not created", fct); | |
msr_log(msr, 1, "%s: Global mutex not initialised", fct); |
Before we merge, I want to check why the lock acquire was failed (see #3255 - the user reported that this issue came with the new version where we introduced this method). |
apr_global_mutex_lock
is sometimes called with a lock that wasn't created (for any reason).In this case, the pointer is null and
apr_global_mutex_lock
dereferences a null pointer, leading to a crash.This PR creates a wrapper around
apr_global_mutex_lock
to handle checking that and correct logging.Same for
msr_global_mutex_unlock
.