summaryrefslogtreecommitdiff
path: root/drivers/net/wireguard/allowedips.c
diff options
context:
space:
mode:
authorJakub Kicinski <kuba@kernel.org>2022-08-02 13:47:52 -0700
committerJakub Kicinski <kuba@kernel.org>2022-08-02 13:47:53 -0700
commitd768c9e3b0d82853e761dce6eed6f574060ba366 (patch)
tree2418f8bf1a5b797b4bd6a7269d524f0f208ea8e6 /drivers/net/wireguard/allowedips.c
parentcf9bc1eb1841984634d25a66adc96cfb377675a2 (diff)
parentbd18bafaef337a437149edd5531e4d137cddc1a2 (diff)
downloadwireguard-linux-trimmed-d768c9e3b0d82853e761dce6eed6f574060ba366.tar.gz
wireguard-linux-trimmed-d768c9e3b0d82853e761dce6eed6f574060ba366.zip
Merge branch 'wireguard-patches-for-5-20-rc1'
Jason A. Donenfeld says: ==================== wireguard patches for 5.20-rc1 I had planned to send these out eventually as net.git patches, but as you emailed earlier, I figure there's no harm in just doing this now for net-next.git. Please apply the following small fixes: 1) Rather than using msleep() in order to approximate ktime_get_coarse_ boottime_ns(), instead use an hrtimer, rounded heuristically. 2) An update in selftest config fragments, from Lukas. 3) Linus noticed that a debugging WARN_ON() to detect (impossible) stack corruption would still allow the corruption to happen, making it harder to get the report about the corruption subsequently. 4) Support for User Mode Linux in the test suite. This depends on some UML patches that are slated for 5.20. Richard hasn't sent his pull in, but they're in his tree, so I assume it'll happen. ==================== Link: https://lore.kernel.org/r/20220802125613.340848-1-Jason@zx2c4.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'drivers/net/wireguard/allowedips.c')
-rw-r--r--drivers/net/wireguard/allowedips.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/drivers/net/wireguard/allowedips.c b/drivers/net/wireguard/allowedips.c
index 9a4c8ff..5bf7822 100644
--- a/drivers/net/wireguard/allowedips.c
+++ b/drivers/net/wireguard/allowedips.c
@@ -6,6 +6,8 @@
#include "allowedips.h"
#include "peer.h"
+enum { MAX_ALLOWEDIPS_BITS = 128 };
+
static struct kmem_cache *node_cache;
static void swap_endian(u8 *dst, const u8 *src, u8 bits)
@@ -40,7 +42,8 @@ static void push_rcu(struct allowedips_node **stack,
struct allowedips_node __rcu *p, unsigned int *len)
{
if (rcu_access_pointer(p)) {
- WARN_ON(IS_ENABLED(DEBUG) && *len >= 128);
+ if (WARN_ON(IS_ENABLED(DEBUG) && *len >= MAX_ALLOWEDIPS_BITS))
+ return;
stack[(*len)++] = rcu_dereference_raw(p);
}
}
@@ -52,7 +55,7 @@ static void node_free_rcu(struct rcu_head *rcu)
static void root_free_rcu(struct rcu_head *rcu)
{
- struct allowedips_node *node, *stack[128] = {
+ struct allowedips_node *node, *stack[MAX_ALLOWEDIPS_BITS] = {
container_of(rcu, struct allowedips_node, rcu) };
unsigned int len = 1;
@@ -65,7 +68,7 @@ static void root_free_rcu(struct rcu_head *rcu)
static void root_remove_peer_lists(struct allowedips_node *root)
{
- struct allowedips_node *node, *stack[128] = { root };
+ struct allowedips_node *node, *stack[MAX_ALLOWEDIPS_BITS] = { root };
unsigned int len = 1;
while (len > 0 && (node = stack[--len])) {