aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/selftest
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2018-09-22 19:45:57 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2018-09-23 17:05:23 +0200
commit9aa29436b344c0c63cf483d8a93142cf87a6d9cb (patch)
tree943343ec27aba0aa4456c006024e25ea65b19c91 /src/selftest
parentchacha20-arm: use new scalar implementation (diff)
downloadwireguard-monolithic-historical-9aa29436b344c0c63cf483d8a93142cf87a6d9cb.tar.xz
wireguard-monolithic-historical-9aa29436b344c0c63cf483d8a93142cf87a6d9cb.zip
allowedips: work around kasan stack frame bug in selftest
Diffstat (limited to 'src/selftest')
-rw-r--r--src/selftest/allowedips.h11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/selftest/allowedips.h b/src/selftest/allowedips.h
index 36d9bec..ca5f256 100644
--- a/src/selftest/allowedips.h
+++ b/src/selftest/allowedips.h
@@ -495,7 +495,7 @@ bool __init allowedips_selftest(void)
{
struct wireguard_peer *a = NULL, *b = NULL, *c = NULL, *d = NULL,
*e = NULL, *f = NULL, *g = NULL, *h = NULL;
- struct allowedips_cursor cursor = { 0 };
+ struct allowedips_cursor *cursor;
struct walk_ctx wctx = { 0 };
bool success = false;
struct allowedips t;
@@ -504,6 +504,12 @@ bool __init allowedips_selftest(void)
size_t i = 0;
__be64 part;
+ cursor = kzalloc(sizeof(*cursor), GFP_KERNEL);
+ if (!cursor) {
+ pr_info("allowedips self-test malloc: FAIL\n");
+ return false;
+ }
+
mutex_init(&mutex);
mutex_lock(&mutex);
@@ -616,7 +622,7 @@ bool __init allowedips_selftest(void)
insert(4, a, 10, 1, 0, 20, 29);
insert(6, a, 0x26075300, 0x6d8a6bf8, 0xdab1f1df, 0xc05f1523, 83);
insert(6, a, 0x26075300, 0x6d8a6bf8, 0xdab1f1df, 0xc05f1523, 21);
- allowedips_walk_by_peer(&t, &cursor, a, walk_callback, &wctx, &mutex);
+ allowedips_walk_by_peer(&t, cursor, a, walk_callback, &wctx, &mutex);
test_boolean(wctx.count == 5);
test_boolean(wctx.found_a);
test_boolean(wctx.found_b);
@@ -644,6 +650,7 @@ free:
kfree(g);
kfree(h);
mutex_unlock(&mutex);
+ kfree(cursor);
return success;
}