aboutsummaryrefslogtreecommitdiffstats
path: root/driver
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2023-12-11 15:51:04 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2023-12-11 15:08:55 +0000
commitcbf27645083b25caf9dd0c4d6b07163a10c3841d (patch)
treeb3d2dbb04e047e332435a8c4b3ee06819dd0b058 /driver
parentapi: header: add C++ enum manipulation operators (diff)
downloadwireguard-nt-master.tar.xz
wireguard-nt-master.zip
driver: allowedips: expand maximum node depthHEADmaster
In the allowedips self-test, nodes are inserted into the tree, but it generated an even amount of nodes, but for checking maximum node depth, there is of course the root node, which makes the total number necessarily odd. With two few nodes added, it never triggered the maximum depth check like it should have. So, add 129 nodes instead of 128 nodes, and do so with a more straightforward scheme, starting with all the bits set, and shifting over one each time. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'driver')
-rw-r--r--driver/allowedips.c2
-rw-r--r--driver/selftest/allowedips.c24
2 files changed, 14 insertions, 12 deletions
diff --git a/driver/allowedips.c b/driver/allowedips.c
index a8928ce..6e96577 100644
--- a/driver/allowedips.c
+++ b/driver/allowedips.c
@@ -8,7 +8,7 @@
#include "peer.h"
#include "logging.h"
-#define STACK_ENTRIES 128
+#define STACK_ENTRIES 129
static LOOKASIDE_ALIGN LOOKASIDE_LIST_EX NodeCache;
diff --git a/driver/selftest/allowedips.c b/driver/selftest/allowedips.c
index a6b57ef..5a9c77a 100644
--- a/driver/selftest/allowedips.c
+++ b/driver/selftest/allowedips.c
@@ -101,6 +101,7 @@ AllowedIpsSelftest(VOID)
EX_PUSH_LOCK Mutex;
SIZE_T i = 0, Count = 0;
UINT64_BE Part;
+ __declspec(align(8)) UINT8 Ip[16];
MuInitializePushLock(&Mutex);
MuAcquirePushLockExclusive(&Mutex);
@@ -190,19 +191,21 @@ AllowedIpsSelftest(VOID)
AllowedIpsRemoveByPeer(&t, A, &Mutex);
TestNegative(4, A, 192, 168, 0, 1);
- /* These will hit the NT_ASSERT(len < 128) in free_node if something
- * goes wrong.
+ /* These will hit the NT_ASSERT(len < STACK_ENTRIES) in RootFreeRcu if
+ * something goes wrong.
*/
- for (i = 0; i < 128; ++i)
+ for (i = 0; i < 64; ++i)
{
- IN6_ADDR Ip;
-
- Part = CpuToBe64(~(1LLU << (i % 64)));
- RtlFillMemory(&Ip, 16, 0xff);
- RtlCopyMemory((UINT8 *)&Ip + (SIZE_T)(i < 64) * 8, &Part, 8);
- AllowedIpsInsertV6(&t, &Ip, 128, A, &Mutex);
+ Part = CpuToBe64(~0LLU << i);
+ RtlFillMemory(Ip, 8, 0xff);
+ RtlCopyMemory(Ip + 8, &Part, 8);
+ AllowedIpsInsertV6(&t, (IN6_ADDR *)Ip, 128, A, &Mutex);
+ RtlCopyMemory(Ip, &Part, 8);
+ RtlFillMemory(Ip + 8, 8, 0);
+ AllowedIpsInsertV6(&t, (IN6_ADDR *)Ip, 128, A, &Mutex);
}
-
+ RtlFillMemory(Ip, 16, 0);
+ AllowedIpsInsertV6(&t, (IN6_ADDR *)Ip, 128, A, &Mutex);
AllowedIpsFree(&t, &Mutex);
AllowedIpsInit(&t);
@@ -214,7 +217,6 @@ AllowedIpsSelftest(VOID)
LIST_FOR_EACH_ENTRY (IterNode, &A->AllowedIpsList, ALLOWEDIPS_NODE, PeerList)
{
UINT8 Cidr;
- __declspec(align(8)) UINT8 Ip[16];
ADDRESS_FAMILY Family = AllowedIpsReadNode(IterNode, Ip, &Cidr);
++Count;