blob: ce4e5dcf500ca06bb07dae4bf601fec059dfa4e5 [file] [log] [blame]
b.liue9582032025-04-17 19:18:16 +08001From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2From: "Jason A. Donenfeld" <Jason@zx2c4.com>
3Date: Fri, 4 Jun 2021 17:17:35 +0200
4Subject: [PATCH] wireguard: allowedips: initialize list head in selftest
5
6commit 46cfe8eee285cde465b420637507884551f5d7ca upstream.
7
8The randomized trie tests weren't initializing the dummy peer list head,
9resulting in a NULL pointer dereference when used. Fix this by
10initializing it in the randomized trie test, just like we do for the
11static unit test.
12
13While we're at it, all of the other strings like this have the word
14"self-test", so add it to the missing place here.
15
16Fixes: e7096c131e51 ("net: WireGuard secure network tunnel")
17Cc: stable@vger.kernel.org
18Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
19Signed-off-by: David S. Miller <davem@davemloft.net>
20Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
21---
22 drivers/net/wireguard/selftest/allowedips.c | 3 ++-
23 1 file changed, 2 insertions(+), 1 deletion(-)
24
25--- a/drivers/net/wireguard/selftest/allowedips.c
26+++ b/drivers/net/wireguard/selftest/allowedips.c
27@@ -296,6 +296,7 @@ static __init bool randomized_test(void)
28 goto free;
29 }
30 kref_init(&peers[i]->refcount);
31+ INIT_LIST_HEAD(&peers[i]->allowedips_list);
32 }
33
34 mutex_lock(&mutex);
35@@ -333,7 +334,7 @@ static __init bool randomized_test(void)
36 if (wg_allowedips_insert_v4(&t,
37 (struct in_addr *)mutated,
38 cidr, peer, &mutex) < 0) {
39- pr_err("allowedips random malloc: FAIL\n");
40+ pr_err("allowedips random self-test malloc: FAIL\n");
41 goto free_locked;
42 }
43 if (horrible_allowedips_insert_v4(&h,