lib/fuse_lowlevel.c: fix uninitialized eventfd in teardown watchdog#7
Open
agabhin wants to merge 1 commit into
Open
lib/fuse_lowlevel.c: fix uninitialized eventfd in teardown watchdog#7agabhin wants to merge 1 commit into
agabhin wants to merge 1 commit into
Conversation
If fuse_session_start_teardown_watchdog() is called twice on the same session, the "timeout thread already running" guard fires goto err before tt->eventfd is assigned. Since tt came from malloc, eventfd contains garbage. fuse_tt_destruct() checks tt->eventfd != -1 before close(), but a garbage value will almost certainly pass this check, causing close() on a random file descriptor. Only triggers on double-call (a caller bug), but the defensive guard should clean up correctly rather than corrupt state. Initialize tt->eventfd = -1 immediately after malloc so the destruct path is always safe. Found by Facebook Infer (PULSE_UNINITIALIZED_VALUE). Signed-off-by: Abhinav Agarwal <abhinavagarwal1996@gmail.com>
498220d to
e3ea1a4
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix uninitialized
eventfdin teardown watchdog error path.If
fuse_session_start_teardown_watchdog()is called twice on the same session, the "timeout thread already running" guard firesgoto errbeforett->eventfdis assigned. Sincettcame frommalloc,eventfdis garbage —fuse_tt_destruct()willclose()a random fd.This only triggers on double-call (a caller bug), but the defensive guard should clean up correctly rather than corrupt state. Fix: initialize
tt->eventfd = -1after malloc.Found by Facebook Infer (PULSE_UNINITIALIZED_VALUE).