mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH net v3 0/2] wireguard: free receive queue packets on peer removal, and test it
@ 2026-11-27 10:22 Andrii Pasichnyk
  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-27 10:22 ` [PATCH net v3 2/2] wireguard: selftests: remove a peer under load Andrii Pasichnyk
  0 siblings, 2 replies; 3+ messages in thread
From: Andrii Pasichnyk @ 2026-11-27 10:22 UTC (permalink / raw)
  To: Jason A . Donenfeld
  Cc: wireguard, netdev, Andrew Lunn, David S . Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Shuah Khan, linux-kselftest,
	linux-kernel

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-27 10:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-27 10:22 [PATCH net v3 0/2] wireguard: free receive queue packets on peer removal, and test it Andrii Pasichnyk
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-27 10:22 ` [PATCH net v3 2/2] wireguard: selftests: remove a peer under load Andrii Pasichnyk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®