From: Andrii Pasichnyk <apasichnik9@gmail.com>
To: "Jason A . Donenfeld" <Jason@zx2c4.com>
Cc: wireguard@lists.zx2c4.com, netdev@vger.kernel.org,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Shuah Khan <shuah@kernel.org>,
linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH net v3 0/2] wireguard: free receive queue packets on peer removal, and test it
Date: Fri, 27 Nov 2026 12:22:41 +0200 [thread overview]
Message-ID: <20261127102243.49405-1-apasichnik9@gmail.com> (raw)
Removing a peer while its receive queue is busy can leave packets on
the per-peer receive queue. Each of them holds a keypair and a peer
reference, so the peer and the keypair are never freed. Patch 1 frees
what is left; patch 2 adds the test Jason asked for in the v1 thread to
netns.sh.
Tested on net e9e45fcb6 with the WireGuard selftest VM (x86_64 KVM):
both patches, 4 vCPUs: pass
both patches, NR_CPUS=1: pass
both patches, NR_CPUS=1, 200 removals: pass, nothing leaked
patch 2 only, NR_CPUS=1: fail, a peer and a keypair
"merely created"
Changes in v3:
- Patch 1: purge rx_queue only. The tx_queue purge in v2 could run
beside a transmit_packet_work that was queued during the second
flush, as the Sashiko review pointed out, and it was not needed: the
leak is on rx_queue. The older comment in peer_remove_after_dead() is
updated, the subject follows, and the commit message says how the bug
was found.
- Patch 2: CONFIG_LOG_BUF_SHIFT is 21 instead of 20, which covers the
worst case of the loop; the commit message says that NR_CPUS=1 is the
configuration that checks for the leak.
- Rebased on current net.
v2: https://lore.kernel.org/netdev/20261126094722.73025-1-apasichnik9@gmail.com/
v1: https://lore.kernel.org/netdev/20261003201625.4572-1-apasichnik9@gmail.com/
Andrii Pasichnyk (2):
wireguard: peer: free packets left on the receive queue on removal
wireguard: selftests: remove a peer under load
drivers/net/wireguard/peer.c | 25 +++++++++++++++++--
tools/testing/selftests/wireguard/netns.sh | 14 +++++++++++
.../selftests/wireguard/qemu/kernel.config | 2 +-
3 files changed, 38 insertions(+), 3 deletions(-)
base-commit: e9e45fcb6d39bee9325e6a7dca72bd14e82760f3
--
2.43.0
next reply other threads:[~2026-11-27 10:22 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-27 10:22 Andrii Pasichnyk [this message]
2026-11-27 10:22 ` [PATCH net v3 1/2] wireguard: peer: free packets left on the receive queue on removal Andrii Pasichnyk
2026-11-28 10:25 ` netdev-bot+sashiko
2026-11-27 10:22 ` [PATCH net v3 2/2] wireguard: selftests: remove a peer under load Andrii Pasichnyk
2026-11-28 10:25 ` netdev-bot+sashiko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261127102243.49405-1-apasichnik9@gmail.com \
--to=apasichnik9@gmail.com \
--cc=Jason@zx2c4.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=shuah@kernel.org \
--cc=wireguard@lists.zx2c4.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.