Skip to content

sbus: defer notification callbacks#8202

Merged
alexey-tikhonov merged 3 commits into
SSSD:masterfrom
pbrezina:sbus-chain-fix
Dec 4, 2025
Merged

sbus: defer notification callbacks#8202
alexey-tikhonov merged 3 commits into
SSSD:masterfrom
pbrezina:sbus-chain-fix

Conversation

@pbrezina

Copy link
Copy Markdown
Member

Otherwise, it is possible to incorrectly chain nested requests since the
chain id is still present in the hash table.

Resolves: #8194

@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 aims to fix a race condition with nested requests by deferring sbus notification callbacks. The changes achieve this by adding the tevent context to the sbus_request_list structure and using tevent_req_defer_callback when a request is finished. The overall approach is correct and directly addresses the issue.

I have one suggestion to improve robustness by adding a NULL check to prevent a potential crash, which I've detailed in a specific comment.

Comment thread src/sbus/request/sbus_request_hash.c
@alexey-tikhonov

Copy link
Copy Markdown
Member

@pbrezina

Copy link
Copy Markdown
Member Author

The PR CI failures may be related, although I see some issues in the master branch first. I will restart it one more time and then investigate.

@pbrezina
pbrezina force-pushed the sbus-chain-fix branch 3 times, most recently from 34efd07 to ad9b35a Compare November 25, 2025 15:29
@pbrezina

Copy link
Copy Markdown
Member Author

The patch works now correctly, previously there was a race condition when cr_domains may not have been yet populated and it resulted in a random crash. It is ready for review, remaining failures are not related.

@alexey-tikhonov

Copy link
Copy Markdown
Member

/gemini review

@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 addresses an issue with nested request chaining in sbus by deferring notification callbacks. The core change in sbus_request_hash.c uses tevent_req_defer_callback to ensure that requests are fully processed and cleaned up before their callbacks are executed, which correctly resolves the potential for incorrect chaining. The necessary event context is now stored in sbus_request_list to support this. A new integration test has been added to test_identity.py which effectively validates the fix by checking for a hang that occurred in the problematic scenario. Additionally, there's a small optimization in cache_req.c to only use cache_first behavior when multiple domains are present. The changes are logical, well-implemented, and the new test provides good coverage for the fix. I have no further comments.

@alexey-tikhonov alexey-tikhonov added the coverity Trigger a coverity scan label Dec 1, 2025
@alexey-tikhonov

Copy link
Copy Markdown
Member

Note: Covscan is green.

Comment thread src/sbus/request/sbus_request_hash.c
Comment thread src/tests/system/mhc.yaml
@alexey-tikhonov

Copy link
Copy Markdown
Member

previously there was a race condition when cr_domains may not have been yet populated and it resulted in a random crash

Maybe unimportant, but looking at updates I don't understand where race was (or how it was fixed)...

@alexey-tikhonov alexey-tikhonov added backport-to-sssd-2-9-4 Corresponds to C8S and removed coverity Trigger a coverity scan labels Dec 1, 2025
@pbrezina

pbrezina commented Dec 2, 2025

Copy link
Copy Markdown
Member Author

previously there was a race condition when cr_domains may not have been yet populated and it resulted in a random crash

Maybe unimportant, but looking at updates I don't understand where race was (or how it was fixed)...

The original patch relayed on cr_domains, which is flatten list of domain names for search resolution order. If we use IPA provider, we do not read the option from configuration file but from the server. In this case, the cr_domains was not yet populated at this time, it was NULL. The fix was to rely on rctx->domain.

@thalman thalman 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

Otherwise, it is possible to incorrectly chain nested requests since the
chain id is still present in the hash table.

Resolves: SSSD#8194
Reviewed-by: Alexey Tikhonov <[email protected]>
Reviewed-by: Tomáš Halman <[email protected]>
Otherwise we will perform unnecessary data provider lookups.

Resolves: SSSD#8194
Reviewed-by: Alexey Tikhonov <[email protected]>
Reviewed-by: Tomáš Halman <[email protected]>
@sssd-bot

sssd-bot commented Dec 2, 2025

Copy link
Copy Markdown
Contributor

The pull request was accepted by @thalman with the following PR CI status:


🟢 CodeFactor (success)
🟢 CodeQL (success)
🟢 osh-diff-scan:fedora-rawhide-x86_64:upstream (success)
🟢 rpm-build:centos-stream-10-x86_64:upstream (success)
🟢 rpm-build:fedora-41-x86_64:upstream (success)
🟢 rpm-build:fedora-42-x86_64:upstream (success)
🟢 rpm-build:fedora-43-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-41) (failure)
🔴 ci / intgcheck (fedora-42) (failure)
🔴 ci / intgcheck (fedora-43) (failure)
🔴 ci / intgcheck (fedora-44) (failure)
🟢 ci / prepare (success)
🟢 ci / system (centos-10) (success)
🔴 ci / system (fedora-41) (failure)
🟢 ci / system (fedora-42) (success)
🟢 ci / system (fedora-43) (success)
🟢 ci / system (fedora-44) (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.

@alexey-tikhonov
alexey-tikhonov merged commit 00547f6 into SSSD:master Dec 4, 2025
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sss_nss: hang when looking up a group with stale cache entry and a LDAP provider

4 participants