Skip to content

sdap_select_principal_from_keytab_sync: waitpid() synchronously#8473

Merged
alexey-tikhonov merged 1 commit into
SSSD:masterfrom
arrowd:ldap-child-wnohang
Feb 26, 2026
Merged

sdap_select_principal_from_keytab_sync: waitpid() synchronously#8473
alexey-tikhonov merged 1 commit into
SSSD:masterfrom
arrowd:ldap-child-wnohang

Conversation

@arrowd

@arrowd arrowd commented Feb 21, 2026

Copy link
Copy Markdown
Contributor

Without this change the ldap_child process started by this function ends up in the <defunct> state. kernel trace hints that the process isn't fully finished by the time waitpid is called:

 13126 sssd_be  CALL  wait4(13127,0,0x1<WNOHANG>,0)
 13126 sssd_be  RET   wait4 0
waitpid(ldap_child) failed, process might be leaking

According to man waitpid(2), the function returns 0 when passed WNOHANG and there is no child process that can be reported as exited. Omitting WNOHANG fixes the issue.

@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 correctly fixes an issue where a child process could become a zombie by making the waitpid() call blocking. This ensures the parent process waits for the child to terminate. I've added a suggestion to make this call more robust by handling potential interruptions from signals (EINTR), which is a good practice for system calls like waitpid().

Comment thread src/providers/ldap/sdap_child_helpers.c
@alexey-tikhonov alexey-tikhonov self-assigned this Feb 23, 2026
@alexey-tikhonov
alexey-tikhonov self-requested a review February 23, 2026 08:51
@arrowd
arrowd force-pushed the ldap-child-wnohang branch from 0bda4c3 to 7c5d23a Compare February 23, 2026 15:34
@alexey-tikhonov alexey-tikhonov added no-backport This should go to target branch only. Waiting for review labels Feb 24, 2026
@arrowd
arrowd force-pushed the ldap-child-wnohang branch from 7c5d23a to 8f6c77a Compare February 24, 2026 18:24

@ikerexxe ikerexxe 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.

Just a minor change and we'll be done

Comment thread src/providers/ldap/sdap_child_helpers.c Outdated
@arrowd
arrowd force-pushed the ldap-child-wnohang branch from 8f6c77a to 8e76d1d Compare February 25, 2026 10:46

@ikerexxe ikerexxe 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.

LGTM!

@alexey-tikhonov alexey-tikhonov added coverity Trigger a coverity scan and removed Waiting for review coverity Trigger a coverity scan labels Feb 25, 2026
@alexey-tikhonov

Copy link
Copy Markdown
Member

Note: Covscan is green.

@alexey-tikhonov alexey-tikhonov added Accepted and removed coverity Trigger a coverity scan labels Feb 25, 2026
Without this change the ldap_child process started by this function ends up
in the <defunct> state. kernel trace hints that the process isn't fully
finished by the time waitpid is called:

 13126 sssd_be  CALL  wait4(13127,0,0x1<WNOHANG>,0)
 13126 sssd_be  RET   wait4 0
waitpid(ldap_child) failed, process might be leaking

According to man waitpid(3), the function returns 0 when passed WNOHANG and
there is no child process that can be reported as exited. Omitting WNOHANG
fixes the issue.

Reviewed-by: Alexey Tikhonov <[email protected]>
Reviewed-by: Iker Pedrosa <[email protected]>
@sssd-bot

Copy link
Copy Markdown
Contributor

The pull request was accepted by @alexey-tikhonov 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.

@alexey-tikhonov
alexey-tikhonov merged commit 404d166 into SSSD:master Feb 26, 2026
2 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Accepted no-backport This should go to target branch only.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants