wireguard: receive: drop handshakes if queue lock is contended
authorJason A. Donenfeld <Jason@zx2c4.com>
Mon, 29 Nov 2021 15:39:27 +0000 (10:39 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 8 Dec 2021 08:04:46 +0000 (09:04 +0100)
commit2745192cb798be774c2f3085644434f2a6387372
tree7374cb48baab3a1d0367897508ff6cb86460b99b
parentaf794a64d6cad9fbf8f65df3722e80c55b6ec198
wireguard: receive: drop handshakes if queue lock is contended

commit fb32f4f606c17b869805d7cede8b03d78339b50a upstream.

If we're being delivered packets from multiple CPUs so quickly that the
ring lock is contended for CPU tries, then it's safe to assume that the
queue is near capacity anyway, so just drop the packet rather than
spinning. This helps deal with multicore DoS that can interfere with
data path performance. It _still_ does not completely fix the issue, but
it again chips away at it.

Reported-by: Streun Fabio <fstreun@student.ethz.ch>
Fixes: e7096c131e51 ("net: WireGuard secure network tunnel")
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/wireguard/receive.c