42
6
Fork
You've already forked steve
1

Fix token leak if client performs non-blocking poll #5

Manually merged
mgorny merged 1 commit from flow/steve:fix-token-leak into main 2026年05月23日 08:20:35 +02:00
Member
Copy link

If a client performs a non-blocking poll while no tokens were
available, FUSE/CUSE passes a nullptr as the pollhandle argument
to steve_poll(). Steve would previously push this nullptr into the
waiters queue.

Later, when a token became available, the server would wake this
"ghost" waiter, permanently reserving a token for a client that was
not actually waiting for it. This effectively leaks the token until
the client process exited.

Fix this by only queuing a waiter request if the pollhandle is
non-null (representing an actual sleeping client).

Signed-off-by: Florian Schmaus flow@gentoo.org

If a client performs a non-blocking poll while no tokens were available, FUSE/CUSE passes a nullptr as the pollhandle argument to steve_poll(). Steve would previously push this nullptr into the waiters queue. Later, when a token became available, the server would wake this "ghost" waiter, permanently reserving a token for a client that was not actually waiting for it. This effectively leaks the token until the client process exited. Fix this by only queuing a waiter request if the pollhandle is non-null (representing an actual sleeping client). Signed-off-by: Florian Schmaus <flow@gentoo.org>
If a client performs a non-blocking poll while no tokens were
available, FUSE/CUSE passes a nullptr as the pollhandle argument
to steve_poll(). Steve would previously push this nullptr into the
waiters queue.
Later, when a token became available, the server would wake this
"ghost" waiter, permanently reserving a token for a client that was
not actually waiting for it. This effectively leaks the token until
the client process exited.
Fix this by only queuing a waiter request if the pollhandle is
non-null (representing an actual sleeping client).
Signed-off-by: Florian Schmaus <flow@gentoo.org>

Out of interest, do you have an example client?

Out of interest, do you have an example client?
Author
Member
Copy link

@thesamesam wrote in #5 (comment):

Out of interest, do you have an example client?

No. The possibility for this came up while working on #2

I am not sure why a client should poll with a zero timeout nor if there a clients that actually do so. So, we might not see such clients, but it can't hurt for Steve to be prepared for this case.

@thesamesam wrote in https://codeberg.org/gentoo/steve/pulls/5#issuecomment-15684110: > Out of interest, do you have an example client? No. The possibility for this came up while working on https://codeberg.org/gentoo/steve/pulls/2 I am not sure why a client should poll with a zero timeout nor if there a clients that actually do so. So, we might not see such clients, but it can't hurt for Steve to be prepared for this case.
mgorny left a comment
Copy link

Thanks!

Thanks!
mgorny manually merged commit 7d3d2e3937 into main 2026年05月23日 08:20:35 +02:00
Author
Member
Copy link

I am not sure why a client should poll with a zero timeout

Just to add: event loop reactor designs where timeout it dynamically calculated may end up with timeout being zero (intentionally or unintentionally). But I did not (yet) look at the code of the typical candidates if such a case exists.

> I am not sure why a client should poll with a zero timeout Just to add: event loop reactor designs where timeout it dynamically calculated may end up with timeout being zero (intentionally or unintentionally). But I did not (yet) look at the code of the typical candidates if such a case exists.
flow deleted branch fix-token-leak 2026年05月23日 08:34:45 +02:00
Sign in to join this conversation.
No reviewers
Labels
Clear labels
No items
No labels
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
gentoo/steve!5
Reference in a new issue
gentoo/steve
No description provided.
Delete branch "flow/steve:fix-token-leak"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?