<feed xmlns='http://www.w3.org/2005/Atom'>
<title>wireguard-linux-compat/src/selftest, branch master</title>
<subtitle>WireGuard kernel module backport for Linux 3.10 - 5.5</subtitle>
<id>https://git.zx2c4.com/wireguard-linux-compat/atom/src/selftest?h=master</id>
<link rel='self' href='https://git.zx2c4.com/wireguard-linux-compat/atom/src/selftest?h=master'/>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-linux-compat/'/>
<updated>2021-06-04T14:57:59Z</updated>
<entry>
<title>allowedips: free empty intermediate nodes when removing single node</title>
<updated>2021-06-04T14:57:59Z</updated>
<author>
<name>Jason A. Donenfeld</name>
<email>Jason@zx2c4.com</email>
</author>
<published>2021-06-02T13:40:55Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-linux-compat/commit/?id=383461dba89e31631a972dd4d090bc4cc650088f'/>
<id>urn:sha1:383461dba89e31631a972dd4d090bc4cc650088f</id>
<content type='text'>
When removing single nodes, it's possible that that node's parent is an
empty intermediate node, in which case, it too should be removed.
Otherwise the trie fills up and never is fully emptied, leading to
gradual memory leaks over time for tries that are modified often. There
was originally code to do this, but was removed during refactoring in
2016 and never reworked. Now that we have proper parent pointers from
the previous commits, we can implement this properly.

In order to reduce branching and expensive comparisons, we want to keep
the double pointer for parent assignment (which lets us easily chain up
to the root), but we still need to actually get the parent's base
address. So encode the bit number into the last two bits of the pointer,
and pack and unpack it as needed. This is a little bit clumsy but is the
fastest and less memory wasteful of the compromises. Note that we align
the root struct here to a minimum of 4, because it's embedded into a
larger struct, and we're relying on having the bottom two bits for our
flag, which would only be 16-bit aligned on m68k.

The existing macro-based helpers were a bit unwieldy for adding the bit
packing to, so this commit replaces them with safer and clearer ordinary
functions.

We add a test to the randomized/fuzzer part of the selftests, to free
the randomized tries by-peer, refuzz it, and repeat, until it's supposed
to be empty, and then then see if that actually resulted in the whole
thing being emptied. That combined with kmemcheck should hopefully make
sure this commit is doing what it should. Along the way this resulted in
various other cleanups of the tests and fixes for recent graphviz.

Signed-off-by: Jason A. Donenfeld &lt;Jason@zx2c4.com&gt;
</content>
</entry>
<entry>
<title>allowedips: initialize list head in selftest</title>
<updated>2021-06-04T14:57:59Z</updated>
<author>
<name>Jason A. Donenfeld</name>
<email>Jason@zx2c4.com</email>
</author>
<published>2021-04-21T23:03:25Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-linux-compat/commit/?id=3c14c4bf90f37ad5d0bc6e0e0e7972f9ae4ad3ed'/>
<id>urn:sha1:3c14c4bf90f37ad5d0bc6e0e0e7972f9ae4ad3ed</id>
<content type='text'>
The randomized trie tests weren't initializing the dummy peer list head,
resulting in a NULL pointer dereference when used. Fix this by
initializing it in the randomized trie test, just like we do for the
static unit test.

While we're at it, all of the other strings like this have the word
"self-test", so add it to the missing place here.

Signed-off-by: Jason A. Donenfeld &lt;Jason@zx2c4.com&gt;
</content>
</entry>
<entry>
<title>noise: separate receive counter from send counter</title>
<updated>2020-05-20T05:18:53Z</updated>
<author>
<name>Jason A. Donenfeld</name>
<email>Jason@zx2c4.com</email>
</author>
<published>2020-05-20T05:06:45Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-linux-compat/commit/?id=448891d8217dab3df79ba7506164cbc8dc18288a'/>
<id>urn:sha1:448891d8217dab3df79ba7506164cbc8dc18288a</id>
<content type='text'>
In "queueing: preserve flow hash across packet scrubbing", we were
required to slightly increase the size of the receive replay counter to
something still fairly small, but an increase nonetheless.  It turns out
that we can recoup some of the additional memory overhead by splitting
up the prior union type into two distinct types. Before, we used the
same "noise_counter" union for both sending and receiving, with sending
just using a simple atomic64_t, while receiving used the full replay
counter checker. This meant that most of the memory being allocated for
the sending counter was being wasted. Since the old "noise_counter" type
increased in size in the prior commit, now is a good time to split up
that union type into a distinct "noise_replay_ counter" for receiving
and a boring atomic64_t for sending, each using neither more nor less
memory than required.

Also, since sometimes the replay counter is accessed without
necessitating additional accesses to the bitmap, we can reduce cache
misses by hoisting the always-necessary lock above the bitmap in the
struct layout. We also change a "noise_replay_counter" stack allocation
to kmalloc in a -DDEBUG selftest so that KASAN doesn't trigger a stack
frame warning.

All and all, removing a bit of abstraction in this commit makes the code
simpler and smaller, in addition to the motivating memory usage
recuperation. For example, passing around raw "noise_symmetric_key"
structs is something that really only makes sense within noise.c, in the
one place where the sending and receiving keys can safely be thought of
as the same type of object; subsequent to that, it's important that we
uniformly access these through keypair-&gt;{sending,receiving}, where their
distinct roles are always made explicit. So this patch allows us to draw
that distinction clearly as well.

Signed-off-by: Jason A. Donenfeld &lt;Jason@zx2c4.com&gt;
</content>
</entry>
<entry>
<title>selftests: initalize ipv6 members to NULL to squelch clang warning</title>
<updated>2020-05-06T01:15:45Z</updated>
<author>
<name>Jason A. Donenfeld</name>
<email>Jason@zx2c4.com</email>
</author>
<published>2020-05-05T21:16:26Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-linux-compat/commit/?id=3f54461d3cf43176b06467de619018382baf4cb7'/>
<id>urn:sha1:3f54461d3cf43176b06467de619018382baf4cb7</id>
<content type='text'>
Without setting these to NULL, clang complains in certain
configurations that have CONFIG_IPV6=n:

In file included from drivers/net/wireguard/ratelimiter.c:223:
drivers/net/wireguard/selftest/ratelimiter.c:173:34: error: variable 'skb6' is uninitialized when used here [-Werror,-Wuninitialized]
                ret = timings_test(skb4, hdr4, skb6, hdr6, &amp;test_count);
                                               ^~~~
drivers/net/wireguard/selftest/ratelimiter.c:123:29: note: initialize the variable 'skb6' to silence this warning
        struct sk_buff *skb4, *skb6;
                                   ^
                                    = NULL
drivers/net/wireguard/selftest/ratelimiter.c:173:40: error: variable 'hdr6' is uninitialized when used here [-Werror,-Wuninitialized]
                ret = timings_test(skb4, hdr4, skb6, hdr6, &amp;test_count);
                                                     ^~~~
drivers/net/wireguard/selftest/ratelimiter.c:125:22: note: initialize the variable 'hdr6' to silence this warning
        struct ipv6hdr *hdr6;
                            ^

We silence this warning by setting the variables to NULL as the warning
suggests.

Reported-by: Arnd Bergmann &lt;arnd@arndb.de&gt;
Signed-off-by: Jason A. Donenfeld &lt;Jason@zx2c4.com&gt;
</content>
</entry>
<entry>
<title>allowedips: avoid double lock in selftest error case</title>
<updated>2019-11-26T10:33:33Z</updated>
<author>
<name>Jason A. Donenfeld</name>
<email>Jason@zx2c4.com</email>
</author>
<published>2019-11-25T10:16:01Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-linux-compat/commit/?id=da0e24a44cfc76a93a369075c2514a4b3247c840'/>
<id>urn:sha1:da0e24a44cfc76a93a369075c2514a4b3247c840</id>
<content type='text'>
Signed-off-by: Jason A. Donenfeld &lt;Jason@zx2c4.com&gt;
</content>
</entry>
<entry>
<title>allowedips: maintain per-peer list of allowedips</title>
<updated>2019-02-26T22:01:12Z</updated>
<author>
<name>Jason A. Donenfeld</name>
<email>Jason@zx2c4.com</email>
</author>
<published>2019-02-26T02:38:24Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-linux-compat/commit/?id=cc58f5878702332bd5b619f39b2c0ab9dbdef292'/>
<id>urn:sha1:cc58f5878702332bd5b619f39b2c0ab9dbdef292</id>
<content type='text'>
This makes `wg show` and `wg showconf` and the like significantly
faster, since we don't have to iterate through every node of the trie
for every single peer. It also makes netlink cursor resumption much less
problematic, since we're just iterating through a list, rather than
having to save a traversal stack.

Signed-off-by: Jason A. Donenfeld &lt;Jason@zx2c4.com&gt;
</content>
</entry>
<entry>
<title>ratelimiter: build tests with !IPV6</title>
<updated>2019-01-23T13:29:44Z</updated>
<author>
<name>Jason A. Donenfeld</name>
<email>Jason@zx2c4.com</email>
</author>
<published>2019-01-03T02:08:49Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-linux-compat/commit/?id=0c6958b2e3d6c01e13038fa690036ccbb922cce3'/>
<id>urn:sha1:0c6958b2e3d6c01e13038fa690036ccbb922cce3</id>
<content type='text'>
Signed-off-by: Jason A. Donenfeld &lt;Jason@zx2c4.com&gt;
</content>
</entry>
<entry>
<title>global: update copyright</title>
<updated>2019-01-08T00:26:10Z</updated>
<author>
<name>Jason A. Donenfeld</name>
<email>Jason@zx2c4.com</email>
</author>
<published>2019-01-02T00:58:10Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-linux-compat/commit/?id=962d7c947da268bec508bd17a1b6d5e4df07b943'/>
<id>urn:sha1:962d7c947da268bec508bd17a1b6d5e4df07b943</id>
<content type='text'>
Signed-off-by: Jason A. Donenfeld &lt;Jason@zx2c4.com&gt;
</content>
</entry>
<entry>
<title>allowedips: fix sparse warnings in optional selftests</title>
<updated>2018-10-27T01:11:31Z</updated>
<author>
<name>Jason A. Donenfeld</name>
<email>Jason@zx2c4.com</email>
</author>
<published>2018-10-25T15:27:11Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-linux-compat/commit/?id=377d89defdacecbf28be3bf58d8fb001930c5e15'/>
<id>urn:sha1:377d89defdacecbf28be3bf58d8fb001930c5e15</id>
<content type='text'>
Signed-off-by: Jason A. Donenfeld &lt;Jason@zx2c4.com&gt;
</content>
</entry>
<entry>
<title>global: give if statements brackets and other cleanups</title>
<updated>2018-10-08T23:57:47Z</updated>
<author>
<name>Jason A. Donenfeld</name>
<email>Jason@zx2c4.com</email>
</author>
<published>2018-10-08T20:54:32Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-linux-compat/commit/?id=1564e913bf02a924116497bdb8c1b994298c0465'/>
<id>urn:sha1:1564e913bf02a924116497bdb8c1b994298c0465</id>
<content type='text'>
Signed-off-by: Jason A. Donenfeld &lt;Jason@zx2c4.com&gt;
</content>
</entry>
</feed>
