Skip to content

KRB5: fix mem leak in authenticate_stored_users()#8517

Merged
justin-stephenson merged 2 commits intoSSSD:masterfrom
alexey-tikhonov:uid-table-leak
Mar 19, 2026
Merged

KRB5: fix mem leak in authenticate_stored_users()#8517
justin-stephenson merged 2 commits intoSSSD:masterfrom
alexey-tikhonov:uid-table-leak

Conversation

@alexey-tikhonov
Copy link
Member

No description provided.

Copy link

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

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 a memory leak in authenticate_stored_users by adding calls to hash_destroy for uid_table on all exit paths. My review focuses on ensuring the correctness of these additions. I've identified a couple of areas for improvement regarding error handling for the newly added cleanup calls.

@sumit-bose
Copy link
Contributor

Hi,

thank you for digging this issue up and fixing it. But it looks that currently get_uid_table() can return an allocated hash table even in case of an error. Which means there is a potential leak in the error checking for get_uid_table() in this function here and in init_delayed_online_authentication(). I guess it would be best to fix get_uid_table().

bye,
Sumit

@alexey-tikhonov
Copy link
Member Author

(rebase)

@alexey-tikhonov
Copy link
Member Author

But it looks that currently get_uid_table() can return an allocated hash table even in case of an error. Which means there is a potential leak in the error checking for get_uid_table() in this function here and in init_delayed_online_authentication(). I guess it would be best to fix get_uid_table().

Thanks, fixed.

@alexey-tikhonov alexey-tikhonov added coverity Trigger a coverity scan and removed Changes requested labels Mar 16, 2026
@sumit-bose
Copy link
Contributor

/gemini review

Copy link

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

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 a memory leak in authenticate_stored_users() by ensuring the uid_table hash table is properly deallocated. The changes in krb5_delayed_online_authentication.c add the necessary calls to hash_destroy() on all exit paths of the function. The modification in get_uid_table() in find_uid.c enhances error handling by cleaning up the hash table upon failure, which prevents memory leaks in its callers. The changes are correct and effectively resolve the identified memory leak.

Copy link
Contributor

@sumit-bose sumit-bose left a comment

Choose a reason for hiding this comment

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

Hi,

thank you for the update, ACK.

bye,
Sumit

@alexey-tikhonov
Copy link
Member Author

Note: Covscan is green.

@alexey-tikhonov alexey-tikhonov removed the coverity Trigger a coverity scan label Mar 16, 2026
@justin-stephenson justin-stephenson self-assigned this Mar 19, 2026
Reviewed-by: Justin Stephenson <jstephen@redhat.com>
Reviewed-by: Sumit Bose <sbose@redhat.com>
Reviewed-by: Justin Stephenson <jstephen@redhat.com>
Reviewed-by: Sumit Bose <sbose@redhat.com>
@sssd-bot
Copy link
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.

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.

4 participants