vfs: re-register epoll waiter after restore to fix missed notifications - #13953
Open
pawannn wants to merge 1 commit into
Open
vfs: re-register epoll waiter after restore to fix missed notifications#13953pawannn wants to merge 1 commit into
pawannn wants to merge 1 commit into
Conversation
…fications after restore (google#13920)
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.
Fixes #13920.
Problem
After checkpoint/restore, an epoll instance that was registered before the checkpoint may stop receiving events.
For example, on a restored TCP listening socket:
poll(2)reports the socket as readable.Impact
Applications that rely on epoll (such as those using Tokio or mio) can stop accepting new connections after restore. Connections continue to arrive, but
epoll_wait()never wakes up, soaccept(2)is never called.Root cause
An epoll interest registers a waiter with the file's
waiter.Queueso it can receive readiness notifications.After restore, that waiter is no longer registered with the queue. As a result, future notifications never reach the restored epoll interest, even though the file itself becomes ready.
What this change does
This change updates
epollInterest.afterLoadto re-register the waiter with the file'swaiter.Queueduring restore.This restores event delivery while preserving the existing behavior, including skipping deleted interests (
mask == 0).Tests
Added
pkg/sentry/vfs/epoll_test.gowith three tests:TestEpollInterestAfterLoadReRegistersWaiterverifies that notifications are delivered again after restore. It fails without this change and passes with it.TestEpollInterestAfterLoadPreservesReadyStateverifies that the existing "mark ready after load" behavior is preserved.TestEpollInterestAfterLoadSkipsDeletedverifies that deleted interests are still skipped.Verification
//pkg/sentry/vfs:vfs_test PASSEDTestEpollInterestAfterLoadReRegistersWaiter FAIL: got 0 events, want 1//pkg/sentry/vfs:vfs_test PASSEDResult
After restore, epoll continues receiving readiness notifications as expected, allowing applications to resume accepting new connections normally.