Skip to content

Unlink the RPC from waiting_for_bufs in homa_rpc_alloc_server errors - #135

Open
Stuartwastaken wants to merge 1 commit into
PlatformLab:mainfrom
Stuartwastaken:fix/alloc-server-unlink
Open

Stuartwastaken wants to merge 1 commit into
PlatformLab:mainfrom
Stuartwastaken:fix/alloc-server-unlink

Conversation

@Stuartwastaken

Copy link
Copy Markdown
Contributor

When the receive pool is full, homa_pool_alloc_msg puts a new server RPC on waiting_for_bufs and returns 0. If homa_rpc_alloc_server then finds the socket shut down, its error path calls homa_pool_release, which doesn't touch buf_links, and kfrees the RPC while it is still on the list. Later list operations on waiting_for_bufs read and write the freed RPC: homa_pool_check_waiting when buffers free up during reaping, and homa_pool_unlink on its neighbours at shutdown. It needs a full pool plus a close() racing with an arriving request, which a restart of a busy server can hit.

This calls homa_pool_unlink on the error path; the bucket lock is held there, and since 5fbfc52 homa_pool_unlink takes the pool lock and returns early if the RPC isn't queued. The new homa_rpc_alloc_server__socket_shutdown_while_waiting_for_bufs test fills the pool and shuts the socket down: without the fix AddressSanitizer reports a heap-use-after-free on the freed RPC (freed at homa_rpc.c:221), and with it all 885 unit tests and the smoke tests pass.

* When the pool is full, homa_pool_alloc_msg queues the new RPC on
  waiting_for_bufs and returns 0. If the socket is then found to be
  shut down, the error path freed the RPC while it was still on the
  list.
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.

1 participant