Skip to content

lib/fuse_lowlevel.c: fix uninitialized eventfd in teardown watchdog#7

Open
agabhin wants to merge 1 commit into
masterfrom
fix-teardown-watchdog-eventfd
Open

lib/fuse_lowlevel.c: fix uninitialized eventfd in teardown watchdog#7
agabhin wants to merge 1 commit into
masterfrom
fix-teardown-watchdog-eventfd

Conversation

@agabhin

@agabhin agabhin commented Apr 7, 2026

Copy link
Copy Markdown
Owner

Summary

Fix uninitialized eventfd in teardown watchdog error path.

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 is garbage — fuse_tt_destruct() will close() 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 = -1 after malloc.

Found by Facebook Infer (PULSE_UNINITIALIZED_VALUE).

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>
@agabhin agabhin force-pushed the fix-teardown-watchdog-eventfd branch from 498220d to e3ea1a4 Compare April 7, 2026 23:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants