Skip to content

memberOf plugin: avoid ldb_dn_compare() in mbof_append_addop()#8546

Merged
alexey-tikhonov merged 1 commit into
SSSD:masterfrom
alexey-tikhonov:mbof_append_addop
Mar 27, 2026
Merged

memberOf plugin: avoid ldb_dn_compare() in mbof_append_addop()#8546
alexey-tikhonov merged 1 commit into
SSSD:masterfrom
alexey-tikhonov:mbof_append_addop

Conversation

@alexey-tikhonov

@alexey-tikhonov alexey-tikhonov commented Mar 24, 2026

Copy link
Copy Markdown
Member

Justification is the same as in 704c31d
In certain scenarios this function is a hot path and using heavy ldb_dn_compare() adds unnecessary overhead.

Testing with a following setup: 50 mid-level groups that all share the same 2500 leaf groups as members, plus one top-level group containing all mid-level groups. Each leaf group contains a single user. ignore_group_members = false.
time id user with a cold cache:

i.e. this patch makes mbof_append_addop() approx x2 faster (this gain doesn't depend on number of groups; but weight of mbof_append_addop() in total consumption depends on it)

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request refactors debug logging in several LDAP provider files by replacing direct DEBUG calls with DEBUG_CONDITIONAL for improved performance. It also updates the memberof LDB module to use linearized DNs for comparison, changing the comparison logic from ldb_dn_compare to sss_linearized_dn_match. Feedback indicates a potential issue in memberof.c where returning LDB_SUCCESS when ldb_dn_get_linearized fails might mask critical errors, and also notes an unaddressed FIXME comment that requires clarification regarding parent comparisons with the new DN matching logic.

I am having trouble creating individual review comments. Click here to see my feedback.

src/ldb_modules/memberof.c (349-351)

critical

Returning LDB_SUCCESS when ldb_dn_get_linearized fails might mask a critical issue. If the entry_dn is invalid or cannot be linearized, it could indicate a problem that should be handled as an error rather than silently succeeding. This could lead to add operations being incorrectly ignored, causing data inconsistency or unexpected behavior.

    if (entry_dn_linearized == NULL) {
        /* Log an error here to indicate that linearization failed */
        return LDB_ERR_INVALID_DN; /* Or another appropriate error code */
    }

src/ldb_modules/memberof.c (363)

high

The FIXME comment "check if this is right, might have to compare parents" remains unaddressed. Given the change from ldb_dn_compare to sss_linearized_dn_match, it's crucial to clarify if this FIXME is still relevant. If sss_linearized_dn_match sufficiently handles the comparison, the FIXME should be removed. If not, this change might introduce a subtle correctness issue regarding parent comparisons that needs to be resolved.

@alexey-tikhonov
alexey-tikhonov marked this pull request as ready for review March 25, 2026 12:35
@aplopez aplopez self-assigned this Mar 25, 2026
@aplopez
aplopez self-requested a review March 25, 2026 12:40
@alexey-tikhonov alexey-tikhonov added coverity Trigger a coverity scan and removed coverity Trigger a coverity scan labels Mar 25, 2026
@alexey-tikhonov

Copy link
Copy Markdown
Member Author

Note: Covscan is green.

@alexey-tikhonov alexey-tikhonov removed the coverity Trigger a coverity scan label Mar 25, 2026
Comment thread src/ldb_modules/memberof.c

@aplopez aplopez left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ACK

Justification is the same as in 704c31d
In certain scenarios this function is a hot path and using heavy
`ldb_dn_compare()` adds unnecessary overhead.

Reviewed-by: Alejandro López <[email protected]>
Reviewed-by: Justin Stephenson <[email protected]>
@sssd-bot

Copy link
Copy Markdown
Contributor

The pull request was accepted by @justin-stephenson with the following PR CI status:


🟢 CodeQL (success)
🟢 osh-diff-scan:fedora-rawhide-x86_64:upstream (success)
🟢 rpm-build:centos-stream-10-x86_64:upstream (success)
🟢 rpm-build:fedora-42-x86_64:upstream (success)
🟢 rpm-build:fedora-43-x86_64:upstream (success)
🟢 rpm-build:fedora-44-x86_64:upstream (success)
🟢 rpm-build:fedora-rawhide-x86_64:upstream (success)
🟢 Analyze (target) / cppcheck (success)
🟢 Build / freebsd (success)
🟢 Build / make-distcheck (success)
🟢 ci / intgcheck (centos-10) (success)
🟢 ci / intgcheck (fedora-42) (success)
🟢 ci / intgcheck (fedora-43) (success)
🟢 ci / intgcheck (fedora-44) (success)
🟢 ci / intgcheck (fedora-45) (success)
🟢 ci / prepare (success)
🟢 ci / system (centos-10) (success)
🟢 ci / system (fedora-42) (success)
🟢 ci / system (fedora-43) (success)
🟢 ci / system (fedora-44) (success)
🟢 ci / system (fedora-45) (success)
➖ Coverity scan / coverity (skipped)
🟢 Static code analysis / codeql (success)
🟢 Static code analysis / pre-commit (success)
🟢 Static code analysis / python-system-tests (success)


There are unsuccessful or unfinished checks. Make sure that the failures are not related to this pull request before merging.

@sssd-bot
sssd-bot force-pushed the mbof_append_addop branch from b71221b to 2a6192b Compare March 27, 2026 19:14
@alexey-tikhonov
alexey-tikhonov merged commit 2dcdca2 into SSSD:master Mar 27, 2026
16 of 17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants