Skip to content

potential deadlock in wireguard-go sending lots of traffic to several peers without handshakes #1971

Closed

Description

@josharian

(sketch, I’m on my phone)

On mobile platforms, wireguard-go limits the number of buffers that can be outstanding at any time. It also has a per-peer limit on the number of staged packets (packets awaiting a handshake). But with enough peers connected, the staged packets outstanding could consume the entire buffer pool. If that happened, receiving new packets would block, because no buffers were available. If receiving packets fails, then handshakes cannot complete. (Similarly so for sending new packets in this state.)

This would cause at least a temporary deadlock. Eventually the handshake timer would fire enough times to exceed the handshake retry limit and would then clear the staged packets.

In android that would require 32 peers. On iOS with upstream values, 8 peers. On iOS with our restricted values, 1 peer(!).

At this point, this is a theoretical concern that occurred to me lying in bed. Next step is to verify with the code, think about how to reproduce, and consider mitigations (such as device-wide handshake queue dropping when the buffer pool gets low, or a separate buffer pool dedicated to handshake buffers).

Activity

  1. added
    L4 Most users
    OS-android
    OS-ios
    P2 Aggravating
    and removed on May 22, 2021
  2. DentonGentry commented on Feb 12, 2023

    @DentonGentry
    Contributor

    A few relevant developments since this bug was filed:

    As we're approaching two years since this issue was filed with (to my knowledge) no indication that the problem has actually materialized, we'll expect to close this during the next regular bug scrub.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    L4 Most usersOS-androidOS-iosP2 AggravatingT3 Performance/Debugging

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions