summaryrefslogtreecommitdiffhomepage
path: root/src/selftest/allowedips.h
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
commit05eedf2288b5f9b1a86a7ca4efe31835369302ad (patch)
tree999a4794bcb6a01100f4e04f2590b5f071b5b653 /src/selftest/allowedips.h
parenta2ade5f157ed59c012b4d66438a496529e030411 (diff)
allowedips: work around kasan stack frame bug in selftest
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'src/selftest/allowedips.h')
-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;
}